Template for Generic Nagios Plugin | blog.jgriffiths.org
I love nagios it’s the perfect way to monitor linux. Monitoring command can be written in almost any language: nagios expects a exit code and a exit string and it works. I write most of my plugins in bash shell. Here is a generic plugin template:
!/bin/bash
Sanity check
if [ $# -ne 2 ]; then
echo « Usage: $0 commandline1 commandline2″
exit
fi
COMMAND=`commandhere`
ESUCCESS= »0″
EWARNING= »1″
ECRITICAL= »2″
E_UNKNOWN= »3 »
if grep -q « succeeded! » <<< $COMMAND; then echo "OK - $1 $2 working" exit ${ESUCCESS} else echo "CRITICAL - $1 $2 not working" exit ${ECRITICAL} fi © 2010, Joseph Griffiths. All rights reserved.