Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9115007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:19:46+00:00 2026-06-17T04:19:46+00:00

I can print out Host UP Time percentage from Nagios-Report Perl Module with following

  • 0

I can print out Host UP Time percentage from Nagios-Report Perl Module with 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 only print out Service UP Time Percentage? I mean only output the percentage value.

I tried many options but couldn’t get it right.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:19:47+00:00Added an answer on June 17, 2026 at 4:19 am

    This will produce Service UP Time Report, but How can I only retrieve UP Time percentage value instead of 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() ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code prints out 10 . How can I make it print out
I can print out a date nicely based on the user's locale. But how
Still learning magento coding. I wonder is there a way I can print out
I'm trying to iterate through all nodes, so I can print them out for
Assume I have char **argv . First, how can I print out all the
How to print out the zombie's name and graveyard Can you concatenate this without
I have two csv file ( ) I can get it to print out
Can I do it with System.out.print ?
How can I utilize System.out.print(ln/f) in a way that will allow me to format
Simple problem that I can't figure out... How can I print a '%' character

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.