Giter Club home page Giter Club logo

nagios_downtime's Introduction

nagios_downtime - Script based downtime scheduling

nagios_downtime can be used to schedule downtimes directly from monitored machines to automaticaly schedule downtimes in Nagios only with having access to the Nagios CGIs or Multisite with having access to the Web API. There is no additional connection needed.

You can schedule those downtimes automaticaly on system reboot by an init script. You could also run the script to schedule downtimes for special services e.g. during backups of databases. nagios_downtime can create a downtime in Nagios/Multisite before shuting down the database to start the backup (add mode) and delete the downtime again when the backup is finished (del mode).

Scheduling downtimes for planned downtimes gives you several advantages:

  • No alerts are raised by planned downtimes
  • The unplanned downtime in reporting is not affected by such downtimes

Currently the nagios_downtime Scripts are shipped for Linux (written in Perl) and Windows (written in VBS). The intention was to have two scripts for the different platforms to reach one goal. During time both scripts diverged a bit. I started development of these scripts back in 2005, so please don't be too strict with the coding style, I am a bit unhappy with this for myself, but currently don't have the time to fix this. Maybe I find the time to fix this one day. You are welcome to send improvements!

Linux (Perl script)

Prerequisites (Perl)

  • Perl
  • Perl Modules:
    • LWP
    • Switch
    • Net::Ping
    • Sys::Hostname
    • Getopt::Long

Usage

You can use the provided init script to set up a basic downtime scheduling. In some cases you may need to change the parameter in the init script calls or the options in the nagios_downtime file to fit your needs. For example the options for accessing the CGI files will be needed to be changed in most environments.

You basicaly have two ways to provide the options to the script:

a) via command line b) via editing the options in the script

For details about the single command line parameters please execute this:

# nagios_downtime -h

You may create a configuration file with the basic parameters like Nagios host, cgi path, cgi user and password using the options in the nagios_downtime script. This way you don't need to provide the parameters on each call.

Examples:

OMD with Multisite

This command can be used to schedule a downtime of 15 minutes on a OMD host (omd.my-domain.com) with Multisite enabled. The path /omdsite/check_mk, the user automationuser and its password automationpassword will be used to access the API. A host-downtime for the host webserver.my-domain.com will be scheduled.

# nagios_downtime -m add -t 15 -i multisite -S omd.my-domain.com -p /omdsite/check_mk \
                  -u automationuser -P automationpassword -H webserver.my-domain.com

With this command you can terminate the downtime. You need to have the saving of the downtime ids enabled.

# nagios_downtime -m del -i multisite -S omd.my-domain.com -p /omdsite/check_mk \
                  -u nagiosadmin -P nagiosadmin -H webserver.my-domain.com
Nagios

This command can be used to schedule a downtime of 15 minutes on the nagios host (nagios.my-domain.com). The CGIs are located at /nagios/cgi-bin. The CGIs can be accessed by the user nagiosadmin with password nagiosadmin. A host-downtime for the host webserver.my-domain.com will be scheduled.

# nagios_downtime -m add -t 15 -S nagios.my-domain.com -p /nagios/cgi-bin \
                  -u nagiosadmin -P nagiosadmin -H webserver.my-domain.com

With this command you can terminate the downtime. You need to have the saving of the downtime ids enabled.

# nagios_downtime -m del -S nagios.my-domain.com -p /nagios/cgi-bin \
                  -u nagiosadmin -P nagiosadmin -H webserver.my-domain.com

Init script installation (Should work on SuSE, RedHat, CentOS, Fedora)

Copy the file nagios_downtime to /usr/bin. And make sure it is executable.

# cp -p nagios_downtime /usr/bin
# chmod +x /usr/bin/nagios_downtime

Copy the init script nagios_downtime.init to /etc/init.d. Also make sure it is executable.

# cp -p nagios_downtime.init /etc/init.d
# chmod +x /etc/init.d/nagios_downtime.init

Activate the init script to be executed on system shutdown.

# chkconfig --add nagios_downtime
# chkconfig nagios_downtime on

Downtime deletion

