
January 17th, 2013, 02:41 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 2 m 43 sec
Reputation Power: 0
|
|
|
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/
Following code 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() ;
|