age*_*ser 10 linux monitoring ssh port nagios
我刚刚在 Gentoo 服务器上部署了 Nagios,除了 ssh 之外,一切都很好,它标记为“CRITICAL”,因为它拒绝连接。但那是因为它在不同于默认 22 的端口上运行。如何更改它以便它监视正确的端口?
Ali*_*ani 15
在 ssh 插件配置 /etc/nagios-plugins/config/ssh.cfg 中,有一个名为 check_ssh_port 的别名。如果它不存在,你可以像上面那样定义它:
$ 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$'
}
Run Code Online (Sandbox Code Playgroud)
在服务文件 /etc/nagios3/conf.d/services_nagios2.cfg 中,定义你的 ssh 服务来监控,如下所示:
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
}
Run Code Online (Sandbox Code Playgroud)
将 12000 替换为默认 ssh 端口和目标服务器。
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>
Run Code Online (Sandbox Code Playgroud)
这回答了你的问题了吗?-p 参数允许您指定端口,在 /etc/nagios/nrpe.cfg 中进行自定义检查并将其放在那里:
command[check_remote_ssh]= /usr/lib/nagios/plugins/check_ssh -p 1234 some.host
Run Code Online (Sandbox Code Playgroud)
由于上述解决方案都不适合我,我将发布这个小变化。
此定义是默认定义(例如localhost.cfg
:),仅添加了 -p 选项和中间的空格。
我想这是给出的两个解决方案的混合版本。
它适用于 Nagios Core 4 和 nagios-plugins 2.1.1
define service{
use local-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_ssh!-p 12345
notifications_enabled 1
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
39660 次 |
最近记录: |