Hello,

Using NRPE 2.12 and have an issue with a variable from a perl script not
being printed.

The script works fine when executed manually using the 'nagios' user which
NRPE is running as:

sh-2.05a$ /usr/local/nagios/libexec/check_apache

OK - 68 requests being processed.


However, via NRPE:

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_apache

OK -  requests being processed.


Below is the script.  I've tried many different code variations, but end
result is the same.  I appreciate any insight as to what the issue could
be.  Thanks!

------



#!/usr/bin/perl

 $OK       = 0;
 $WARNING  = 1;
 $CRITICAL = 2;

 $status       = $OK;
 $returnstring = "";

 ($apache_tool, @lines, $tot_req);

 $apache_tool = "/usr/local/apache/sbin/apachectl status";

@lines = `$apache_tool`;

foreach (@lines)
{
    if ($_ =~ /requests currently being processed/)
    {
        $tot_req = (split(" ", $_))[0];
        last;
    }
}

if ($tot_req < 350)
{
    $status = $OK;
}
elsif ($tot_req >= 350 && $tot_req < 450)
{
     $status = $WARNING;

}
elsif ($tot_req > 450)
{

     $status = $CRITICAL;
}

if ($status == $OK)
{
    $returnstring = "$tot_req requests being processed.\n";

    print "OK - $returnstring\n";
}

elsif ($status == $WARNING)
{
    $returnstring = "$tot_req requests being processed.\n";

    print "WARNING - $returnstring\n";
}

elsif ($status == $CRITICAL)

{
    $returnstring = "$tot_req request being processed.\n";

    print "CRITICAL - $returnstring\n";
}
exit $status;
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Nagios-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting 
any issue. 
::: Messages without supporting info will risk being sent to /dev/null

Reply via email to