This guy did it using NSCA and an event handler:
nagiosexchange.org/Wiki_Home … drwiki_pi1[keyword]=RemoteHostScheduledDowntimeAtReboot
But if it were me, I’d probably write a script on the remote host that rsync’s or scp’s some token filename with a few bytes in it over to the nagios host, and have a cron job run a script on the nagios host every minute checking for the existance of that file that isn’t zero-length, and if it exists, create a filename.running file (so that the script doesn’t trip over itself the next minute if still running), and then write a “DISABLE_SVC_NOTIFICATIONS” command to the nagios external cmd pipe and leave the filename.running in place. When the remote host is done, it can rsync or scp over a zero-length file of the same filename, and the next minute the script executes, it sees the zero-length file and deletes the both the filename and filename.running, and sends a “ENABLE_SVC_NOTIFICATIONS” command to the nagios external cmd pipe.
For a full list of external commands:
nagios.org/developerinfo/ext … ndlist.php
I just whipped up the script below and tested it (sorry, the forums screw up the indents), I created /var/spool/tsmbackup with the word MEAT in it and ran the script, which disabled active checks on a particular service, and then later I did a “> /var/spool/tsmbackup” (zero-lengthed the file) and ran the script again and it enabled the service checks and cleaned up after itself.
#!/bin/bash
now=date +%s
commandfile=’/var/spool/nagios/nagios.cmd’
tokenfile=’/var/spool/tsmbackup’
if -f $tokenfile ] ; then
if ! -s $tokenfile ] ; then
# backup has completed
echo -e "${now}] ENABLE_SVC_NOTIFICATIONS;sn-db2;CDR Database Push\\n" > $commandfile
if -f ${tokenfile}.running ] ; then
rm ${tokenfile}.running
fi
rm $tokenfile
else
# backup is occuring
if ! -f ${tokenfile}.running ] ; then
touch ${tokenfile}.running
echo -e "${now}] DISABLE_SVC_NOTIFICATIONS;sn-db2;CDR Database Push\\n" > $commandfile
fi
fi
fi
You could add some mail commands into the script if you want to warn people that the backup is happening and the service isn’t being monitored or is done and is being monitored again. You could also add a check to see how long the .running file has been hanging around, and re-enable the service checks and clean up if it’s been over a certain duration, so that if the database is still down (backup program barfed?) after the expected backup period, nagios will be the one to send out the alert. Also, instead of using DISABLE_SVC_NOTIFICATIONS, you could let the service-down alert happen, and instead play with ACKNOWLEDGE_SVC_PROBLEM, which gets you your requirement above to only use nagios for all emails.
-mike
Edited Thu Dec 29 2005, 12:03AM ]