Plugin error: Remote cisco command via SSH not working

Javier Castillo Alcibar Javier.Castillo at a-e.es
Mon Nov 13 10:18:42 CET 2006


Hello all,
 
I have some cisco routers that can only be managed using SSH. I wrote an
script, to do remotely some PING's from these routers, integrated in
nagios.

My problem is very strange:
	- if a execute this script from the command line by myself, it
works as expected.
	- if nagios process executes the script, it does not work. It
looks like ssh process didn't return anything....

I think it's a problem related with ttys.....but I'm not sure.

This is my (perl) script:

#!/usr/bin/perl
#
# Uso: usr/local/sbin/check_cisco_ping_ssh <host> <port> <user> <pass>
<ip> <warn-rate> <crit-rate>
#
use Net::SSH::Perl;

$router=$ARGV[0];
$port=$ARGV[1];
$user=$ARGV[2]; 
$pass=$ARGV[3]; 
$ip=$ARGV[4]; 
$warn=$ARGV[5]; 
$crit=$ARGV[6]; 

my $sesion_ssh = Net::SSH::Perl->new($router, protocol=>1,
cipher=>'DES', port=>$port); 
$sesion_ssh->login($user, $pass);

$command="ping $ip";

my($output, $output_error, $val_exit) = $sesion_ssh->cmd($command);

$output =~ /Success rate is (\d*) (.*)/;
$rate=$1;

if ( $rate <= $crit ) {
        print "PROBLEM: PING Rate=$rate%\n";
        exit 2;
}
if ( $rate <= $warn ) {
        print "WARNING: PING Rate=$rate%\n";
        exit 1;
}
if ( $rate <= 100 ) {
        print "OK: PING Rate=$rate%\n"; 
        exit 0;
}
exit 3;


Any help is welcome!!.

Thx in advance.
Regards
 
--------------------------------------------------------
Alhambra-Eidos ha cambiado su dominio de correo electronico. Por favor revise sus contactos, y proceda a actualizar nuestras direcciones a @a-e.es. 


 
Muchas gracias.
Alhambra-Eidos. We solve IT, we solve it
--------------------------------------------------------

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
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