Benny,

OK, well, I hope I'm not embarrassing myself with this.  It's a perl script and 
uses Ton Voon's nifty Nagios::Plugins module.  I run checks against things I 
want to know about.  Thinking about it, I guess it would be nice to have the 
failed hosts/services check alert on percentage of failures.  Maybe someday.

Mark

-----Original Message-----
From: C. Bensend [mailto:be...@bennyvision.com] 
Sent: Saturday, October 23, 2010 8:44 PM
To: nagios-users@lists.sourceforge.net
Subject: Re: [Nagios-users] Scheduled checks falling far behind


> You can also run, if memory serves, the "nagiostats" command located in
> your Nagios "bin" directory to see this information as well.  I actually
> use that nagiostats data in a custom check and graph a lot of those
> latencies and other Nagios performance related info.

Boy, would I *love* to see your method for that!

I personally hacked the source of nagiostats to create a custom
plugin, but it's a horrible, horrible hack and I'd like to see
a cleaner, more scalable method.

Can you share?

Benny


-- 
"No matter how many shorts we have in the system, my guards will
be instructed to treat every surveillance camera malfunction as a
full-scale emergency."
                       -- Peter Anspach's Evil Overlord List, #67



------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null
#!/usr/bin/perl -w

# Nagios Plugin script to check several Nagios statistics

use strict;
use warnings;
use Nagios::Plugin;

use vars qw( $VERSION $PROGNAME $NAGIOS_BASE $NAGIOSSTATS
            $warning $critical
            %nagios_stats_data );
$VERSION = '0.32';

# the location of the Nagios installation root
$NAGIOS_BASE = '/usr/local/nagios';

# the command to run to get 'nagiostats'
$NAGIOSSTATS = $NAGIOS_BASE . '/bin/nagiostats';

# get the base name of this script for use in the examples
use File::Basename;
$PROGNAME = basename($0);

sub load_nagiostats;

sub do_cached_host_checks;
sub do_cached_service_checks;
sub do_command_buffers;
sub do_execution_time;
sub do_failed_hosts;
sub do_failed_services;
sub do_host_latency;
sub do_hosts_checked;
sub do_service_latency;
sub do_services_checked;

# Instantiate Nagios::Plugin object (the 'usage' parameter is mandatory)
my $p = Nagios::Plugin -> new (
    usage     => "Usage: %s [ --verbose | -v ] [ --debug | -d ]
                    [ --cached-host-checks    ] |
                    [ --cached-service-checks ] |
                    [ --command-buffers       ] |
                    [ --execution-time        ] |
                    [ --failed-hosts          ] |
                    [ --failed-services       ] |
                    [ --hosts-checked         ] |
                    [ --host-latency          ] |
                    [ --service-checked       ] |
                    [ --services-latency      ]",
    version => $VERSION,
    blurb => 'Nagios plugin to check various Nagios statistics.',
    extra     =>  "

THRESHOLDs are specified 'min:max' or 'min:' or ':max'
(or 'max'). If specified '\...@min:max', a warning status will be generated
if the count *is* inside the specified range."

);

# Define and document the valid command line options
# usage, help, version, timeout and verbose are defined by default.


$p -> add_arg(
    spec => 'cached-host-checks',
    help => 'Check that number of cached host checks matches the threshold.'
);

$p -> add_arg(
    spec => 'cached-service-checks',
    help => 'Check that number of cached service checks matches the threshold.'
);

$p -> add_arg(
    spec => 'command-buffers',
    help => 'Check that number of used command buffers matches the threshold.'
);

$p -> add_arg(
    spec => 'execution-time',
    help => 'Check the host and service execution times.'
);

$p -> add_arg(
    spec => 'failed-hosts',
    help => 'Check that number of failed hosts matches the threshold.'
);

$p -> add_arg(
    spec => 'failed-services',
    help => 'Check that number of failed services matches the threshold.'
);

$p -> add_arg(
    spec => 'host-latency',
    help => 'Check that average host latency is within the threshold.'
);

$p -> add_arg(
    spec => 'hosts-checked',
    help => 'Check that number of hosts checked matches the threshold.'
);

$p->add_arg(
    spec => 'services-checked',
    help => 'Check that number of services checked matches the threshold.'
);

