Sponsored Content
Top Forums Shell Programming and Scripting Extracting Latency, Loss and Jitter from PING responses. Post 302264638 by tony.kandaya on Thursday 4th of December 2008 12:36:08 PM
Old 12-04-2008
Thanks for all your help guys, here is what I have done so far

1 - a check-hosts script that uses a host-list.txt to ping konwn hosts

./check-hosts (script that pings hosts and generates the ping-results.txt)
rm -f ping-results.txt
cat hosts-list.txt |\
while read line
do
echo . >> ping-results.txt
date >> ping-results.txt
ping -c 5 -q $line >> ping-results.txt
echo $line
done

2 - host-list.txt

Host11
Host12
Host13
Host14

3 - I have modified the awk script (named extract-sla) from Zaxxon's response to read like this

awk '
/^PING / {h=$2}
/packet loss/ {pl=$6}
/min\/avg\/max/ {
split($4,a,"/")
printf("%s %s %s %s\n", h, a[2], a[4], pl )
}
' ping-results.txt

4 - Here is the new output from the results (which I can store into a file)

Host11 56.817 8.520 0%
Host12 55.031 8.485 0%
Host13 72.351 40.053 0%
Host14 32.590 9.705 0%

** Is there a way to get rid of the % sign since we already know it's a percentage.

5 - I would like to input these numbers into a database with a mysql command (the database and tables are already created)

Hostxx a b c

mysql -h 10.255.1.11 -u ping --password='ping' -D host_SLA -e "UPDATE device_list SET latency=a, jitter=b, loss=c WHERE host='Hostxx'";


Thanks for all your responses
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ping to machine and count responses

if i wanted to ping all the machines in a given directory (/etc/hosts) and return a total count of responses how would i go about scripting that? complete newbie...so be gentle if ; then //$1 = /etc/hosts cd "$1" //this puts me into the directory i need...but how do i send ... (2 Replies)
Discussion started by: trostycp
2 Replies

2. Shell Programming and Scripting

How to automate responses

I would have searched for this but I couldn't really think of what to use for the search text... I've got a situation where I need to automate responses to an executable when running it from a script so that it can be made into a job the operators don't have to interact with. When I run it... (2 Replies)
Discussion started by: djp
2 Replies

3. Linux

How do I capture responses from the chat command?

Unfortunately googling the word 'chat' gives you zebedee billion responses that relate to everything and few of them refer to the linux chat command. I've read the man page and found a couple of examples but can't see how to do this. I want to query the modem for it's manufacturer, product id... (8 Replies)
Discussion started by: Bashingaway
8 Replies

4. Shell Programming and Scripting

Using AWK to Calculate Correct Responses

Hello, I am trying to count how many times a subject makes a correct switch or a correct stay response in a simple task. I have data on which condition they were in (here, labeled "IMAGINE" and "RECALL"), as well as whether they made a left or right button response, and whether the outcome was... (5 Replies)
Discussion started by: Jahn
5 Replies

5. Shell Programming and Scripting

Extracting avg latency value from ping output

Hello Everyone, Below is the output of the ping from a router. Please help with a script which extract the Avg value from the o/p (Avg here = 4, as depicted below) and put the value into a new file. Will appreciate your help dearly Router#ping 36.36.36.36 Type escape sequence to abort.... (2 Replies)
Discussion started by: sanjugab
2 Replies

6. AIX

Packet loss coming with big packet size ping

(5 Replies)
Discussion started by: Vishal_dba
5 Replies

7. IP Networking

DNS: Dig returns different responses...

Hey everyone, Okay, so I've been having some fun with the dig command, and wanted to dig my old school. Two questions came up from this. So I: dig @8.8.8.8 +recurse njcu.edu ANY and the result is about 8 records, including the SOA record. One of them is this weird TXT record, and the other is... (1 Reply)
Discussion started by: Lost in Cyberia
1 Replies

8. Shell Programming and Scripting

