Results 1 to 2 of 2

Thread: check_by_ssh ok from command line, but fails in command [SOLVED]

  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    4

    check_by_ssh ok from command line, but fails in command [SOLVED]

    I am trying to check if a remote process is running in a remote machine using the check_by_ssh plugin.

    SSH is configured and I can connect without password with user shinken. Even more, the command works perfectly when run directly from command line:

    Code:
    su shinken -c '/usr/lib/nagios/plugins/check_by_ssh -H remote_address -u shinken -i ~shinken/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_procs -c 1:1 -C MyProcess"'
    PROCS OK: 1 process with command name 'MyProcess'
    However, when run as a command by shinken, it fails with:

    Code:
    UNKNOWN - check_by_ssh: Remote command '/usr/lib/nagios/plugins/check_procs -c 1:1 -C MyProcess' returned status 255
    My command definition is as follows:

    Code:
    define command {
        command_name   check_ssh_MyProcess
        command_line   /usr/lib/nagios/plugins/check_by_ssh -H $HOSTADDRESS$ -p $_HOSTSSH_PORT$ -u shinken -i ~shinken/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_procs -c 1:1 -C MyProcess" -E
    }
    Seems to be a permissions problem, but after so much reading, I don't know what could be wrong. Any ideas?

  2. #2
    Junior Member
    Join Date
    Nov 2014
    Posts
    4

    Re: check_by_ssh ok from command line, but fails in command [SOLVED]

    For anyone interested, I have solved this problem with:

    Code:
    ssh-copy-id -i ~/.ssh/id_rsa.pub shinken@remote_address
    Originally, I had copied the keys with:

    Code:
    scp .ssh/id_dsa shinken@remote_address:~/.ssh/authorized_keys
    This copies the keys as ssh-dss, while with ss-copy-id it is as ssH-rsa. I don't know why shinken does not like ssh-dss, but hey I'm not a crypto-expert

    Finally, my command is now as follows:

    Code:
    define command {
        command_name   check_ssh_MyDaemon
        command_line   $USER1$/check_by_ssh -H $HOSTADDRESS$ -p $_HOSTSSH_PORT$ -u shinken -i ~shinken/.ssh/id_rsa -C "/usr/lib/nagios/plugins/check_procs -c 1:1 -C MyDaemon" -E
    }
    Hoping this could help someone else...

    BTW, does shinken have a native check_procs equivalent? No problem with the nagios plugin, but...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •