Hello,<br><br>Using NRPE 2.12 and have an issue with a variable from a perl script not being printed.<br><br>The script works fine when executed manually using the 'nagios' user which NRPE is running as:<br><br>sh-2.05a$ /usr/local/nagios/libexec/check_apache<br>
<br>OK - 68 requests being processed.<br><br><br>However, via NRPE:<br><br>/usr/local/nagios/libexec/check_nrpe -H localhost -c check_apache<br> <br>OK - requests being processed.<br><br><br>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!<br>
<br>------<br><br><br><br>#!/usr/bin/perl<br> <br> $OK = 0;<br> $WARNING = 1;<br> $CRITICAL = 2;<br> <br> $status = $OK;<br> $returnstring = "";<br> <br> ($apache_tool, @lines, $tot_req);<br> <br> $apache_tool = "/usr/local/apache/sbin/apachectl status";<br>
<br>@lines = `$apache_tool`;<br> <br>foreach (@lines)<br>{<br> if ($_ =~ /requests currently being processed/)<br> {<br> $tot_req = (split(" ", $_))[0];<br> last;<br> }<br>}<br> <br>if ($tot_req < 350)<br>
{<br> $status = $OK;<br>}<br>elsif ($tot_req >= 350 && $tot_req < 450)<br>{<br> $status = $WARNING;<br> <br>}<br>elsif ($tot_req > 450)<br>{<br> <br> $status = $CRITICAL;<br>}<br> <br>if ($status == $OK)<br>
{<br> $returnstring = "$tot_req requests being processed.\n";<br> <br> print "OK - $returnstring\n";<br>}<br> <br>elsif ($status == $WARNING)<br>{<br> $returnstring = "$tot_req requests being processed.\n";<br>
<br> print "WARNING - $returnstring\n";<br>}<br> <br>elsif ($status == $CRITICAL)<br> <br>{<br> $returnstring = "$tot_req request being processed.\n";<br> <br> print "CRITICAL - $returnstring\n";<br>
}<br>exit $status;<br>