我的 Linux 机器使用非标准 ssh 端口。 Nagios check_ssh
(当然)不断将进程标记为关键进程,因为它无法连接到该端口。目标文件localhost.cfg
允许将参数传递给check_ssh
.
该文档使用以下示例:
为了 ...
/usr/local/nagios/libexec/check_ping -H 192.168.1.2 -w 100.0,90% -c 200.0,60%
...使用:
define service{
host_name linuxbox
service_description PING
check_command check_ping!200.0,80%!400.0,40%
...
}
但是,它没有描述以何种顺序传递参数。在我的localhost.cfg
尝试中:
check_ssh!xxx22!localhost
和
check_ssh!4!10!OpenSSH_6.7p1!!xxx22!localhost
...其中 xxx22 是实际端口。但它不会将其识别为端口。
查看check_ssh
手册页似乎没有表明以什么顺序放置这些开关......
The check_ssh Plugin
check_ssh v2.2.1.git (nagios-plugins 2.2.1)
Copyright (c) 1999 Remi Paulmier <[email protected]>
Copyright (c) 2000-2014 Nagios Plugin Development Team
<[email protected]>
Try to connect to an SSH server at specified server and port
Usage:
check_ssh [-4|-6] [-t <timeout>] [-r <remote version>] [-p <port>] <host>
Options:
-h, --help
Print detailed help screen
-V, --version
Print version information
--extra-opts=[section][@file]
Read options from an ini file. See
https://www.nagios-plugins.org/doc/extra-opts.html
for usage and examples.
-H, --hostname=ADDRESS
Host name, IP Address, or unix socket (must be an absolute path)
-p, --port=INTEGER
Port number (default: 22)
-4, --use-ipv4
Use IPv4 connection
-6, --use-ipv6
Use IPv6 connection
-t, --timeout=INTEGER:<timeout state>
Seconds before connection times out (default: 10)
Optional ":<timeout state>" can be a state integer (0,1,2,3) or a state STRING
-r, --remote-version=STRING
Alert if string doesn't match expected server version (ex: OpenSSH_3.9p1)
-P, --remote-protocol=STRING
Alert if protocol doesn't match expected protocol version (ex: 2.0)
-v, --verbose
Show details for command-line debugging (Nagios may truncate output)
Send email to [email protected] if you have questions regarding use
of this software. To submit patches or suggest improvements, send email to
[email protected]
答案1
您可以定义一个命令并将该命令用于您的服务。
define command{
command_name check_ssh_2222
command_line /usr/lib/nagios/plugins/check_ssh -p 2222 $ARG1
}
然后为您服务:
check_command check_ssh_2222
答案2
我的/etc/nagios/objects/commands.cfg
州
define command{
command_name check_ping
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c $ARG2$ -p 5
}
它定义了感叹号之间的参数,如您给出的文档示例中所示。它还告诉我们
define command{
command_name check_ssh
command_line $USER1$/check_ssh $ARG1$ $HOSTADDRESS$
}
我认为你的条目应该是
check_ssh!--port=xxx22
因为没有像--port=$ARG1$
定义中那样的预定义参数来指定端口,而只有通用占位符。
编辑:我认为 localhost 不应该成为该check_ssh!...
行的一部分,因为 nagios 将替换$HOSTADDRESS$
适当的主机 ip/名称。