I wrote the following plugin which alerts on Available Memory on FreeBSD. It runs locally on remote machine and its nagios status is ok on the core. But it fails over NRPE. I don't see any errors in the NRPE log file.
Code: Select all
#!/usr/local/bin/bash
if [ "$1" = "-w" ] && [ "$2" -lt "101" ] && [ "$3" = "-c" ] && [ "$4" -lt "101" ] ; then
warn=$2
crit=$4
AVAILMEMPERC=$(free -m | grep 'mem_avail' | sed 's/.*\[ \(.*\)\]/\1/' | awk '{print $1}' | tr -d %)
if [ ${AVAILMEMPERC} -gt $warn ] && [ ${AVAILMEMPERC} -gt $crit ];then
echo "OK - Available Memory = $AVAILMEMPERC% | Available memory=$AVAILMEMPERC%;$warn;$crit;0;100"
exit 0
elif [ ${AVAILMEMPERC} -lt $warn ] && [ ${AVAILMEMPERC} -gt $crit ]; then
echo "WARNING - Available Memory = $AVAILMEMPERC% | Available memory=$AVAILMEMPERC%;$warn;$crit;0;100"
exit 1
else
echo "CRITICAL - Available Memory = $AVAILMEMPERC% | Available memory=$AVAILMEMPERC%;$warn;$crit;0;100"
exit 2
fi
else
echo "$0 - Nagios Plugin for checking the available memory in a Linux system"
echo ""
echo "Usage: $0 -w <warnlevel> -c <critlevel>"
echo " = warnlevel and critlevel is warning and critical value for alerts."
echo ""
echo "EXAMPLE: $0 -w 10 -c 5 "
echo " = This will send warning alert when available memory is less than 10%, and send critical when it is less than 5%"
echo ""
exit 3
fi
OK - Available Memory = 88% | Available memory=88%;20;10;0;100
On web gui:
CRITICAL - Available Memory = %
From the GUI output, it looks like the variable value hasn't been grabbed but I am not sure what the issue is. All the other plugins are running fine.