Trying to develop a new perl plugin

Nibin VM nibin.vm at piserve.com
Sun Jan 23 16:46:03 CET 2011


Hello guys,

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.

===========
#!/usr/bin/perl -w

use strict;
use Net::SNMP;
use Getopt::Long;

use lib "/usr/lib64/nagios/libexec";
my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3);
my $host = undef;
my $result = undef;
my @array = undef;

$host=$ARGV[0];
$result=`/usr/lib64/nagios/plugins/check_snmp -H $host -C "community" -o
extOutput.1`;

@array = split(/\ /, $result);
chomp($array[3]);

if ( $array[3] le "19999" )
{
 print "OK: current emails queue is $array[3]\n";
 exit $ERRORS{"OK"};
}

elsif ( $array[3] ge "20000"  &&  $array[3] le "29999" )
{
 print "Warning: current emails queue is $array[3]\n";
 exit $ERRORS{"WARNING"};
}

elsif ( $array[3] ge "30000" )
{
 print "Critical: current emails queue is $array[3]\n";
 exit $ERRORS{"CRITICAL"};
}

else
{
 print "Unknown";
 exit $ERRORS{"UNKNOWN"};
}
================

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.

]# ./test.pl "server name"
OK: current emails queue is 264

But from the nagios from end it shows as critical and it shows "Critical:
current emails queue is Unknown" error :(

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 :) ).

Thanks in advance!

-- 
Regards,
Nibin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20110123/d68690f6/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
-------------- next part --------------
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
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


More information about the Users mailing list