I have a server that is used a middleman for a bunch of reverse ssh tunnels. I want to use nagios on that server to monitor that all of those ssh tunnels are up.

Essentially I want to do the nagios equivalent of:

ssh -p 12344 localhost
ssh -p 12415 localhost
ssh -p 12544 localhost

I have the following definitions:

define host{
  use generic-host
  host_name paniqui
  address localhost
  _PORT 12345
}

define hostgroup {
    hostgroup_name  chits-servers
    alias           CHITS servers
    members         paniqui
}

define service {
  hostgroup_name                  chits-servers
  service_description             SSHTUNNEL
  check_command                   check_ssh!-p $_HOSTPORT$ $HOSTADDRESS$
  use                             generic-service
  notification_interval           0 ; set > 0 if you want to be renotified
}

But when I check the service on the Nagios web interface I see:

Status Information: UNKNOWN  (for 0d 2h 7m 50s)     
Usage:check_ssh [-46] [-t <timeout>] [-r <remote version>] [-p <port>] <host>

Any suggestions?

link|improve this question
feedback

2 Answers

up vote 4 down vote accepted

Parameters to the command should be configured in the command definition. Something like:

define command {
   command_name check_tunneled_ssh
   command_line /usr/lib/nagios/plugins/check_ssh -p $ARG1$ $HOSTADDRESS$
}

Then you would use

check_command check_tunneled_ssh!12344

in your service.

link|improve this answer
I don't see the point in defining a new command when 'check_ssh' works perfectly well. Your new command just means we have to specify a port and makes it a little more limited. – PriceChild Mar 29 '11 at 23:13
feedback

Here's my nagios/etc/objects/commands.cfg, which I believe is standard.

# 'check_ssh' command definition
define command{
        command_name    check_ssh
        command_line    $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
        }

Which means that I think you've gone wrong by specifying $HOSTADDRESS$ in your check command. Try this in your service definition instead:

  check_command                   check_ssh!-p 12345

Another comment, not related to your 'real' question... I wouldn't make a separate host definition for all the remote servers, I'd just make a new service on the localhost 'host' (seen as that's what's providing the service) for each tunnel.

link|improve this answer
It's a good point, but for my setup I will be adding more services that I am checking, and I think that having them as different hosts is preferable. – Mike McKay Mar 29 '11 at 16:55
Ah k that sounds like a plan. I would still suggest that it is pointless defining a new command like DerfK recommends, when the existing check_ssh will work perfectly well. Just see above for the syntax required of 'check_command'. In addition, assuming the other service checks are going to be 'check_by_ssh'd up I would consider defining this as the host check for those hosts and not a separate service. – PriceChild Mar 29 '11 at 23:09
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.