Don't forget you may also want to post this on nagiosexchange.com as it's a great resource for Nagios related projects.
Thx, -Don Lewis On Thu, 2006-11-16 at 17:13 +0100, Javier Castillo Alcibar wrote: > Hello, > > I think I solved the problem. Notice this command in my perl script: > "$ENV{'HOME'} = '/var/lib/nagios';" > > Nagios process was executing the plugin with HOME env varible set to "/root" > ¿?¿?. This made ssh fails when trying to read $HOME/.ssh/config files.... > (root folder is not readable by other users) > > Finally, my contribution to nagios world: check_cisco_ping_ssh (ping from > cisco routers, using ssh): > > #!/usr/bin/perl > # Net::SSH de http://www.stupidfool.org/perl/net-ssh/ > # > # Use: usr/local/sbin/check_cisco_ping_ssh <host> <port> <user> <pass> <ip> > <warn> <crit> > # > use strict; > > use Net::SSH::Perl; > > $ENV{'HOME'} = '/var/lib/nagios'; > > my $router=$ARGV[0]; > my $port=$ARGV[1]; > > my $user=$ARGV[2]; > my $pass=$ARGV[3]; > > my $ip=$ARGV[4]; > > my $warn=$ARGV[5]; > my $crit=$ARGV[6]; > > > > my $sesion_ssh = Net::SSH::Perl->new($router, protocol=>1, cipher=>'DES', > port=>$port, debug=> 'false'); > $sesion_ssh->login($user, $pass); > > my $comand="ping $ip"; > > my($output, $output_error, $value_exit) = $sesion_ssh->cmd($command); > > $output =~ /Success rate is (\d*) (.*)/; > > my $rate=$1; > > if ( $rate <= $crit ) { > print "PROBLEM: Rate=$rate%\n"; > exit 2; > } > > if ( $rate <= $warn ) { > print "WARNING: Rate=$rate%\n"; > exit 1; > } > > if ( $rate <= 100 ) { > print "OK: Rate=$rate%\n"; > exit 0; > } > > exit 3; > > > > Enjoy it. > Regards > > Javier Castillo Alcíbar (2404) > Alhambra Eidos. > +34 91 787 23 00 [EMAIL PROTECTED] > > > > > > > > -----Mensaje original----- > De: Andreas Ericsson [mailto:[EMAIL PROTECTED] > Enviado el: jueves, 16 de noviembre de 2006 16:59 > Para: Javier Castillo Alcibar > CC: nagios-users@lists.sourceforge.net > Asunto: Re: [Nagios-users] Plugin error: Remote cisco command via SSH > notworking > > Javier Castillo Alcibar wrote: > > > > 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!!. > > > > Have you compiled nagios with embedded perl support? If so, use /usr/bin/perl > /path/to/your/script.pl > > instead of just > > /path/to/your/script.pl > > in the command definition. > > Other than that, make sure that the nagios-user has access to execute the > script and try it from the command-line *as the nagios user*. If that works, > you've made some mistake in your configuration. > > -- > Andreas Ericsson [EMAIL PROTECTED] > OP5 AB www.op5.se > Tel: +46 8-230225 Fax: +46 8-230231 > > -------------------------------------------------------- > Alhambra-Eidos ha cambiado su dominio de correo electrónico. 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 > -------------------------------------------------------- > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Nagios-users mailing list > Nagios-users@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 ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Nagios-users mailing list Nagios-users@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