Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gateway check for pfSense
#!/bin/sh
# add this file as /usr/local/libexec/check_pfsense_dpinger
# apinger is gone. This is a new RTT check based on output available from the dpinger sockets
FILES=$(find /var/run | grep dpinger | grep sock)
stateid=0
message=''
OIFS=$IFS
IFS=$'\n'
temp=$FILES
for FILE in $temp
do
name=$(cat $FILE | cut -d' ' -f1)
rrt=$(cat $FILE | cut -d' ' -f2)
rrts=$(cat $FILE | cut -d' ' -f3)
loss=$(cat $FILE | cut -d' ' -f4)
# echo $name $rtt $rtts $loss
message="${message}${name}: ${loss}% "
if [ "$loss" -lt "5" ];
then
if [ "$stateid" -lt "1" ];
then
status="OK"
stateid=0
fi
elif [ "$loss" -gt "6" ] && [ "$loss" -lt "100" ];
then
if [ "$stateid" -lt "1" ];
then
status="WARNING"
stateid=1
fi
elif [ "$loss" -eq "100" ];
then
if [ "$stateid" -lt "2" ];
then
status="CRITICAL"
stateid=2
fi
fi
done
echo "$status - $message"
exit $stateid
# add to /usr/local/etc/nrpe.cfg and restart NRPE service
command[check_gateways]=/usr/local/libexec/nagios/check_pfsense_dpinger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment