Page 1 of 1

check_by_ssh

Posted: Wed May 07, 2014 12:03 pm
by vburshteyn
Hello All,

Please note that I am a Nagios newb so please be gentle! :)

I have establish an key connection to the remote server and abble to SSH in with out pws.

I am also able to execute commands in CLI:
/usr/local/nagios/libexec/check_by_ssh -E 1 -l vi-admin -H x.x.x.x -C "~/box293_check_vmware.pl --server y.y.y.y --check vCenter_Name_Version"
this command return a valid response.

When I run this from Nagios:
/usr/local/nagios/libexec/check_by_ssh -l vi-admin -H x.x.x.x $ARG1$
$ARG1$ = -C "~/box29vmware.pl --server y.y.y.y --check vCenter_Name_Version"
I get
TEST: OUTPUT: Remote command execution failed: Could not create directory '/var/www/.ssh'.
and Remote command execution failed.

Any tips would be appreciated.

Re: check_by_ssh

Posted: Wed May 07, 2014 3:19 pm
by sreinhardt
When you ran this via cli what user were you? Also I would highly suggest against using the test command button. It runs from apache via a php file as the apache user, which is quite separate from the nagios user. Specifically for check_by_ssh it would need a ~/.ssh folder with a ssh key for the apache user to login password-less, which I am guessing is not likely there.

Re: check_by_ssh

Posted: Wed May 07, 2014 3:22 pm
by vburshteyn
i ran the command as a nagios user.

Re: check_by_ssh

Posted: Wed May 07, 2014 4:53 pm
by sreinhardt
OK great! So if you save that service and apply configuration, so that nagios is restarted with that command and service. What happens with it, does it check correctly?

Re: check_by_ssh

Posted: Wed May 07, 2014 5:05 pm
by Box293
I think the problem is in your command definition or service definition.

The command in the command defintion should be:

Code: Select all

define command {
command_name box293_check_vmware
command_line $USER1$/check_by_ssh -E 1 -t 90 -l vi-admin -H x.x.x.x -C "~/box293_check_vmware.pl --server $ARG1$ --check $ARG2$ \"$ARG3$\" \"$ARG4$\" \"$ARG5$\" \"$ARG6$\" \"$ARG7$\" \"$ARG8$\""
}
Where x.x.x.x is the IP address of your vMA server

And the check command in your service definition should be:

Code: Select all

check_command box293_check_vmware!y.y.y.y!vCenter_Name_Version!!!!!!
Where:
  • $ARG1$ = y.y.y.y
    $ARG2$ = vCenter_Name_Version
Does this help?