Skip to content

Instantly share code, notes, and snippets.

@TheCase
Last active May 6, 2017 16:50
Show Gist options
  • Save TheCase/004186b882df347d764c09ad64f1a4cb to your computer and use it in GitHub Desktop.
Save TheCase/004186b882df347d764c09ad64f1a4cb to your computer and use it in GitHub Desktop.
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