Newer
Older
icinga-plugins / check_port
Paul Staroch on 21 Dec 2017 455 bytes added plugin check_port
#!/bin/bash

# example for nagios-nrpe-server:
# command[check_openvpn]=/opt/icinga/check_port 1194

if [ "$1" == "" ]; then
	echo Missing first parameter.
	exit 3
fi
if [ "$2" == "" ]; then
	COUNT=`netstat -tulpen|grep -c "$1"`
	if [ "$COUNT" -eq 0 ]; then
		echo Port not open.
		exit 2
	fi

	echo Port open.
	exit 0
fi

COUNT=`netstat -tulpen|grep "$1"|grep -c "$2"`
if [ "$COUNT" -eq 0 ]; then
	echo Port not open.
	exit 2
fi

echo Port open.
exit 0