Untitled
unknown
plain_text
3 years ago
444 B
8
Indexable
https://codeshare.io/eV
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 <host_ip> <port>"
exit 3 # NRPE Critical status code
fi
host_ip="$1"
port="$2"
timeout 3 /bin/bash -c "</dev/tcp/${host_ip}/${port}" &>/dev/null
if [ $? -eq 0 ]; then
echo "OK: Port ${port} is open on ${host_ip}"
exit 0 # NRPE OK status code
else
echo "CRITICAL: Port ${port} is closed on ${host_ip}"
exit 2 # NRPE Critical status code
fi
Editor is loading...