Hello guys,<br><br>I am trying to write some nagios perl plugin to monitor some services I'm responsible for. Initially I tried to write custom plugin to monitor mail queue using the following script.<br><br>===========<br>
#!/usr/bin/perl -w<br><br>use strict;<br>use Net::SNMP;<br>use Getopt::Long;<br><br>use lib "/usr/lib64/nagios/libexec";<br>my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3);<br>
my $host = undef;<br>my $result = undef;<br>my @array = undef;<br><br>$host=$ARGV[0];<br>$result=`/usr/lib64/nagios/plugins/check_snmp -H $host -C "community" -o extOutput.1`;<br><br>@array = split(/\ /, $result);<br>
chomp($array[3]);<br><br>if ( $array[3] le "19999" )<br>{<br> print "OK: current emails queue is $array[3]\n";<br> exit $ERRORS{"OK"};<br>}<br><br>elsif ( $array[3] ge "20000" && $array[3] le "29999" )<br>
{<br> print "Warning: current emails queue is $array[3]\n";<br> exit $ERRORS{"WARNING"};<br>}<br><br>elsif ( $array[3] ge "30000" )<br>{<br> print "Critical: current emails queue is $array[3]\n";<br>
exit $ERRORS{"CRITICAL"};<br>}<br><br>else<br>{<br> print "Unknown";<br> exit $ERRORS{"UNKNOWN"};<br>}<br clear="all">================<br><br>As you can see, I use snmp to pull mail queue from the remote server. When I try the command from command line it work fine.<br>
<br>]# ./<a href="http://test.pl">test.pl</a> "server name"<br>OK: current emails queue is 264<br><br>But from the nagios from end it shows as critical and it shows "Critical: current emails queue is Unknown" error :(<br>
<br>Please somebody help me to sort this out. Obviously its the first perl script that I ever wrote and I really interested to write more plugins in perl(I am in love with perl now :) ).<br><br>Thanks in advance!<br><br>
-- <br>Regards,<br>Nibin.<br><br><br><div style="display: inline;"></div><br>