$p -> add_arg(
    spec => 'service-latency',
    help => 'Check that average service latency is within the threshold.'
);

$p -> add_arg(
    spec     => 'debug|d',
    help     => 'Debug flag.'
);

$p -> add_arg(
    spec     => 'warning=s',
    help     => 'Warning threshold.'
);

$p -> add_arg(
    spec     => 'critical=s',
    help     => 'Critical threshold.',
    required => 1
);



# Parse arguments and process standard ones (e.g. usage, help, version)
$p -> getopts;

# perform sanity checking on command line options
unless ( defined ( $p -> opts -> critical ) ) {
        $p -> nagios_exit( UNKNOWN, "You must supply at least a critical 
parameter"
    );
}

$critical = $p -> opts -> critical;
if ( not defined ( $p -> opts -> warning ) ) {
    $warning = $critical;
}

# set the thresholds
$p -> set_thresholds( warning  => $warning,
                      critical => $critical );


unless (
         defined ( $p -> opts -> {'cached-host-checks'     } ) or
         defined ( $p -> opts -> {'cached-service-checks'  } ) or
         defined ( $p -> opts -> {'command-buffers'        } ) or
         defined ( $p -> opts -> {'execution-time'         } ) or
         defined ( $p -> opts -> {'failed-hosts'           } ) or
         defined ( $p -> opts -> {'failed-services'        } ) or
         defined ( $p -> opts -> {'host-latency'           } ) or
         defined ( $p -> opts -> {'hosts-checked'          } ) or
         defined ( $p -> opts -> {'service-latency'        } ) or
         defined ( $p -> opts -> {'services-checked'       } )
                                                                  ) {
        $p -> nagios_exit( UNKNOWN, "You must supply one of " .
                'cached-host-checks'      .
                'cached-service-checks'   .
                'command-buffers'         .
                'execution-time'          .
                'failed-hosts'            .
                'failed-services'         . 
                'host-latency'            .
                'hosts-checked'           .
                'service-latency'         . 
                'services-checked'
        );
}


##############################################################################
# check stuff.
load_nagiostats;


do_cached_host_checks     if defined ( $p -> opts -> { 'cached-host-checks'     
} );
do_cached_service_checks  if defined ( $p -> opts -> { 'cached-service-checks'  
} );
do_command_buffers        if defined ( $p -> opts -> { 'command-buffers'        
} );
do_execution_time         if defined ( $p -> opts -> { 'execution-time'         
} );
do_failed_hosts           if defined ( $p -> opts -> { 'failed-hosts'           
} );
do_failed_services        if defined ( $p -> opts -> { 'failed-services'        
} );
do_host_latency           if defined ( $p -> opts -> { 'host-latency'           
} );
do_hosts_checked          if defined ( $p -> opts -> { 'hosts-checked'          
} );
do_service_latency        if defined ( $p -> opts -> { 'service-latency'        
} );
do_services_checked       if defined ( $p -> opts -> { 'services-checked'       
} );



$p -> nagios_exit( UNKNOWN,  "none of activity/latencies/states defined!" );

##############################################################################
# check the result against the defined warning and critical thresholds,
# output the result and exit


sub load_nagiostats {
    open NS, "$NAGIOSSTATS |"
      or $p -> nagios_exit( UNKNOWN, "Could not run $NAGIOSSTATS: $!" );
        while ( my $line = <NS> ) {
            if ( $line =~ /^([\w\d\/\s]+):\s+(.*)$/ ) {
                $nagios_stats_data{ $1 } = $2;

                if ( $line =~ /^Active Host Checks/ ) {
                    # special case -- the next 5 lines are additional
                    # stats about active host checks
                    foreach my $count ( 1 .. 5 ) {
                        my $sub_line = <NS>;
                        $sub_line =~ /^   ([\w\-]+):\s+(.*)$/;
                        $nagios_stats_data{ 'Active Host Checks ' . $1 } = $2;
                    } # foreach

                } elsif ( $line =~ /^Active Service Checks/ ) {
                    # special case -- the next 3 lines are additional
                    # stats about active service checks
                    foreach my $count ( 1 .. 3 ) {
                        my $sub_line = <NS>;
                        $sub_line =~ /^   ([\w\-]+):\s+(.*)$/;
                        $nagios_stats_data{ 'Active Service Checks ' . $1 } = 
$2;
                    } # foreach
                }
            }
        }
    close NS;

    if ( defined ( $p -> opts -> debug ) ) {
        foreach my $key ( keys %nagios_stats_data ) {
            print '<' . $key . '> -> <' . $nagios_stats_data{ $key } . ">\n";
        }
    }
} # sub load_nagiostats







