ARe*_*ddy 6 linux grep awk ping gawk
我正在寻找一些可以向我展示缺失的东西ICMP包,或者可以在输出中显示失败。下面的例子
当前输出中我们缺少 icmp_seq 计数。
64 bytes from 192.168.56.11: icmp_seq=38 ttl=64 time=1.23 ms
64 bytes from 192.168.56.11: icmp_seq=52 ttl=64 time=0.831 ms
64 bytes from 192.168.56.11: icmp_seq=53 ttl=64 time=0.679 ms
64 bytes from 192.168.56.11: icmp_seq=54 ttl=64 time=0.679 ms
64 bytes from 192.168.56.11: icmp_seq=55 ttl=64 time=0.679 ms
64 bytes from 192.168.56.11: icmp_seq=56 ttl=64 time=0.679 ms
Run Code Online (Sandbox Code Playgroud)
所需的输出,如果丢失,将对 icmp_seq 进行计数,然后显示错误
64 bytes from 192.168.56.11: icmp_seq=51 ttl=64 time=1.23 ms
64 bytes from 192.168.56.11: icmp_seq=52 ttl=64 time=0.831 ms
64 bytes from 192.168.56.11: icmp_seq=53 ttl=64 time=0.679 ms
Failed
Failed
Failed
Failed
64 bytes from 192.168.56.11: icmp_seq=58 ttl=64 time=0.679 ms
64 bytes from 192.168.56.11: icmp_seq=59 ttl=64 time=0.679 ms
Failed
Failed
Failed
Run Code Online (Sandbox Code Playgroud)
ARe*_*ddy -1
到目前为止,我已经成功编写了以下命令。我可以在后台运行它以及tailf正在创建的文件。
[root@connect ~]# touch result.txt; while true; do ping -c 1 -w 2 192.168.56.11 || echo \xe2\x80\x9c`date` ping faild\xe2\x80\x9d >> result.txt; sleep 1; done\nRun Code Online (Sandbox Code Playgroud)\n编者注:发帖者可能想写以下内容而不是\xe2\x80\x9c`date` ping faild\xe2\x80\x9d:
[root@connect ~]# touch result.txt; while true; do ping -c 1 -w 2 192.168.56.11 || echo \xe2\x80\x9c`date` ping faild\xe2\x80\x9d >> result.txt; sleep 1; done\nRun Code Online (Sandbox Code Playgroud)\n