返回列表 发帖

Zabbix5.0.12_使用Ping的模板监控主机网络延迟情况

笺注:这是在 CentOS8_LAMP_编译安装Zabbix5.0.12 的基础上进行的。


备注:
被监控主机不用安装zabbix-agent;
这是在公网测试;


在Zabbix服务器上Ping被监控主机的站点域名:
[root@centos8 ~]# ping -c 4 blog.zhuohua.store
PING blog.zhuohua.store (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=1 ttl=128 time=52.3 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=2 ttl=128 time=65.4 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=3 ttl=128 time=86.7 ms
64 bytes from 47.75.39.177 (47.75.39.177): icmp_seq=4 ttl=128 time=74.5 ms

--- blog.zhuohua.store ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 16ms
rtt min/avg/max/mdev = 52.259/69.697/86.703/12.596 ms
[root@centos8 ~]#


在Zabbix服务器上Ping被监控主机的IP地址:
[root@centos8 ~]# ping -c 4 47.75.39.177
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.
64 bytes from 47.75.39.177: icmp_seq=1 ttl=128 time=79.4 ms
64 bytes from 47.75.39.177: icmp_seq=2 ttl=128 time=71.6 ms
64 bytes from 47.75.39.177: icmp_seq=3 ttl=128 time=72.6 ms
64 bytes from 47.75.39.177: icmp_seq=4 ttl=128 time=63.8 ms

--- 47.75.39.177 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 13ms
rtt min/avg/max/mdev = 63.757/71.831/79.403/5.555 ms
[root@centos8 ~]#



#################Zabbix添加被监控主机:

配置》主机》创建主机:(主机名称无需与被监控主机的真实主机名一致;群组可以随便选;Interfaces的类型选择“客户端”;IP地址那里要输入被监控主机的IP地址;端口为10050)
图片1.png


主机Linux_server_1创建成功:
图片2.png


给主机Linux_server_1添加模板:( Template Module ICMP Ping )
图片3.png


模板添加成功:(主机会继承所使用模板的监控项、触发器、图形等等)
图片4.png


模板Template Module ICMP Ping自带的三个监控项:
图片5.png

但这三个监控项的状态都是“不支持的”:
图片6.png

不支持的原因是Zabbix服务器没有安装fping:
At least one of '/usr/sbin/fping', '/usr/sbin/fping6' must exist. Both are missing in the system.
图片7.png



######

在Zabbix服务器安装fping:
tar -zxvf fping-4.0.tar.gz
cd fping-4.0
./configure --prefix=/usr/local/fping/
make && make install

修改fping的权限:
chown root:zabbix /usr/local/fping/sbin/fping
chmod 4710 /usr/local/fping/sbin/fping

fping安装成功:
[root@centos8 ~]# find / -name fping
/root/fping-4.0/src/fping
/usr/local/fping
/usr/local/fping/sbin/fping
[root@centos8 ~]#



测试命令fping:

当Zabbix服务器能Ping通被监控主机的站点域名(blog.zhuohua.store)时的效果:
[root@centos8 ~]# /usr/local/fping/sbin/fping blog.zhuohua.store
blog.zhuohua.store is alive
[root@centos8 ~]#

当Zabbix服务器能Ping通被监控主机的IP地址(47.75.39.177)时的效果:
[root@centos8 ~]# /usr/local/fping/sbin/fping 47.75.39.177
47.75.39.177 is alive
[root@centos8 ~]#



修改Zabbix服务器的配置文件:
[root@centos8 ~]# cat /usr/local/zabbix/etc/zabbix_server.conf |grep "fping"
#       Location of fping.
#       Make sure that fping binary has root ownership and SUID flag set.
# FpingLocation=/usr/sbin/fping
#       Location of fping6.
#       Make sure that fping6 binary has root ownership and SUID flag set.
#       Make empty if your fping utility is capable to process IPv6 addresses.
# Fping6Location=/usr/sbin/fping6

修改为:
[root@centos8 ~]# cat /usr/local/zabbix/etc/zabbix_server.conf |grep "fping"
#       Location of fping.
#       Make sure that fping binary has root ownership and SUID flag set.
FpingLocation=/usr/local/fping/sbin/fping
#       Location of fping6.
#       Make sure that fping6 binary has root ownership and SUID flag set.
#       Make empty if your fping utility is capable to process IPv6 addresses.
# Fping6Location=/usr/sbin/fping6


保存好配置文件后,重启一下Zabbix本机的客户端和服务端:
pkill -9 -U zabbix
/usr/local/zabbix/sbin/zabbix_agentd
/usr/local/zabbix/sbin/zabbix_server


重新检查主机Linux_server_1的三个监控项:
图片8.png

现在正常了:
图片9.png



######

模板Template Module ICMP Ping自带的宏:
图片10.png



模板Template Module ICMP Ping自带的三个触发器:

触发器名称: High ICMP ping loss
严重性: 警告
表达式: {Linux_server_1:icmppingloss.min(5m)}>{$ICMP_LOSS_WARN} and {Linux_server_1:icmppingloss.min(5m)}<100
图片11.png


触发器名称: High ICMP ping response time
严重性: 警告
表达式: {Linux_server_1:icmppingsec.avg(5m)}>{$ICMP_RESPONSE_TIME_WARN}
图片12.png


触发器名称: Unavailable by ICMP ping
严重性: 严重
表达式: {Linux_server_1:icmpping.max(#3)}=0
图片13.png



######

当Zabbix服务器Ping不通主机Linux_server_1时:

root@centos8 ~]# ping -c 4 47.75.39.177
PING 47.75.39.177 (47.75.39.177) 56(84) bytes of data.

--- 47.75.39.177 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 114ms

[root@centos8 ~]#


当Zabbix服务器Ping不通被监控主机的站点域名(blog.zhuohua.store)时的效果:
[root@centos8 ~]# /usr/local/fping/sbin/fping blog.zhuohua.store
blog.zhuohua.store is unreachable
[root@centos8 ~]#


当Zabbix服务器Ping不通被监控主机的IP地址(47.75.39.177)时的效果:
[root@centos8 ~]# /usr/local/fping/sbin/fping 47.75.39.177
47.75.39.177 is unreachable
[root@centos8 ~]#


在仪表板上的告警效果:(显示对应触发器的名称)
Unavailable by ICMP ping
图片14.png

图片15.png



当Zabbix服务器能Ping通主机Linux_server_1时,在仪表板上的告警会马上消失:
图片16.png



######

给主机Linux_server_1的监控项“ICMP loss”创建图形:
图片17.png
监控项:
图片18.png


给主机Linux_server_1的监控项“ICMP ping”创建图形:
图片19.png
监控项:
图片20.png


给主机Linux_server_1的监控项“ICMP response time”创建图形:
图片21.png
监控项:
图片22.png



监测》主机》选择主机Linux_server_1》图形:
图片23.png

选择显示的图形:
图片24.png


查看主机Linux_server_1的图形“ICMP loss image”:
图片25.png
注释:图形中的数据线是从右往左延伸的。

图片26.png


查看主机Linux_server_1的图形“ICMP ping image”:
图片27.png
注释:图形中的数据线是从右往左延伸的。

图片28.png


查看主机Linux_server_1的图形“ICMP response time image”:
图片29.png
注释:图形中的数据线是从右往左延伸的。

图片30.png





相关文章:
Zabbix使用Ping的模板监控主机网络延迟情况

返回列表