I just deployed Nagios on a Gentoo server and everything is fine except ssh, which it marks as "CRITICAL" because it's refusing connections. But that's because it's running on a port different from the default 22. How do I change it so that it monitors the right port?

link|improve this question

67% accept rate
feedback

3 Answers

up vote 3 down vote accepted
host:~$ /usr/lib/nagios/plugins/check_ssh --help
check_ssh v1991 (nagios-plugins 1.4.12)
Copyright (c) 1999 Remi Paulmier <remi@sinfomic.fr>
Copyright (c) 2000-2007 Nagios Plugin Development Team
        <nagiosplug-devel@lists.sourceforge.net>

Try to connect to an SSH server at specified server and port


Usage:check_ssh [-46] [-t <timeout>] [-r <remote version>] [-p <port>] <host>

does this answer your question? -p parameter lets you specify the port, make custom check in /etc/nagios/nrpe.cfg and put there:

command[check_remote_ssh]= /usr/lib/nagios/plugins/check_ssh -p 1234 some.host
link|improve this answer
It worked! In my case it was the local check_ssh in /etc/nagios/objects/commands.cfg. Thanks for your help :) – obvio171 Oct 11 '09 at 20:45
feedback

In ssh pluging config /etc/nagios-plugins/config/ssh.cfg, there an alias named check_ssh_port. if it not existe you may defined like above:


$ cat >> /etc/nagios-plugins/config/ssh.cfg
define command{
        command_name    check_ssh_port
        command_line    /usr/lib/nagios/plugins/check_ssh -p '$ARG1$' '$HOSTADDRESS$'
        }

in the service file /etc/nagios3/conf.d/services_nagios2.cfg, define you ssh service to monitor like this:


define service {
        hostgroup_name                  ssh2-servers
        service_description             SSH2
        check_command                   check_ssh_port!12000!server
        use                             generic-service
        notification_interval           240 ; set > 0 if you want to be renotified
}
replace 12000 by you default ssh port and server by your target.

link|improve this answer
+1 well written for the latest version of nagios (at this time) – cwd Dec 11 '11 at 19:24
feedback

What about exceptions? Does this cover it? Only one of my servers is running sshd on a non-standard port. Should I take this one server out of the ssh_servers hostgroup?

link|improve this answer
This isn't a discussion forum, so you should really post this as a new question. However, the answer is to pass the port as a parameter for any server which doesn't use port 22. i.e. In the service definition: check_command check_ssh!-p 222 – John Gardeniers May 10 '10 at 3:56
feedback

Your Answer

 
or
required, but never shown

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