sub check_activity {
    # look at the following fields
    #  Services Checked:                       1149
    #  Services Scheduled:                     1149
    #  Services Actively Checked:              2663
    #  Services Passively Checked:             0
    #  Hosts Checked:                          177
    #  Hosts Scheduled:                        0
    #  Hosts Actively Checked:                 571
    #  Host Passively Checked:                 0
    # and determine if number of hosts or services checked is more than warning
    # or critical (kind of meaningless, but we do return perfdata...)

    if ( $nagios_stats_data{ 'Services Checked' } >= $critical ) {

        $p -> nagios_exit( CRITICAL, "Services checked " .
            "($nagios_stats_data{'Services Checked'}) above $critical" );

    } elsif ( $nagios_stats_data{ 'Serviced Checked' } >= $warning ) {

        $p -> nagios_exit( WARNING, "Services checked " .
            "($nagios_stats_data{'Services Checked'}) above $warning" );

    } elsif ( $nagios_stats_data{'Hosts Checked'} >= $critical ) {

        $p -> nagios_exit( CRITICAL, "Hosts checked " .
            "($nagios_stats_data{'Hosts Checked'}) above $critical" );

    } elsif ( $nagios_stats_data{'Hosts Checked'} >= $warning ) {
        $p -> nagios_exit( WARNING, "Hosts checked ($nagios_stats_data{'Hosts 
Checked'}) above $warning" );
    } else {
        $p->nagios_exit( OK, "No checks above thresholds" );
    }

} # sub check_activity








sub do_cached_host_checks {
    my $title = 'Nagios Cached Host Checks';
    my %host_data;

    $p -> shortname( $title );


    $nagios_stats_data{ 'Active Host Checks Scheduled'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s*$|;

    $host_data{ 'scheduled_last_1_min'     } = $1;
    $host_data{ 'scheduled_last_5_min'     } = $2;
    $host_data{ 'scheduled_last_15_min'    } = $3;


    $nagios_stats_data{ 'Active Host Checks On-demand'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s*$|;

    $host_data{ 'ondemand_last_1_min'      } = $1;
    $host_data{ 'ondemand_last_5_min'      } = $2;
    $host_data{ 'ondemand_last_15_min'     } = $3;


    $nagios_stats_data{ 'Active Host Checks Parallel'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s*$|;

    $host_data{ 'parallel_last_1_min'     } = $1;
    $host_data{ 'parallel_last_5_min'     } = $2;
    $host_data{ 'parallel_last_15_min'    } = $3;


    $nagios_stats_data{ 'Active Host Checks Serial'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s*$|;

    $host_data{ 'serial_last_1_min'       } = $1;
    $host_data{ 'serial_last_5_min'       } = $2;
    $host_data{ 'serial_last_15_min'      } = $3;


    $nagios_stats_data{ 'Active Host Checks Cached'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s*$|;

    $host_data{ 'cached_last_1_min'       } = $1;
    $host_data{ 'cached_last_5_min'       } = $2;
    $host_data{ 'cached_last_15_min'      } = $3;


    $p -> shortname( $title );

    $p -> add_perfdata(
            label     => 'scheduled_last_1_min',
            value     => $host_data{ 'scheduled_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'scheduled_last_5_min',
            value     => $host_data{ 'scheduled_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'scheduled_last_15_min',
            value     => $host_data{ 'scheduled_last_15_min' },
    );

    $p -> add_perfdata(
            label     => 'ondemand_last_1_min',
            value     => $host_data{ 'ondemand_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'ondemand_last_5_min',
            value     => $host_data{ 'ondemand_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'ondemand_last_15_min',
            value     => $host_data{ 'ondemand_last_15_min' },
    );

    $p -> add_perfdata(
            label     => 'parallel_last_1_min',
            value     => $host_data{ 'parallel_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'parallel_last_5_min',
            value     => $host_data{ 'parallel_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'parallel_last_15_min',
            value     => $host_data{ 'parallel_last_15_min' },
    );

    $p -> add_perfdata(
            label     => 'serial_last_1_min',
            value     => $host_data{ 'serial_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'serial_last_5_min',
            value     => $host_data{ 'serial_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'serial_last_15_min',
            value     => $host_data{ 'serial_last_15_min' },
    );

    $p -> add_perfdata(
            label     => 'cached_last_1_min',
            value     => $host_data{ 'cached_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'cached_last_5_min',
            value     => $host_data{ 'cached_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'cached_last_15_min',
            value     => $host_data{ 'cached_last_15_min' },
    );



    # there really is no error threshold for this, we just want to graph it
    $p -> nagios_exit(
        return_code => OK,
        message => ' Active host checks cached last 1/5/15 min ('           .
            $host_data{ 'cached_last_1_min'  } . '/' .
            $host_data{ 'cached_last_5_min'  } . '/' .
            $host_data{ 'cached_last_15_min' } . ')  '
    );

} # sub do_cached_host_checks



sub do_cached_service_checks {

    my %service_data;
    my $title = 'Nagios Cached Service Checks';

    $nagios_stats_data{ 'Active Service Checks Scheduled'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s*$|;

    $service_data{ 'scheduled_last_1_min'     } = $1;
    $service_data{ 'scheduled_last_5_min'     } = $2;
    $service_data{ 'scheduled_last_15_min'    } = $3;


    $nagios_stats_data{ 'Active Service Checks On-demand'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s+$|;

    $service_data{ 'ondemand_last_1_min'      } = $1;
    $service_data{ 'ondemand_last_5_min'      } = $2;
    $service_data{ 'ondemand_last_15_min'     } = $3;


    $nagios_stats_data{ 'Active Service Checks Cached'         }
      =~ m|([\d\.]+)\s*/\s*([\d\.]+)\s*/\s*([\d\.]+)\s*$|;

    $service_data{ 'cached_last_1_min'        } = $1;
    $service_data{ 'cached_last_5_min'        } = $2;
    $service_data{ 'cached_last_15_min'       } = $3;


    $p -> shortname( $title );

    $p -> add_perfdata(
            label     => 'scheduled_last_1_min',
            value     => $service_data{ 'scheduled_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'scheduled_last_5_min',
            value     => $service_data{ 'scheduled_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'scheduled_last_15_min',
            value     => $service_data{ 'scheduled_last_15_min' },
    );

    $p -> add_perfdata(
            label     => 'ondemand_last_1_min',
            value     => $service_data{ 'ondemand_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'ondemand_last_5_min',
            value     => $service_data{ 'ondemand_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'ondemand_last_15_min',
            value     => $service_data{ 'ondemand_last_15_min' },
    );

    $p -> add_perfdata(
            label     => 'cached_last_1_min',
            value     => $service_data{ 'cached_last_1_min' },
    );

    $p -> add_perfdata(
            label     => 'cached_last_5_min',
            value     => $service_data{ 'cached_last_5_min' },
    );

    $p -> add_perfdata(
            label     => 'cached_last_15_min',
            value     => $service_data{ 'cached_last_15_min' },
    );

    # there really is no error threshold for this, we just want to graph it
    $p -> nagios_exit(
        return_code => OK,
        message => ' Active service checks cached last 1/5/15 min ('           .
            $service_data{ 'cached_last_1_min'  } . '/' .
            $service_data{ 'cached_last_5_min'  } . '/' .
            $service_data{ 'cached_last_15_min' } . ')  '
    );

} # sub do_cached_service_checks




sub do_command_buffers {

    my $title =  'Nagios Command Buffers';

    $nagios_stats_data{ 'Used/High/Total Command Buffers' }
      =~ m|(\d+)\s+/\s+(\d+)\s+/\s+(\d+)$|;

    $nagios_stats_data{ 'Command Buffers Used'  }  = $1;
    $nagios_stats_data{ 'Command Buffers High'  }  = $2;
    $nagios_stats_data{ 'Command Buffers Total' }  = $3;

    $p -> shortname( $title );

    $p -> add_perfdata(
            label => 'Nagios Command Buffers Used',
            value => $nagios_stats_data{ 'Command Buffers Used' },
            threshold => $p -> threshold
    );

    $p -> add_perfdata(
            label => 'Nagios Command Buffers High',
            value => $nagios_stats_data{ 'Command Buffers High' }
    );

    $p -> add_perfdata(
            label => 'Nagios Command Buffers Total',
            value => $nagios_stats_data{ 'Command Buffers Total' }
    );

    $p -> nagios_exit(
        return_code => $p -> check_threshold(
                            check => $nagios_stats_data{ 'Command Buffers Used' 
}
                        ),
        message => ' Command buffers used/high/total ('                    .
                        $nagios_stats_data{ 'Command Buffers Used' } . '/' .
                        $nagios_stats_data{ 'Command Buffers High' } . '/' .
                        $nagios_stats_data{ 'Command Buffers Total' } . ')  '
    );

} # sub do_command_buffers






sub do_execution_time {

    my $title = 'Nagios Check Execution Times';

    $nagios_stats_data{ 'Active Service Execution Time'  }
      =~ m|([\d\.]+)\s+/\s+([\d\.]+)\s+/\s+([\d\.]+)\s+sec$|;

    $nagios_stats_data{ 'Min Service Execution Time'     } = $1;
    $nagios_stats_data{ 'Max Service Execution Time'     } = $2;
    $nagios_stats_data{ 'Average Service Execution Time' } = $3;

    $nagios_stats_data{ 'Active Host Execution Time'     }
      =~ m|([\d\.]+)\s+/\s+([\d\.]+)\s+/\s+([\d\.]+)\s+sec$|;

    $nagios_stats_data{ 'Min Host Execution Time'        } = $1;
    $nagios_stats_data{ 'Max Host Execution Time'        } = $2;
    $nagios_stats_data{ 'Average Host Execution Time'    } = $3;

    $p -> shortname( $title );

    $p -> add_perfdata(
        label     => 'Nagios Max Host Execution Time',
        value     => $nagios_stats_data{ 'Max Host Execution Time' }
    );

    $p -> add_perfdata(
        label     => 'Nagios Host Execution Time',
        value     => $nagios_stats_data{ 'Average Host Execution Time' },
        threshold => $p -> threshold
    );

    $p -> add_perfdata(
        label     => 'Nagios Min Host Execution Time',
        value     => $nagios_stats_data{ 'Min Host Execution Time' }
    );

    $p -> add_perfdata(
        label     => 'Nagios Max Service Execution Time',
        value     => $nagios_stats_data{ 'Max Service Execution Time' }
    );

    $p -> add_perfdata(
        label     => 'Nagios Average Service Execution Time',
        value     => $nagios_stats_data{ 'Average Service Execution Time' },
        threshold => $p -> threshold
    );

    $p -> add_perfdata(
        label     => 'Nagios Min Service Execution Time',
        value     => $nagios_stats_data{ 'Min Service Execution Time' }
    );


    $p -> nagios_exit(
        return_code => $p -> check_threshold(
                            check => $nagios_stats_data{ 'Average Service 
Execution Time'}
                       ),
        message     => ' Service Execution Time min/max/avg ('                  
     .
                        $nagios_stats_data{ 'Min Service Execution Time'     } 
. '/' .
                        $nagios_stats_data{ 'Max Service Execution Time'     } 
. '/' .
                        $nagios_stats_data{ 'Average Service Execution Time' } 
. ')  '
    );

} # sub do_execution_time







sub do_failed_hosts {

    my $title = 'Nagios Failed Hosts';

    $nagios_stats_data{ 'Hosts Up/Down/Unreach' }
      =~ m|(\d+)\s+/\s+(\d+)\s+/\s+(\d+)$|;

    $nagios_stats_data{ 'Hosts Up'              } = $1;
    $nagios_stats_data{ 'Hosts Down'            } = $2;
    $nagios_stats_data{ 'Hosts Unreachable'     } = $3;


    $p -> shortname( $title );

    my $total_not_ok = (
                            $nagios_stats_data{ 'Hosts Down'        } +
                            $nagios_stats_data{ 'Hosts Unreachable' } ) -
                            $nagios_stats_data{ 'Hosts In Downtime' };

    $p -> add_perfdata(
            label     => 'Nagios Hosts Not OK',
            value     => $total_not_ok,
            threshold => $p -> threshold
    );

    $p -> add_perfdata(
            label    => 'Nagios Hosts Up',
            value    => $nagios_stats_data{ 'Hosts Up' }
    );

    $p -> add_perfdata(
            label    => 'Nagios Hosts Down',
            value    => $nagios_stats_data{ 'Hosts Down' }
    );

    $p -> add_perfdata(
            label    => 'Nagios Hosts Unreachable',
            value    => $nagios_stats_data{ 'Hosts Unreachable' }
    );

    $p -> add_perfdata(
            label    => 'Nagios Hosts In Downtime',
            value    => $nagios_stats_data{ 'Hosts In Downtime' }
    );

    $p -> add_perfdata(
            label    => 'Nagios Hosts Flapping',
            value    => $nagios_stats_data{ 'Hosts Flapping' }
    );

    $p->nagios_exit(
        return_code => $p -> check_threshold(
                            check => $total_not_ok
                        ),
        message => " Hosts not in OK state is $total_not_ok "
    );

} # sub do_failed_hosts


sub do_hosts_checked {

    my $title = 'Nagios Hosts Checked';

    $p -> shortname( $title );

    $p -> add_perfdata(
            label => 'Nagios Hosts Checked',
            value => $nagios_stats_data{ 'Hosts Checked' }
    );

    $p -> add_perfdata(
            label => 'Nagios Hosts Actively Checked',
            value => $nagios_stats_data{ 'Hosts Actively Checked' }
    );

    $p -> add_perfdata(
            label => 'Nagios Hosts Passively Checked',
            value => $nagios_stats_data{ 'Host Passively Checked' }
    );

    $p -> add_perfdata(
            label => 'Nagios Hosts Scheduled',
            value => $nagios_stats_data{ 'Hosts Scheduled' }
    );

    $p -> nagios_exit(
        return_code => $p -> check_threshold(
                            check => $nagios_stats_data{ 'Hosts Checked' }
                        ),
        message => " Hosts checked $nagios_stats_data{'Hosts Checked'}"
    );

} # sub do_hosts_checked





sub do_failed_services {

    my $title = 'Nagios Failed Services';

    $nagios_stats_data{ 'Services Ok/Warn/Unk/Crit' }
      =~ m|(\d+)\s+/\s+(\d+)\s+/\s+(\d+)\s+/\s+(\d+)$|;

    $nagios_stats_data{ 'Services OK'               } = $1;
    $nagios_stats_data{ 'Services Warning'          } = $2;
    $nagios_stats_data{ 'Services Unknown'          } = $3;
    $nagios_stats_data{ 'Services Critical'         } = $4;

    $p -> shortname( $title );

    my $total_not_ok = (
                        $nagios_stats_data{ 'Services Warning'     } +
                        $nagios_stats_data{ 'Services Critical'    } +
                        $nagios_stats_data{ 'Services Unknown'     } ) -
                        $nagios_stats_data{ 'Services In Downtime' };

    $p -> add_perfdata(
            label     => 'Nagios Services Not OK',
            value     => $total_not_ok,
            threshold => $p -> threshold
    );

    $p -> add_perfdata(
            label => 'Nagios Services OK',
            value => $nagios_stats_data{ 'Services OK' }
    );

    $p -> add_perfdata(
            label => 'Nagios Services Unknown',
            value => $nagios_stats_data{ 'Services Unknown' }
    );

    $p -> add_perfdata(
            label => 'Nagios Services Warning',
            value => $nagios_stats_data{ 'Services Warning' }
    );

    $p -> add_perfdata(
            label => 'Nagios Services Critical',
            value => $nagios_stats_data{ 'Services Critical' }
    );

    $p -> add_perfdata(
            label => 'Nagios Services In Downtime',
            value => $nagios_stats_data{ 'Services In Downtime' }
    );

    $p -> add_perfdata(
            label => 'Nagios Flapping Services',
            value => $nagios_stats_data{ 'Services Flapping' }
    );

    $p -> nagios_exit(
        return_code => $p -> check_threshold(
                            check => $total_not_ok
                        ),
        message => " Services not in OK state is $total_not_ok "
    );

} # sub do_failed_services




sub do_host_latency {

    my $title = 'Nagios Host Latency';

    $nagios_stats_data{ 'Active Host Latency'         }
      =~ m|([\d\.]+)\s+/\s+([\d\.]+)\s+/\s+([\d\.]+)\s+sec$|;

    $nagios_stats_data{ 'Min Active Host Latency'     } = $1;
    $nagios_stats_data{ 'Max Active Host Latency'     } = $2;
    $nagios_stats_data{ 'Average Active Host Latency' } = $3;


    $p -> shortname( $title );

    $p -> add_perfdata(
            label     => 'Nagios Average Host Latency',
            value     => $nagios_stats_data{'Average Active Host Latency'},
            threshold => $p -> threshold
    );

    $p -> add_perfdata(
            label => 'Nagios Max Host Latency',
            value => $nagios_stats_data{'Max Active Host Latency'}
    );

    $p->add_perfdata(
            label => 'Nagios Min Host Latency',
            value => $nagios_stats_data{'Min Active Host Latency'}
    );

    $p -> nagios_exit(
        return_code => $p -> check_threshold(
                            check => $nagios_stats_data{ 'Average Active Host 
Latency' }
                        ),
        message => ' Active host latency min/max/avg ('           .
            $nagios_stats_data{ 'Min Active Host Latency' } . '/' .
            $nagios_stats_data{ 'Max Active Host Latency' } . '/' .
            $nagios_stats_data{ 'Average Active Host Latency' } . ')  '
    );

} # sub do_host_latency



sub do_service_latency {

    my $title = 'Nagios Service Latency';


    $nagios_stats_data{ 'Active Service Latency'         }
      =~ m|([\d\.]+)\s+/\s+([\d\.]+)\s+/\s+([\d\.]+)\s+sec$|;

    $nagios_stats_data{ 'Min Active Service Latency'     } = $1;
    $nagios_stats_data{ 'Max Active Service Latency'     } = $2;
    $nagios_stats_data{ 'Average Active Service Latency' } = $3;


    $p -> shortname( $title );

    $p -> add_perfdata(
            label     => 'Nagios Average Service Latency',
            value     => $nagios_stats_data{'Average Active Service Latency'},
            threshold => $p -> threshold
    );

    $p -> add_perfdata(
            label => 'Nagios Max Service Latency',
            value => $nagios_stats_data{'Max Active Service Latency'}
    );

    $p->add_perfdata(
            label => 'Nagios Min Service Latency',
            value => $nagios_stats_data{'Min Active Service Latency'}
    );

    $p -> nagios_exit(
        return_code => $p -> check_threshold(
                            check => $nagios_stats_data{'Average Active Service 
Latency'}
                        ),
        message => ' Active service latency min/max/avg ('           .
            $nagios_stats_data{ 'Min Active Service Latency' } . '/' .
            $nagios_stats_data{ 'Max Active Service Latency' } . '/' .
            $nagios_stats_data{ 'Average Active Service Latency' } . ')  '
    );

} # sub do_service_latency



sub do_services_checked {

    my $title = 'Nagios Services Checked';

    $p -> shortname( $title );

    $p -> add_perfdata(
            label     => 'Nagios Services Checked',
            value     => $nagios_stats_data{ 'Services Checked' },
            threshold => $p -> threshold
    );

    $p -> add_perfdata(
            label     => 'Nagios Services Actively Checked',
            value     => $nagios_stats_data{ 'Services Actively Checked' }
    );

    $p -> add_perfdata(
            label    => 'Nagios Services Passively Checked',
            value    => $nagios_stats_data{ 'Services Passively Checked' }
    );

    $p -> add_perfdata(
            label    => 'Nagios Services Scheduled',
            value    => $nagios_stats_data{ 'Services Scheduled' }
    );

    $p -> nagios_exit(
        return_code => $p -> check_threshold(
                            check => $nagios_stats_data{ 'Services Checked' }
                        ),
        message => " Hosts checked $nagios_stats_data{'Services Checked'}"
    );

} # sub do_services_checked


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Nagios-users mailing list
Nagios-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to