Skip to content

Instantly share code, notes, and snippets.

@slillibri
Created December 19, 2010 00:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slillibri/746998 to your computer and use it in GitHub Desktop.
Save slillibri/746998 to your computer and use it in GitHub Desktop.
Nagios passive check
#!/bin/bash
## Example passive service check for smtp
SVC_RES=`/usr/lib/nagios/plugins/check_smtp -H localhost -t 5`
NOW=`date +%s`
CMD_FILE='/var/run/nagios3/rw/nagios.cmd'
NAGIOS_HOST='your.nagios.host'
HOST=`hostname -f`
case $SVC_RES in
0) `ssh $NAGIOS_HOST 'printf "[%lu] PROCESS_SERVICE_CHECK_RESULT;$HOST;SMPT;0;OK- Everything Looks Great\n" $now > $commandfile'`
1) `ssh $NAGIOS_HOST 'printf "[%lu] PROCESS_SERVICE_CHECK_RESULT;$HOST;SMPT;1;WARNING- Something Amis\n" $now > $commandfile'`
2) `ssh $NAGIOS_HOST 'printf "[%lu] PROCESS_SERVICE_CHECK_RESULT;$HOST;SMPT;2;CRITICAL- Service not running\n" $now > $commandfile'`
*) `ssh $NAGIOS_HOST 'printf "[%lu] PROCESS_SERVICE_CHECK_RESULT;$HOST;SMPT;3;UNKNOWN- There was a problem with the command\n" $now > $commandfile'`
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment