Skip to content

Instantly share code, notes, and snippets.

@yakatz
Created August 15, 2014 03:43
Show Gist options
  • Save yakatz/c70ee6bfd8a9a9c00463 to your computer and use it in GitHub Desktop.
Save yakatz/c70ee6bfd8a9a9c00463 to your computer and use it in GitHub Desktop.
pfSense NRPE Multiple Gateway RTT Check
#!/bin/sh
# check_pfsense_rtt2.1.4 Version 0.2
# Based on Copyright 2012, Justin Edmands, justinedmands@gmail.com
# Modified 2014, Yehuda Katz, yehuda@ymkatz.net
# Info available from http://justinedmands.com/?q=nagios_check_pfsense_rtt
# License for use: http://www.opensource.org/licenses/bsd-license.php
# place this file in your pfsense nagios plugin directory. As of pfsense 2.0.2, this is /usr/local/libexec/nagios. Make the plugin executable with chmod 755.
# In later pfSense versions, this is /usr/pbi/nrpe-*/libexec/nagios/
# This is compatible with pfsense 2.1.4
stateid=-1
while read p; do
real_rtt=`echo $p | cut -f7 -d '|' | sed s/ms//`
rtt=`echo $p | cut -f7 -d '|' | sed s/....ms//`
isp=`echo $p | cut -f3 -d '|'`
ispIP=`echo $p | cut -f1 -d '|'`
if [ $rtt -lt 50 ]
then
echo "Normal - $isp RTT OK for $ispIP : $real_rtt ms"
if [ $stateid -lt 0 ]
then
stateid=0
fi
elif [ $rtt -gt 50 ] && [ $rtt -lt 100 ]
then
echo "Warning - $isp RTT Increasing for $ispIP : $real_rtt ms"
if [ $stateid -lt 1 ]
then
stateid=1
fi
elif [ $rtt -gt 100 ]
then
echo "Alert - $isp RTT Critical for $ispIP : $real_rtt ms"
if [ $stateid -lt 2 ]
then
stateid=2
fi
fi
done < /var/run/apinger.status
exit $stateid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment