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
Cancel scheduled hostgroup dowtime
-
tonyyarusso
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: Cancel scheduled hostgroup dowtime
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.
You do not have the required permissions to view the files attached to this post.
Re: Cancel scheduled hostgroup dowtime
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?
-
tonyyarusso
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: Cancel scheduled hostgroup dowtime
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
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
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!
# 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.datSuper duper thanks Tony!
-
tonyyarusso
- Posts: 1128
- Joined: Wed Mar 03, 2010 12:38 pm
- Location: St. Paul, MN, USA
- Contact:
Re: Cancel scheduled hostgroup dowtime
Looks good!