Using SSH to run remote command checks
Demetri Mouratis
dmourati at cm.math.uiuc.edu
Thu Dec 22 19:28:14 CET 2005
On Thu, 22 Dec 2005, Mark.Law at thomson.com wrote:
> 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$
> }
If you are trying to ssh to another server and kick off the command there
use check_by_ssh as follows:
# check-remote-load
define command{
command_name check-remote-load
command_line $USER1$/check_by_ssh -H $HOSTADDRESS$ -C "$USER1$/check_load -w $ARG1$ -c $ARG2$"
}
In your example, put the chkAdminServer.pl scripts in the nagios plugins
directory on the target, e.g. /usr/lib/nagios/plugins then set the $USER1$
variable to the same. Then, su - nagios of your nagios box and ssh target
/usr/lib/nagios/plugins/chkAdminServer.pl.
-------------------------------------------------------
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_id=7637&alloc_id=16865&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