Using SSH to run remote command checks

Marc Powell marc at ena.com
Thu Dec 22 18:06:57 CET 2005



> -----Original Message-----
> From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
> admin at lists.sourceforge.net] On Behalf Of Mark.Law at thomson.com
> Sent: Thursday, December 22, 2005 8:46 AM
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Using SSH to run remote command checks
> 
> I tested the following command from the command line ~
> 
> /usr/bin/ssh -l nagios host1 chkAdminServer.pl
> 
> and it returns OK with an exit code of 0.  Great.
> 
> When I put it into the following service definition, I get a Status
> UNKNOWN with STATUS INFORMATION (No Output)
> 
> define service{
>   name                            check_adminserver
>   service_description             AdminServer
>   use                             hg.prod.check_5min
>   host                            host1,host2
>   contact_groups                  systemgrp
>   check_command
> check_command_ssh!/path/to/perl/script/bin/chkAdminServer.pl!
> }
> 
> The check command definition is really simple also ~
> 
> define command{
>   command_name    check_command_ssh
>   command_line    /usr/bin/ssh -l nagios $HOSTADDRESS$ $ARG1$
> }
>
> I have checked permissions, log files, verified public keys on the
> remote server, everything I can think of - but it continues to fail.
In
> fact, it appears that the command isn't even attempting to run.   Any
> ideas?

The majority of the time this happens because people run their tests as
root or some other user who does not have the same access levels as the
nagios user. Did you perform your test as the nagios user? My first
suspicion is that the host key hasn't been accepted for that host for
the nagios user.

You can also try changing your command definition to make sure nagios is
calling ssh and in exactly the way you expect it is with --


define command{
  command_name    check_command_ssh
  command_line    echo "/usr/bin/ssh -l nagios $HOSTADDRESS$ $ARG1$"
>>/tmp/ssh_exec
}

--
Marc


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&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