Cancel scheduled hostgroup dowtime

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

Cancel scheduled hostgroup dowtime

Post 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
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Cancel scheduled hostgroup dowtime

Post 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
You do not have the required permissions to view the files attached to this post.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

Re: Cancel scheduled hostgroup dowtime

Post 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?
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Cancel scheduled hostgroup dowtime

Post 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.
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
TSCAdmin
Posts: 155
Joined: Wed Apr 14, 2010 3:00 pm
Location: India

Re: Cancel scheduled hostgroup dowtime

Post 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! :)
tonyyarusso
Posts: 1128
Joined: Wed Mar 03, 2010 12:38 pm
Location: St. Paul, MN, USA
Contact:

Re: Cancel scheduled hostgroup dowtime

Post by tonyyarusso »

Looks good!
Tony Yarusso
Technical Services
___
TIES
Web: http://ties.k12.mn.us/
Locked