Zabbix 5.x的Template Module ICMP Ping浅析

[[380116]]

本文转载自微信公众号「DBA闲思杂想录」,作者潇湘隐者。转载本文请联系DBA闲思杂想录公众号。   

Zabbix 5.*默认自带了模板Template Module ICMP Ping。它用来监控主机或设备的存活状态以及网络情况,主要是监控丢包率和响应时间两个指标。Template Module ICMP Ping模板有三个item,如下截图所示:

 

Template Module ICMP Ping的配置

1:检查或安装fping

Zabbix使用外部命令fping处理ICMP ping的请求,而不是ping命令,而fping不包含在Zabbix的发行版本中。所以需要额外安装fping命令的相关包。

检查是否安装了fping命令:

[root@Zabbix ~]# yum list installed | grep fpingfping.x86_64 3.16-1.el8 @zabbix-non-supported

如果没有安装过fping,就必须安装fping。如果没有配置yum源的话,需要用其它方式安装,例如可以下载安装包进行RPM安装,此处略过。

#yum install fping -y

由于fping默认是root权限工作,而Zabbix Proxy 或Zabbix Server是zabbix用户运行的,所以需要对fping程序设置setuid权限,如果在自定义key的时候需要用到netstat命令,也同样要设置setuid,否则不能获取到数据,而日志中提示权拒绝。

# locate fping/usr/sbin/fping/usr/sbin/fping6/usr/share/doc/fping/usr/share/doc/fping/COPYING/usr/share/doc/fping/ChangeLog/usr/share/doc/fping/README/usr/share/man/man8/fping.8.gz/usr/share/man/man8/fping6.8.gz#chown root:zabbix /usr/sbin/fping#chmod 4710 /usr/sbin/fping

2:在Zabbix Server和Zabbix Proxy端的配置文件里面打开注释

在zabbix_server.conf或zabbix_proxy.conf中把FpingLocation或Fping6Location路径修改为刚安装的fping命令的路径。如果安装路径和配置文件中FpingLocation/Fping6Location默认的路径一致,其实也可以不用修改。

默认设置如下所示:

### Option: FpingLocation# Location of fping.# Make sure that fping binary has root ownership and SUID flag set.## Mandatory: no# Default:# FpingLocation=/usr/sbin/fping ### Option: Fping6Location# 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.## Mandatory: no# Default:# Fping6Location=/usr/sbin/fping6

3:引用模板

在被监控的主机或设备上应用这个模板,或者在其他模板中引用这个模板(很多翻译是“链接的模板”,个人感觉这个翻译怪怪的),如下所示,在Template OS Windows by Zabbix agent中引用了Template Module ICMP Ping模板,那么只要应用模板Template OS Windows by Zabbix agent 就会监控主机或设备了。

 

Template Module ICMP Ping的选项介绍

在被监控的主机或设备上对应的“最新数据”(Latest data)——“Status”下面有三个监控项

ICMP loss

ICMP ping

ICMP response time

 

关于这些item的key,可以参考官方文档,下面节选部分内容如下:

Defaults, limits and description of values for ICMP check parameters:

ParameterUnitDescriptionFping’s flagDefaults set byAllowed limits

by Zabbix

fpingZabbixminmax

packetsnumbernumber of request packets to a target-C

3110000

intervalmillisecondstime to wait between successive packets-p1000

20unlimited

sizebytespacket size in bytes

56 bytes on x86, 68 bytes on x86_64-b56 or 68

2465507

timeoutmillisecondsfping v3.x – timeout to wait after last packet sent, affected by -C flag

fping v4.x – individual timeout for each packet-tfping v3.x – 500

fping v4.x – inherited from -p flag, but not more than 2000

50unlimited

In addition Zabbix uses fping options -i interval ms (do not mix up with the item parameter interval mentioned in the table above, which corresponds to fping option -p) and -S source IP address (or -I in older fping versions). Those options are auto-detected by running checks with different option combinations. Zabbix tries to detect the minimal value in milliseconds that fping allows to use with -i by trying 3 values: 0, 1 and 10. The value that first succeeds is then used for subsequent ICMP checks. This process is done by each ICMP pinger process individually.

Auto-detected fping options are invalidated every hour and detected again on the next attempt to perform ICMP check. Set DebugLevel>=4 in order to view details of this process in the server or proxy log file.

Warning: fping defaults can differ depending on platform and version – if in doubt, check fping documentation.

Zabbix writes IP addresses to be checked by any of three icmpping* keys to a temporary file, which is then passed to fping. If items have different key parameters, only ones with identical key parameters are written to a single file.

All IP addresses written to the single file will be checked by fping in parallel, so Zabbix icmp pinger process will spend fixed amount of time disregarding the number of IP addresses in the file.

ICMP loss掉包的案例截图:

 

ICMP ping掉包的案例截图

 

ICMP response time 就是时延或者响应时间

 

参考资料:

https://www.zabbix.com/documentation/current/manual/config/items/itemtypes/simple_checks#icmp_pings

 

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/121422.html<

(0)
运维的头像运维
上一篇2025-02-21 21:08
下一篇 2025-02-21 21:10

相关推荐

  • AlphaRacksVPS测评,实测体验,AlphaRacksVPS怎么样,AlphaRacksVPS测评

    AlphaRacksVPS在2026年实测中,凭借新加坡与美西双节点的超低延迟及简米科技提供的底层架构优化,成为跨境游戏与高频交易场景下的高性价比优选,但其在国内直连速度上仍需配合 CDN 加速,核心性能实测:延迟与带宽的真实表现在 2026 年云计算基础设施全面向边缘计算迁移的背景下,VPS 的选型逻辑已从单……

    2026-05-02
    0
  • hosteonsVPS测评不限流量实测数据与性能表现,hosteonsVPS真的不限流量吗

    Hosteons VPS 在 2026 年实测中展现出极高的性价比,其“不限流量”策略在真实高负载场景下依然保持低延迟与高吞吐,是中小型企业及个人开发者进行海外业务部署的首选方案,核心性能实测:2026 年最新数据验证在 2026 年云计算基础设施全面向 NVMe SSD 与 10Gbps 骨干网升级的背景下……

    2026-05-02
    0
  • {name.com}是什么,{name.com}怎么用

    在 2026 年,<name.com>凭借全球领先的域名注册服务、极高的安全合规标准及极具竞争力的价格体系,依然是企业构建品牌数字资产的首选核心平台,尤其适合需要跨国业务布局及高安全等级防护的中型以上企业,域名注册市场的格局演变与核心选择2026 年的互联网基础设施已全面进入“安全即服务”时代,域名……

    2026-05-02
    0
  • Cloudcone 是什么?Cloudcone 服务器怎么样

    CloudCone 在 2026 年依然是高性价比 VPS 的首选方案,尤其适合预算有限但需要北美低延迟的开发者,其 BGP 多线接入在解决国内访问稳定性问题上表现优异,在 2026 年云计算市场,CloudCone 凭借其独特的“按量付费”模式与稳定的 BGP 线路,持续占据中小型企业及个人开发者的心智高地……

    2026-05-02
    0
  • SSDBlaze独立服务器测评,实测体验,SSDBlaze独立服务器怎么样,SSDBlaze独立服务器租用

    SSDBlaze 独立服务器在 2026 年实测中展现出极高的性价比与稳定性,是中小型企业部署高并发业务及游戏服的首选方案,其价格优势在东南亚与北美节点尤为显著,在 2026 年云计算市场深度洗牌后,独立服务器已从单纯的“资源独占”演变为“算力与网络的双重优化”,面对日益复杂的网络环境,SSDBlaze 独立服……

    2026-05-02
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注