28. 11. 2011 Patrick Zambelli Uncategorized

Automatic Nagios Downtime schedulation script

This blog article presents a little tool that might be useful to automatize tasks around Nagios. In every day’s IT administrator tasks the reboot and downtime for servers and services maintenance is not avoidable.

One of the administration tasks in NetEye is also the schedulation of such downtimes in order to avoid predictable alert notifications via eMail and SMS, but also to respect the downtime periods for your SLA statistics.

Here I would like to introduce a little script that allows to setup downtime periods in a direct way via command line. For even repeated events it would be possible to accomplish via cron job.

The script call itself requires just the essential information: The name of the host and the service for which is needed to schedule the downtime. Additional arguments might be the Downtime comment description and the duration.
A possible command call would be:  ./schedule_nagios_downtime.pl <nagios host> <nagios service> [<comment> <seconds of downtime>]

Example:
[root@neteye ~]# ./schedule_nagios_downtime.pl neteye Current+Users Downtime+for+maintainance 7200

You can note that Host and Service Names with non basic-ASCII characters special encoding is required. The replacement for a space is for example a “+”. The result would be  as shown below:


To facilitate the discovery of problems the script execution results are kept in a local logfile in /tmp. Just read the file to extract the last execution html:

[root@neteye ~]# cat /tmp/nagios_downtime.log

Get the script

You can download the script here: schedule_nagios_downtime.pl.tar

Just copy it somewhere on your NetEye ( or Nagios installation ) and define within the first lines a few initial things:

  • the URL to the local or remote cgi
  • The user to authenticate
  • The password

That’s it. Now the script should be ready. If the web server’s authentication is correct and the server returns some strings the content is logged in the /tmp/nagios_downtime.html

Patrick Zambelli

Patrick Zambelli

Project Manager at Würth Phoenix
After my graduation in Applied Computer Science at the Free University of Bolzano I decided to start my professional career outside the province. With a bit of good timing and good luck I went into the booming IT-Dept. of Geox in the shoe district of Montebelluna, where I realized how a big IT infrastructure has to grow and adapt to quickly changing requirements. During this experience I had also the nice possibility to travel the world, while setting up the various production and retail areas of this company. Arrived at Würth Phoenix I started developing on our monitoring solution NetEye. Today, in my position as Consulting an Project Manager I am continuously heading to implement our solutions to meet the expectation of your enterprise customers.

Author

Patrick Zambelli

After my graduation in Applied Computer Science at the Free University of Bolzano I decided to start my professional career outside the province. With a bit of good timing and good luck I went into the booming IT-Dept. of Geox in the shoe district of Montebelluna, where I realized how a big IT infrastructure has to grow and adapt to quickly changing requirements. During this experience I had also the nice possibility to travel the world, while setting up the various production and retail areas of this company. Arrived at Würth Phoenix I started developing on our monitoring solution NetEye. Today, in my position as Consulting an Project Manager I am continuously heading to implement our solutions to meet the expectation of your enterprise customers.

2 Replies to “Automatic Nagios Downtime schedulation script”

  1. grayloglearn says:

    Do we have any script to remove the schedule downtime using nagios API with selected hostnames along with host services.

    1. Patrick Zambelli says:

      Unfortunately I had only the usecase to schedule the downtimes.
      To extend my replay: Today we are using icinga2 for monitoring and there are very nice ways to schedule downtimes via API https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/

Leave a Reply

Your email address will not be published. Required fields are marked *

Archive