Searching a file - and assigning responses to variables (or something)

So first: Sorry if the title is confusing... I have a script I'm writing with a file with several names in it (some other info - but it's not really pertinent...) - I want to be allow the user to delete certain records, but I ran into a problem I'm not sure how to go about fixing. If I were... (6 Replies)
Discussion started by: sabster
6 Replies

9. UNIX for Beginners Questions & Answers

Simple conditional yields too many responses

In this script: #!/bin/bash # bird read -p "Enter name of a bird " REPLY=$REPLY birdname="duck sparrow hawk" for i in $birdname do if ] then echo "Yes, that is a bird." else echo "That is not a bird." fi done I get... (9 Replies)
Discussion started by: Xubuntu56
9 Replies
2PING(8)																  2PING(8)

NAME
2ping - A bi-directional ping client/listener SYNOPSIS
2ping [ options ] --listen | host/IP DESCRIPTION
2ping is a bi-directional ping utility. It uses 3-way pings (akin to TCP SYN, SYN/ACK, ACK) and after-the-fact state comparison between a 2ping listener and a 2ping client to determine which direction packet loss occurs. To use 2ping, start a listener on a known stable network host. The relative network stability of the 2ping listener host should not be in question, because while 2ping can determine whether packet loss is occurring inbound or outbound relative to an endpoint, that will not help you determine the cause if both of the endpoints are in question. Once the listener is started, start 2ping in client mode and tell it to connect to the listener. The ends will begin pinging each other and displaying network statistics. If packet loss occurs, 2ping will wait a few seconds (default 10, configurable with -w) before comparing notes between the two endpoints to determine which direction the packet loss is occurring. To quit 2ping on the client or listener ends, enter ^C, and a list of statistics will be displayed. To get a short inline display of statistics without quitting, send the process a QUIT signal (yes, that's the opposite of what you would think, but it's in line with the normal ping utility). OPTIONS
ping-compatible options: -a Audible ping. -A Adaptive ping. A new client ping request is sent as soon as a client ping response is received. If a ping response is not received within the interval period, a new ping request is sent. Minimal interval is 200msec for not super-user. On networks with low rtt this mode is essentially equivalent to flood mode. 2ping-specific notes: This behavior is somewhat different to the nature of ping's adaptive ping, but the result is roughly the same. -c count Stop after sending count ping requests. 2ping-specific notes: This option behaves slightly differently from ping. If both -c and -w are specified, satisfaction of -c will cause an exit first. Also, internally, 2ping exits just before sending count+1 pings, to give time for the ping to complete. -f Flood ping. For every ping sent a period "." is printed, while for ever ping received a backspace is printed. This provides a rapid display of how many pings are being dropped. If interval is not given, it sets interval to zero and outputs pings as fast as they come back or one hundred times per second, whichever is more. Only the super-user may use this option with zero interval. 2ping-specific notes: Detected outbound/inbound loss responses are printed as ">" and "<", respectively. Receive errors are printed as "E". Due to the asynchronous nature of 2ping, successful responses (backspaces) may overwrite these loss and error characters. -i interval Wait interval seconds between sending each ping. The default is to wait for one second between each ping normally, or not to wait in flood mode. Only super-user may set interval to values less 0.2 seconds. -I interface IP Set source IP address. When pinging IPv6 link-local address this option is required. When in listener mode, this option may be specified multiple to bind to multiple IP addresses. When in client mode, this option may only be specified once, and all outbound pings will be bound to this source IP. 2ping-specific notes: This option only takes an IP address, not a device name. Note that in listener mode, if the machine has an interface with multiple IP addresses and an request comes in via a sub IP, the reply still leaves via the interface's main IP. So this option must be used if you would like to respond via an interface's sub-IP. -l preload If preload is specified, 2ping sends that many packets not waiting for reply. Only the super-user may select preload more than 3. -p pattern You may specify up to 16 "pad" bytes to fill out the packets you send. This is useful for diagnosing data-dependent problems in a network. For example, -p ff will cause the sent packet pad area to be filled with all ones. 2ping-specific notes: This pads the portion of the packet that does not contain the active payload data. If the active payload data is larger than the minimum packet size (--min-packet-size=min), no padding will be sent. -q Quiet output. Nothing is displayed except the summary lines at startup time and when finished. -s packetsize ping compatibility, this will set --min-packet-size to this plus 8 bytes. -v Verbose output. In 2ping, this prints decodes of packets that are sent and received. -V Show version and exit. -w deadline Specify a timeout, in seconds, before 2ping exits regardless of how many pings have been sent or received. Due to blocking, this may occur up to one second after the deadline specified. 2ping-specific notes: This option behaves slightly differently from ping. If both -c and -w are specified, satisfaction of -c will cause an exit first. 2ping-specific options: -?, --help Print a synposis and exit. -6, --ipv6 Bind/connect as IPv6. --auth=key Set a shared key, send cryptographic hashes with each packet, and require cryptographic hashes from peer packets signed with the same shared key. --auth-digest=digest When --auth is used, specify the digest type to compute the cryptographic hash. Valid options are hmac-md5 (default), hmac-sha1 and hmac-sha256. hmac-md5 requires Digest::MD5, and the SHA digests require Digest::SHA. --debug Print (lots of) debugging information. --inquire-wait=secs Wait at least secs seconds before inquiring about a lost packet. Default is 10 seconds. UDP packets can arrive delayed or out of order, so it is best to give it some time before inquiring about a lost packet. --listen Start as a listener. The listener will not send out ping requests at regular intervals, and will instead wait for the far end to initiate ping requests. A listener is required as the remote end for a client. --min-packet-size=min Set the minimum total payload size to min bytes, default 128. If the payload is smaller than min bytes, padding will be added to the end of the packet. --max-packet-size=max Set the maximum total payload size to max bytes, default 512, absolute minimum 64. If the payload is larger than max bytes, information will be rearranged and sent in future packets when possible. --no-3way Do not perform 3-way pings. Used most often when combined with --listen, as the listener is usually the one to determine whether a ping reply should become a 3-way ping. Strictly speaking, a 3-way ping is not necessary for determining directional packet loss between the client and the listener. However, the extra leg of the 3-way ping allows for extra chances to determine packet loss more efficiently. Also, with 3-way ping disabled, the listener will receive no client performance indicators, nor will the listener be able to determine directional packet loss that it detects. --no-match-packet-size When sending replies, 2ping will try to match the packet size of the received packet by adding padding if necessary, but will not exceed --max-packet-size. --no-match-packet-size disabled this behavior, always setting the minimum to --min-packet-size. --no-send-version Do not send the current running version of 2ping with each packet. --notice=text Arbitrary notice text to send with each packet. If the remote peer supports it, this may be displayed to the user. --packet-loss=out:in Simulate random packet loss outbound and inbound. For example, 25:10 means a 25% chance of not sending a packet, and a 10% chance of ignoring a received packet. A single number without colon separation means use the same percentage for both outbound and inbound. --port=port Use UDP port port. With --listen, this is the port to bind as, otherwise this is the port to send to. Default is UDP port 15998. --stats=interval Print a line of brief current statistics every interval seconds. The same line can be printed on demand by sending SIGQUIT to the 2ping process. BUGS
There are probably lots and lots and lots of unknown bugs. By default, source IP logic doesn't work as expected, see -I for details. There appears to be no way to peg the source IP of reply UDP packets to the destination of the packet that is being replied to. As a result, packets always go out the interface's main IP address if not specified manually. (Please, prove the author wrong.) This manpage isn't finished yet, and may never be. AUTHOR
2ping was written by Ryan Finnie <ryan@finnie.org>. 2012-04-22 2PING(8)
All times are GMT -4. The time now is 07:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy