Trouble with a simple plug-in I wrote ...

Novick, Jeff novickj at toysrus.com
Tue Mar 2 17:57:45 CET 2004


Hi, All,
Ok, my fault. Net::RSH needs to be run as root.
Changed the script to shell out and run rsh and all is well.
Thanks!
Jeff
P.S.
Script now looks like this:

#!/usr/bin/perl -w
use POSIX;
use strict;
use lib "/usr/local/nagios/libexec";
use utils qw($TIMEOUT %ERRORS &print_revision &support);

my $host = $ARGV[0];
my $command = "rsh -l netsaint " . $host  . "
\"/usr/local/netsaint/libexec/check_netsaint
/usr/local/netsaint/var/status.log 5 '/usr/local/netsaint/bin/netsaint'\"";
my $rshresults = "";
my $x = 0;
my $i = "";

if (!defined($host)) {
	print "No host specified!\n";
	exit $ERRORS{'UNKNOWN'};
}

$SIG{ALRM} = sub { die "timeout" };

eval {
	alarm(60); # time out after 60 seconds per command.
	$rshresults = `$command`;
	alarm(0);
};

if ($@) {
	if ($@ =~ /timeout/) {
		print "check_netsaint_2.pl: " . $host . " timed out during
rsh operation. $rshresults.\n";
		exit $ERRORS{'UNKNOWN'};
	}
} else {
	if ($rshresults =~ /Error/) {
		print "$rshresults\n";
		exit $ERRORS{'CRITICAL'};
	} else {
		print "$rshresults\n";
		exit $ERRORS{'OK'};
	}
}

print "should have never made it to here.\n";
exit $ERRORS{'UNKNOWN'};

-----Original Message-----
From: Marc Powell [mailto:marc at ena.com] 
Sent: Tuesday, March 02, 2004 10:26 AM
To: Novick, Jeff; nagios-users at lists.sourceforge.net
Subject: RE: [Nagios-users] Trouble with a simple plug-in I wrote ...


On Tuesday, March 02, 2004 7:08 AM, Novick, Jeff shared with us:

> Hi,
> I wrote a plug-in, although not complete to plug-in specs, I believe
> it should be working as it works from the command line. The problem
> is that it always exits with an unknown status, which is in the last
> two lines in the script, whenever it is executed from within nagios. 
> 
> I have build my first nagios (1.2) server but still have some legacy
> netsaint boxes running and would like to check that the netsaint
> process is still running. I also thought this would be a good test
> for writing a plug-in.   
> 
> The debug file from the scripts contains the following when run from
> the command line: --------------------------
> HOST: pingsaint1.tru.com
> COMMAND: /usr/local/netsaint/libexec/check_netsaint
> /usr/local/netsaint/var/status.log 5
> '/usr/local/netsaint/bin/netsaint' 
> ERRORS:
> RSH RESULTS:
>  NetSaint ok: located 7 processes, status log updated 2 seconds ago
> 
> --------------------------
> 
> and when executed from within NagIOS
> 
> --------------------------
> HOST: pingsaint1.tru.com
> COMMAND: /usr/local/netsaint/libexec/check_netsaint
> /usr/local/netsaint/var/status.log 5
> '/usr/local/netsaint/bin/netsaint' 
> ERRORS:
>  at /usr/local/nagios/libexec/check_netsaint.pl line 24 RSH RESULTS:


What's happening on or about line 24 of your script? Could it be that
whatever is being done there can not be done as the nagios user? More
importantly, does your script print a line to standard out and exit with
the proper exit code for Nagios to determine the status? There is
documentation on http://nagiosplug.sourceforge.net on how to properly
exit and/or you could look at an existing plugin.

--
Marc




-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
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

======================================================================== 
This email message is for the sole use of the intended recipient (s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message. To reply to our email administrator directly, send
an email to EmailAdmin at toysrus.com. 
Toys "R" Us, Inc.


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
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