How to print the time fraction of Nagios Service UP from the Nagl-Report Perl module

I can print the host percentage of time from the Nagios-Report Perl module with the following code:

#!/usr/bin/perl use strict ; use Nagios::Report ; my $x = Nagios::Report->new(q<local_cgi localhost nagiosadmin>) or die "Can't construct Nagios::Report object." ; $x->mkreport( [ qw(HOST_NAME PERCENT_TOTAL_TIME_UP) ], sub { my %F = @_; my $u = $F{PERCENT_TOTAL_TIME_UP}; $u =~ s/%//; }, 0, sub { my $F = shift @_ ; } ) ; $x->debug_dump ; 

But how can I print the UP Time Percentage Service ? I mean only the output of the percentage value.

I tried many options, but could not understand.

+6
source share
1 answer

This will result in a Service UP Time Report, but how can I get only a percentage of UP Time instead of a full report?

 #!/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() ; 
+2
source

All Articles