Page 1 of 1
Cancel scheduled hostgroup dowtime
Posted: Tue May 10, 2011 1:17 am
by TSCAdmin
Hello,
We are using Nagios XI 2009R1.3. I scheduled fixed downtime for a hostgroup, let's say windows-servers. We wanted the downtime to expire a couple of hours before the scheduled downtime ends. I tried
$ echo "[($date +%s)] DEL_HOST_DOWNTIME;windows-servers >> nagios.cmd
This did not show any errors in nagios.log but the downtime wasn't cancelled. I have searched online and found a few old scripts/modules that do not seem to work now.
Is there anyway we can force schedule downtime to expire before the fixed end time?
Thanks
Re: Cancel scheduled hostgroup dowtime
Posted: Tue May 10, 2011 9:56 am
by tonyyarusso
Under "Incident Management" in the left sidebar, click "Scheduled Downtime", and you will get a list of current downtimes. On the right you will see a trash can under "Actions", and clicking this for the relevant downtime will delete it.
delete-downtime.png
Re: Cancel scheduled hostgroup dowtime
Posted: Wed May 11, 2011 1:31 am
by TSCAdmin
Yes you are right Tony but it's not feasible when your hostgroup has over 500 items. So I was wondering if there is a way to remove the downtime for a host group in one go instead of clicking trash 500 times?
Re: Cancel scheduled hostgroup dowtime
Posted: Wed May 11, 2011 9:33 am
by tonyyarusso
Ah, I see - you actually want to script it. In that case, the command format seems to be slightly different, and is described on
http://old.nagios.org/developerinfo/ext ... and_id=125. Not that it is expecting the downtime ID, rather than the name of the hostgroup. So, according to the documentation at least, you would have to loop over parsing the status.dat file to find the IDs for downtimes associated with that hostgroup, and then cancel any that are found.
Re: Cancel scheduled hostgroup dowtime
Posted: Thu May 12, 2011 7:42 am
by TSCAdmin
Wow, that's a wonderful idea! I was able to exploit this and came up with (if you please allow me to share)
# get the list of downtime ids and host names, separated by a new line, matching "Windows environment patching" and comment
Code: Select all
$ perl -n00 -e '/comment=Windows environment patching/ && (/downtime_id=(\d+)/ && print $1) && (/host_name=(\S+)/ && print " $1\n")' /usr/local/nagios/var/status.dat
and obviously it could just be converted to a BASH for loop to iterate over the downtime ids with DEL_HOST_DOWNTIME.
Super duper thanks Tony!

Re: Cancel scheduled hostgroup dowtime
Posted: Thu May 12, 2011 9:18 am
by tonyyarusso
Looks good!