The deletion of downtimes is a new feature in nagios_downtime 0.5.

You need to set the vars $storeDowntimeIds and $downtimePath in the head of the nagios_downtime file to be able to use the feature. Once enabled newly scheduled downtimes can be deleted by calling nagios_downtime in deletion mode (-m del).

Bugs and Support

I decided to use GitHub for managing project related communication, you can find the project at (https://github.com/LaMi-/nagios_downtime).

The nagios_downtime scripts were previously homed on my personal, a bit outdated, blog. You might find some useful information there in the related articles or commennts (http://larsmichelsen.com/nagios-downtime/).

Thanks

Thanks to all supporters of open source software. Keep up the great work!

Licensing

Copyright (C) 2014 Lars Michelsen [email protected]

All outcome of the project is licensed under the terms of the GNU GPL v2. Take a look at the LICENSE file for details.

nagios_downtime's People

Contributors

larsmichelsen avatar m4c3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nagios_downtime's Issues

Script exists on linux with error-code 1 und error message, though the GET request was successful

Hi,

we are using check_mk and this script for our linux servers.
It works from check_mk's point of view - scheduled downtime is succesfully submitted, but i receive a general error message ("Some undefined error occured, turn debug mode on to view what happened."
The exit-code of the script is 1 - should be 0

Here's the debug output (anonymized):

Debug: HTTP-GET: http://monitoring.xxx.yyy:80/sysmonit/check_mk/view.py?output_format=json&_transid=-1&_do_confirm=yes&_do_actions=yes&&_username=Peter&_secret=paulandmary&view_name=hoststatus&host=server0815&_down_comment=Perl Downtime-Script (ID:1482415663)&_down_from_now=yes&_down_minutes=10
Debug: HTTP-Response: HINWEIS: Erfolgreich 1 Befehle gesendet.
[
[
  "sitealias",
  "host",
  "host_parents",
  "host_childs",
  "host_addresses",
  "alias",
  "host_icons",
  "host_state",
  "host_plugin_output",
  "host_pnpgraph",
  "host_perf_data",
  "host_in_downtime",
  "host_in_notifper",
  "num_services",
  "num_services_ok",
  "num_services_warn",
  "num_services_crit",
  "num_services_unknown",
  "num_services_pending",
  "host_attempt",
  "host_notification_number",
  "host_state_age",
  "host_check_age",
  "host_next_check",
  "host_next_notification",
  "host_last_notification",
  "host_check_latency",
  "host_check_duration",
  "host_check_interval",
  "host_notifper",
  "host_contact_groups",
  "host_contacts",
  "host_group_memberlist",
  "host_servicelevel",
  "host_check_command",
  "host_custom_vars",
  "host_custom_notes"
],
[
  "Local site sysmonit",
  "server0815",
  "",
  "",
  "1.2.3.4",
  "server0815",
  "menu",
  "UP",
  "Packet received via smart PING",
  "",
  "",
  "nein",
  "ja",
  "20",
  "20",
  "0",
  "0",
  "0",
  "0",
  "1/3",
  "0",
  "2016-10-18 08:16:42",
  "0 sec",
  "in 38 sec",
  "2016-10-18 08:16:42",
  "-",
  "0.000 sec",
  "0.000 sec",
  "60s/6s",
  "24X7",
  "all, Linux",
  "Peter, Chantalle, Chayenne",
  "SQL-Server, Linux",
  "",
  "check-mk-host-smart",
  "",
  ""
]
]

Clearify nagiosDateFormat relation to nagios.cfg

Its me again :)

I cannot say my english is excellent, but i had to learn trough my failure that the value of $nagiosDateFormat has a 1:1 relation to date_format in nagios.cfg, because i did not understand "same like set" as "has to be set same".

If they differ, the downtime scheduling fails with "Start or end time not valid" because nagios expects the date format specified in its config.

Maybe the line https://github.com/LaMi-/nagios_downtime/blob/master/nagios_downtime#L108 should read:

# Nagios date format (has to be set to the same value what "date_format" has in nagios.cfg)
my $nagiosDateFormat = "us";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.