Event Handlers on the External Commands
mark redding
mwjredding at gmail.com
Tue Dec 11 18:29:57 CET 2007
Hi,
On 11/12/2007, ankit.mehrotra at tcs.com <ankit.mehrotra at tcs.com> wrote:
>
> For this, I want to write Event Handlers on the External Commands, but I am
> not sure How to go about it ?
> Does somebody has any idea about it ? any sample code will be of great
> help.
These snippet of shell script may be of use (at least to show you how
to send commands to nagios externally).
#!/bin/sh
# post commands to nagios
now=$(date +%s)
echo "[$now] ENABLE_NOTIFICATIONS" > /data/nagios/spool/rw/nagios.cmd
echo "[$now] STOP_EXECUTING_HOST_CHECKS" > /data/nagios/spool/rw/nagios.cmd
echo "[$now] START_EXECUTING_SVC_CHECKS" > /data/nagios/spool/rw/nagios.cmd
echo "[$now] DISABLE_PERFORMANCE_DATA" > /data/nagios/spool/rw/nagios.cmd
echo "[$now] DISABLE_HOST_CHECK;www.site.com" > /data/nagios/spool/rw/nagios.cmd
echo "[$now] DISABLE_SVC_CHECK;web;WEBSITE" > /data/nagios/spool/rw/nagios.cmd
#!/bin/sh
# process an event handler
echo `date` ": called $0 script with $1 $2 $3" >> ~/event.log
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
case "$2" in
SOFT)
case "$3" in
1)
ssh -l nagios
webserver sudo /www/bin/apachectl restart
echo `date` ": apache
rebooted" >> ~/event.log
;;
esac
;;
HARD)
case "$3" in
3)
ssh -l nagios
webserver sudo /www/bin/apachectl restart
echo `date` ": apache
rebooted again" >> ~/event.log
;;
esac
;;
esac
esac
--
bright blessings,
Mark
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list