SupaRice Posted October 9, 2008 Share Posted October 9, 2008 So, I'm setting up cricket (basically like MRTG) for some simple network performance trending. I've used it before, but a long time ago. And I've lost a script that a friend wrote for me to measure latency. I basically need to be able to do this: latency.sh www.google.com And get output that looks like this: 45.23 48.94 56.7 0 Which would be minimum, average, maximum round trip times, followed by % of packet loss. I'm able to do this, but don't know how to write a script that will clean up the output: #ping -l 10 -c 10 -n -q 172.20.227.1 PING 172.20.227.1 (172.20.227.1) 56(84) bytes of data. --- 172.20.227.1 ping statistics --- 10 packets transmitted, 10 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 2.299/2.362/2.451/0.065 ms, pipe 10 Can anyone help me? I'm sure this is a pretty easy thing to do, but I can't figure it out. I've been working on it for a while and looking at scripting guides, but nada... Quote Link to comment Share on other sites More sharing options...
mavrck Posted October 9, 2008 Share Posted October 9, 2008 ping -c4 yahoo.com | grep '/' | awk '{split($4,t,"/"); print t[1], t[2], t[3], t[4]}' produces... 77.310 79.124 83.042 2.285 Quote Link to comment Share on other sites More sharing options...
SupaRice Posted October 9, 2008 Author Share Posted October 9, 2008 Thanks, is there a way to pick up the loss percentage on the other line? For instance, I took what you did and put this into ping.sh ping -c10 -l10 $1 | grep '/' | awk '{split($4,t,"/"); print t[1], t[2], t[3]}' That gives me the min / avg / max from the second line of output, but I need to pull the % of loss from the first line too. Thanks for your help! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.