我有一个CentOS 7服务器,在接口eth0和eth1上各有两个I。我想用Nagios分别检查两个IP的ping状态,因为每个IP用于不同的用途和不同的VLAN中。
我尝试对两个IP使用check_ping,但它没有正确显示次要IP状态。即使eth1接口IP被关闭,它也会显示ping状态OK。
我看到check_ping插件有一个选项如下
/usr/local/nagios/libexec/check_ping -H <eth1interfaceIP> -w 1000.0,10% -c 3000.0,50%但是,如何在Nagios服务器中的主机配置文件中实现这一点,而没有在客户机中安装代理呢?
发布于 2018-08-27 10:15:37
我找到了解决办法。在这里添加“自定义变量宏”将有所帮助。这种类型的宏与标准宏不同,标准宏必须以"_“符号作为前缀。
步骤:
1.在Nagios服务器的全局commands.cfg文件中使用下面的变量添加命令定义。自定义变量宏是下面代码中的_HOSTSECONDIP、_HOSTTHIRDIP
define command{
command_name check-host-alive
command_line $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,80% -c 5000.0,100% -p 5
}
define command{
command_name check-second-ip
command_line $USER1$/check_ping -H $_HOSTSECONDIP$ -w 3000.0,80% -c 5000.0,100% -p 5
}
define command{
command_name check-third-ip
command_line $USER1$/check_ping -H $_HOSTTHIRDIP$ -w 3000.0,80% -c 5000.0,100% -p 5
}2.在Nagios服务器内的服务器配置文件中添加服务器的辅助IP配置。
define host {
use linux-server
host_name hostname
alias hostname
address IP1
_SECONDIP IP2
_THIRDIP IP3
icon_image win40.png
icon_image_alt Windows
vrml_image win40.png
statusmap_image win40.png
}
define service{
use generic-service
host_name hostname
service_description Ping-IP1
check_command check_ping!1000.0,10%!3000.0,50%
}
define service{
use linux-service
host_name hostname
service_description Ping-IP2
check_command check-second-ip!IP2!1000.0,10%!3000.0,50%
}
define service{
use linux-service
host_name hostname
service_description Ping-IP3
check_command check-third-ip!IP3!1000.0,10%!3000.0,50%
}3.重新启动Nagios服务器
service nagios restarthttps://stackoverflow.com/questions/51857001
复制相似问题