#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    1
    Rep 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() ;
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Location
    Paris area, France
    Posts
    843
    Rep Power
    496
    I don't know this module, but you might just filter out what you don't need in the report.

IMN logo majestic logo threadwatch logo seochat tools logo