centos ping添加丢包记录

    因为生产环境有丢包状况,想确认丢包的时间点,记录到ELK系统进行分析,使用ping命令,发现centos 7.5能够实现,可是centos 6.7没法实现,google查找,发现也有人有这个需求,通过测试,找到解决方案:python

    1.centos 7.5下(其余版本没有测试)
git

    命令:github

 ping  -O  8.8.8.8 -D

   结果:centos

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
[1540370905.497951] no answer yet for icmp_seq=1
[1540370905.548084] 64 bytes from 8.8.8.8: icmp_seq=2 ttl=36 time=49.9 ms
[1540370906.549005] 64 bytes from 8.8.8.8: icmp_seq=3 ttl=36 time=49.5 ms
[1540370907.556569] 64 bytes from 8.8.8.8: icmp_seq=4 ttl=36 time=51.0 ms

  2.centos 6.7没有-O的命令,在网上找了一个ping.py,稍微改动了下,能够实现需求ide

pip install python-ping
ls /usr/bin/ping.py

  这个没有时间戳,手动添加一个,时间紧,代码写的丑,凑活能用,若是后续有需求再改吧测试


   https://github.com/sunhackboy/python/blob/master/ping-addtime.pygoogle


  结尾:若是对你有用,请留言或点赞吧ip

相关文章
相关标签/搜索