Jump to content

Help with Ping script for RRD


Recommended Posts

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
PING ( 56(84) bytes of data.

--- 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...

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...