Giter Club home page Giter Club logo

nagios-report's Introduction

nagios-report

Create Nagios availability reports at the command line

Information

There are several Perl modules that can query Nagios availability information but I didn't like any of them. They also required integration work into another script. I decided to create this one as a simple solution that could print statistics quickly, for when managers want uptime reports.

Usage

  • cgi

Define path to the Nagios availability CGI (avail.cgi) as a local file path. Defaults to /usr/lib64/nagios/cgi-bin/avail.cgi

  • u|user

Define user that Nagios runs as. Defaults to nagios

  • h|host

Define host to generate availability report for. Required parameter.

  • s|service

Define service to generate availability report for. Required parameter.

  • t|timeperiod

Define the time period to report on. Defaults to lastmonth. Choose from today, last24hours, yesterday, thisweek, last7days, lastweek, thismonth, last31days, lastmonth, thisyear, lastyear

  • o|output

Define the output format. Defaults to dump. Choose from:

  • dump - dumps the whole hash of availability information. Useful for debugging.

  • uptime - prints the percentage of uptime

  • downtime - prints the duration of downtime

  • v|verbose

Define verbosity of output. Defaults to false. Adds full-sentence output to output formats uptime and downtime rather than just printing the number.

  • d|dontprinthost

Define whether to print the hostname in verbose output. Defaults to true.

  • r|recipients

The email address to send the report to. This option may be specified more than once to send multiple copies of the email. Leave blank to print the output to stdout (which causes cron to send an email instead).

Integration with BPI

Nagios BPI is a tool that can monitor a set of other Nagios services and aggregate the results to give an aggregate state. For example, if either DNS1 or DNS2 is up, then you can say that the DNS service itself is up. This script can be used to good effect with BPI to report aggregate uptime of your business services.

Examples

$ sudo ./nagios-report.pl -h server.example.co.uk -s Ping -t Today
$VAR1 = 'WARNING';
$VAR2 = {
          'Total' => {
                       'Percent' => '0.000%',
                       'Time' => '0d 0h 0m 0s'
                     },
          'Unscheduled' => {
                             'Percent' => '0.000%',
                             'Time' => '0d 0h 0m 0s'
                           },
          'Scheduled' => {
                           'Percent' => '0.000%',
                           'Time' => '0d 0h 0m 0s'
                         }
        };
$VAR3 = 'CRITICAL';
$VAR4 = {
          'Total' => {
                       'Percent' => '1.935%',
                       'Time' => '0d 0h 27m 52s'
                     },
          'Unscheduled' => {
                             'Percent' => '0.000%',
                             'Time' => '0d 0h 0m 0s'
                           },
          'Scheduled' => {
                           'Percent' => '1.935%',
                           'Time' => '0d 0h 27m 52s'
                         }
        };
$VAR5 = 'All';
$VAR6 = {
          'Total' => {
                       'Percent' => '100.000%',
                       'Time' => '1d 0h 0m 0s'
                     }
        };
$VAR7 = 'OK';
$VAR8 = {
          'Total' => {
                       'Percent' => '98.065%',
                       'Time' => '0d 23h 32m 8s'
                     },
          'Unscheduled' => {
                             'Percent' => '97.731%',
                             'Time' => '0d 23h 27m 20s'
                           },
          'Scheduled' => {
                           'Percent' => '0.333%',
                           'Time' => '0d 0h 4m 48s'
                         }
        };
$VAR9 = 'Undetermined';
$VAR10 = {
           'Total' => {
                        'Percent' => '0.000%',
                        'Time' => '0d 0h 0m 0s'
                      }
         };
$VAR11 = 'UNKNOWN';
$VAR12 = {
           'Total' => {
                        'Percent' => '0.000%',
                        'Time' => '0d 0h 0m 0s'
                      },
           'Unscheduled' => {
                              'Percent' => '0.000%',
                              'Time' => '0d 0h 0m 0s'
                            },
           'Scheduled' => {
                            'Percent' => '0.000%',
                            'Time' => '0d 0h 0m 0s'
                          }
         };
$ sudo ./nagios-report.pl -h server.example.co.uk -s Ping -t Today -o uptime
98.065%
$ sudo ./nagios-report.pl -h server.example.co.uk -s Ping -t Today -o uptime -v
Total uptime percentage for service Ping on host server.example.co.uk during period Today is 98.065%
$ sudo ./nagios-report.pl -h server.example.co.uk -s Ping -t Today -o uptime -v -d
Total uptime percentage for service Ping during period Today is 98.065%
$ sudo ./nagios-report.pl -h server.example.co.uk -s Ping -t Today -o downtime
0d 0h 27m 52s

nagios-report's People

Watchers

James Cloos avatar

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.