Monday, October 17, 2016

Getting time with the ping command

Problem:
Not a big problem but more like created by me. I just wanted to get more information when performing the ping. Sometime it is hand to get the time stamp when ping was performed. We get timestamp using -T in ping but we have to convert it before we can read it.

Fix:
Not a big deal but it can be done as below:

[root@rac1 ~]# ping rac2 | while read cmdoutput; do echo "$(date): $cmdoutput"; done
Mon Oct 17 11:25:28 AEDT 2016: PING rac2.localdomain (192.168.56.102) 56(84) bytes of data.
Mon Oct 17 11:25:28 AEDT 2016: 64 bytes from rac2.localdomain (192.168.56.102): icmp_seq=1 ttl=64 time=0.317 ms
Mon Oct 17 11:25:29 AEDT 2016: 64 bytes from rac2.localdomain (192.168.56.102): icmp_seq=2 ttl=64 time=0.584 ms
Mon Oct 17 11:25:30 AEDT 2016: 64 bytes from rac2.localdomain (192.168.56.102): icmp_seq=3 ttl=64 time=0.405 ms




No comments: