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
Italiano
English
Deutsch