Last active
May 6, 2017 16:50
-
-
Save TheCase/004186b882df347d764c09ad64f1a4cb to your computer and use it in GitHub Desktop.
gateway check for pfSense
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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