Trying to develop a new perl plugin

Nibin VM nibin.vm at piserve.com
Mon Jan 24 16:16:51 CET 2011


Thanks for your reply folks.. :)

Finally I have concluded that the portion which reads the argument has
issues.

$host=$ARGV[0];

It isn't taken correctly when its executed from nagios. Please somebody tell
me what code should I put if I need to specify the host name like
./test.pl-H "hostname"?

On Sun, Jan 23, 2011 at 10:44 PM, Boyer, Timothy A.
<Timothy.Boyer at opm.gov>wrote:

> Permissions problem?  You're running the command line as root; try running
> the command line as your Nagios username.
> ________________________________________
> From: Nibin VM [nibin.vm at piserve.com]
> Sent: Sunday, January 23, 2011 10:46 AM
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Trying to develop a new perl plugin
>
> 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<http://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.
>
>
>
>
>
> ------------------------------------------------------------------------------
> 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
> _______________________________________________
> 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
>



-- 
Regards,
Nibin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20110124/a085ef85/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