Home: Perl Programming Help: Advanced:
How to print out Nagios Service UP Time Percentage from Nagios-Report Perl Module



kunus
New User

Jan 17, 2013, 12:35 AM


Views: 6604
How to print out Nagios Service UP Time Percentage from Nagios-Report Perl Module

Hello,

According to this module:
http://search.cpan.org/~hopcrofts/Nagios-Report-0.003/

This will produce Service UP Time Report, but How can I only retrieve UP Time percentage value instead of full report?

Thanks.

Code
#!/usr/bin/perl 
use strict ;

use Nagios::Report ;

my $x = Nagios::Report->new(
# Data source
q<local_cgi localhost nagiosadmin>,
# Report period
[ qw(24x7) ],
# Time period
'last7days',
# Service report
1,
# Pre-filter
sub { my %F = @_; my $u = $F{PERCENT_TOTAL_TIME_OK}; $u =~ s/%//; $u < 100 }
)
or die "Can't construct Nagios::Report object." ;

$x->mkreport(
[
qw(
HOST_NAME
PERCENT_TOTAL_TIME_OK
DOWN
UP
OUTAGE
)
],

sub { my %F = @_; my $u = $F{PERCENT_TOTAL_TIME_OK}; $u =~ s/%//; $u < 100 },

undef,

undef,

1,

) ;

$x->debug_dump() ;



wickedxter
User

Jan 25, 2013, 2:13 PM


Views: 6404
Re: [kunus] How to print out Nagios Service UP Time Percentage from Nagios-Report Perl Module

change your array of headers to only UP ... the module says it will return only the headers you supply in the array..