如何在host.cfg文件中设置port no并在nagios的services.cfg文件中使用它

我有hostgroups.cfg文件,其中我有不同的主机与不同的端口号。 我想通过端口号为每个主机services.cfg文件,我已经把check_http命令。

由于我的不同主机有不同的端口号不同的HTTP进程,所以我想直接从hosts.cfg文件传递端口号。 可能吗?

以下是我在hosts和services.cfg文件中的示例条目

主机文件:

define host{ use abc host_name test alias /test/ address 192.168.0.24 hostgroups testgroup } 

services.cfg文件

  define service{ use critical-service hostgroup_name test service_description HTTP check_command check_http!8080!7!5 } 

commands.cfg文件

  define command{ command_name check_http command_line $USER1$/check_http -H $HOSTADDRESS$ -p $ARG1$ --url $HOSTALIAS$ -c $ARG2$ -w $ARG3$ } 

在你的主机configuration中,像这样添加一个自定义variables :

 define host { use abc host_name test alias /test/ address 192.168.0.24 hostgroups testgroup _port 8080 } 

然后在您的services.cfg中,将端口replace为您设置的variables(您需要为所有主机设置):

 define service { use critical-service hostgroup_name test service_description HTTP check_command check_http!$_HOSTPORT$!7!5 }