Nagios:监视不同端口上的http服务

我想通过在80以外的多个端口上运行的http监视服务。服务在端口8083,8086和一些其他端口上运行。 我创build了server.cfg文件,如下所示:

define host { use linux-server host_name cfbase-prod alias cfbase-prod address xxxx contacts admin } define service { use generic-service host_name cfbase-prod service_description HTTP check_command check_http contacts admin check_interval 1 } 

但它不是在我的nagios控制台上工作,它仍然显示为端口80上的http,事实并非如此。 有人可以帮忙吗?

您可以直接在命令中指定端口号,但是您必须为每个testing端口创build一个命令。

或者你可以创build一个自定义variables来存储端口号,例如:

 define host { use linux-server host_name cfbase-prod alias cfbase-prod address xxxx contacts admin } define service { use generic-service host_name cfbase-prod service_description HTTP check_command check_http contacts admin check_interval 1 _port_number 8083 } 

在你的命令上你可以像这样inheritance这个variables:

 define command{ command_name check_http command_line $USER1$/check_http -I $HOSTADDRESS$ -p $_SERVICEport_number$ $ARG1$ } 

您必须预先为服务或主机预先安装_service以便在命令中使用您的variables。 资源 :

https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/customobjectvars.html

您应该定义一个新命令,可能命名为check_http_port ,将端口作为$ARG1$

 define command { command_name check_http_port command_line $USER1$/check_http -I $HOSTADDRESS$ -p $ARG1$ <other options you use> } 

然后在你的服务定义中使用check_http_port!8083

请参阅check_http --help帮助更多选项/信息。