Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
nagios plugin execution and my confusion
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
brent_weaver
Guru
Guru


Joined: 01 Jul 2004
Posts: 510
Location: Burlington, VT

PostPosted: Thu May 21, 2009 7:39 pm    Post subject: nagios plugin execution and my confusion Reply with quote

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
View user's profile Send private message
richard.scott
Veteran
Veteran


Joined: 19 May 2003
Posts: 1497
Location: Oxfordshire, UK

PostPosted: Mon Jun 08, 2009 10:45 pm    Post subject: Reply with quote

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
View user's profile Send private message
brent_weaver
Guru
Guru


Joined: 01 Jul 2004
Posts: 510
Location: Burlington, VT

PostPosted: Tue Jun 09, 2009 6:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
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