Rootop 服务器运维与web架构

ssh端口修改后nagios监控ssh服务

| 暂无评论

ssh端口修改后nagios监控ssh服务

nagios默认监控ssh的端口是22,这个是无疑的,为了安全我们可能会修改ssh的默认端口,这样一样nagios就无法正常监控了。
现在就需要修改监控主机的配置文件。
我们可能不了解nagios插件的参数,不过可以通过如下方式查看:
[root@localhost ~]# cd /usr/local/nagios/libexec/ #进入nagios插件目录

[root@localhost libexec]# ./check_ssh #直接执行二进制文件,有的是shell脚本
check_ssh: Could not parse arguments
Usage:
check_ssh [-4|-6] [-t <timeout>] [-r <remote version>] [-p <port>] <host>
[root@localhost libexec]# ./check_http
check_http: Could not parse arguments
Usage:
 check_http -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]
 [-J <client certificate file>] [-K <private key>]
 [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-E] [-a auth]
 [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]
 [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]
 [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]
 [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]
 [-T <content-type>] [-j method]

根据提示可以看到插件支持的参数,那么这里ssh的就需要-p指定端口号。
比如我现在监控本机,直接修改localhost.cfg

define service{
 use local-service ; Name of service template to use
 host_name localhost
 service_description SSH
 check_command check_ssh! -p 1122
 notifications_enabled 0
 }

nagios下,命令与参数之间通过叹号!来分开。

define service{
 use local-service ; Name of service template to use
 host_name localhost
 service_description HTTP
 check_command check_http! -p 8080 #也可以用check_tcp!8080这种方法
 notifications_enabled 0
 }

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/2565.html

作者:Venus

服务器运维与性能优化

发表回复