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

Novick, Jeff novickj at toysrus.com
Tue Mar 2 16:45:05 CET 2004


Hi, Marc,
	I attached the script to my  original email, I guess you didn't
receive it. I'll paste it at the end of this.
Basically, I am just executing an rsh command via Net::Rsh.
Line 24 is @rshresults = $rshell->rsh($host, "root", "netsaint", $command);
By the way, I am not using embedded perl. I probably should have stated that
in my original email.

Thank you,
Jeff

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

my $rshell = Net::Rsh->new();
my $host = $ARGV[0];
my $command = "/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 = $rshell->rsh($host, "root", "netsaint", $command);
#this is line 24
	alarm(0);
};

open (RSHLOG, ">>/usr/local/nagios/libexec/RSH.LOG.TEXT");
	print RSHLOG "--------------------------\n";
	print RSHLOG "HOST: " . $host . "\n";
	print RSHLOG "COMMAND: " . $command . "\n";
	print RSHLOG "ERRORS:\n";
	foreach $i ($@) {
		print RSHLOG $i;
	}
	print RSHLOG "RSH RESULTS:\n";
	print RSHLOG "$rshresults[0]\n";
	print RSHLOG "--------------------------\n";
close RSHLOG;

if ($@) {
	if ($@ =~ /timeout/) {
		print "check_netsaint.pl: " . $host . " timed out during rsh
operation. $rshresults[0].\n";
		exit $ERRORS{'UNKNOWN'};
	}
} else {
	if ($rshresults[0] =~ /Error/) {
		print "$rshresults[0]\n";
		exit $ERRORS{'CRITICAL'};
	} else {
		print "$rshresults[0]\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


======================================================================== 
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