View previous topic :: View next topic |
Author |
Message |
brent_weaver Guru
Joined: 01 Jul 2004 Posts: 510 Location: Burlington, VT
|
Posted: Thu May 21, 2009 7:39 pm Post subject: nagios plugin execution and my confusion |
|
|
Hello. I am fairly new to nagios and am confused as to why a plugin work interactively, but when run by nagios I get an error.
Here is the script:
Code: |
#!/usr/bin/perl
# Deps: This script assuming ssh public key authentication has been setup between this server and the remote node
# nagios: +epn
use strict;
use warnings;
use Getopt::Long;
use vars qw( $CMD $OBJ $HOST $USER $WARN $CRIT $CUR @TEMP $OPTS $EXIT );
use Net::SSH qw(sshopen2);
use Net::Ping;
$OPTS = GetOptions ( "W=i" => \$WARN,
"C=i" => \$CRIT,
"H=s" => \$HOST,
"U=s" => \$USER);
unless ( ($WARN) && ($CRIT) && ($HOST) && ($USER) ) {
print "USAGE: $0 -H <HOSTNAME> -U <USERNAME> -W <WARNING> -C <CRITICAL>\n";
exit(3);
}
sshopen2("$USER\@$HOST", *READER, *WRITER, "sar", "2", "2", "|tail","-1","|awk","'{print \$5}'") || die "SSH cmd execution error: $!\n";
@TEMP = (<READER>);
close READER;
close WRITER;
chomp($TEMP[0]);
$CUR = 0;
$CUR = 100 - $TEMP[0];
$EXIT = 3;
$EXIT = 0 if ( $CUR < $WARN );
$EXIT = 1 if ( ( $CUR >= $WARN ) && ( $CUR < $CRIT ) );
$EXIT = 2 if ( $CUR >= $CRIT );
print "CPU Utilization is $CUR%.\n";
exit($EXIT);
|
I get the following when run as nagios user in shell:
Code: |
./cpu_stat -H hthc -U root -W 90 -C 99
CPU Utilization is 28%.
|
Nagios status is:
**ePN /usr/lib/nagios/plugins/aix/cpu_stat: "Use of uninitialized value in scalar chomp at /usr/lib/perl5/site_perl/5.8.8/Net/SSH.pm line 187,".
Please help me!
Thanks! _________________ Brent Weaver |
|
Back to top |
|
|
richard.scott Veteran
Joined: 19 May 2003 Posts: 1497 Location: Oxfordshire, UK
|
Posted: Mon Jun 08, 2009 10:45 pm Post subject: |
|
|
I guess you've not got the "perl" flag on when compiling nagios-core?
See if this helps:
http://nagiosplug.sourceforge.net/developer-guidelines.html#PERLPLUGIN
Nagios seems to be picky about what perl code it will run.
You could try re-compiling Nagios without perl to see if that helps? ... unless you fancy debugging lots of other peoples perl code so it works in Nagios |
|
Back to top |
|
|
brent_weaver Guru
Joined: 01 Jul 2004 Posts: 510 Location: Burlington, VT
|
Posted: Tue Jun 09, 2009 6:02 pm Post subject: |
|
|
hey thanks for the response. The perl USE flag is used and compiled into nagios-core. It seems that the issue is with parsing out the command??? Seems also that /usr/bin/p1.pl has something to do w/ it. _________________ Brent Weaver |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|