From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qc0-x231.google.com (mail-qc0-x231.google.com [IPv6:2607:f8b0:400d:c01::231]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by huchra.bufferbloat.net (Postfix) with ESMTPS id A84F721F306 for ; Sun, 2 Mar 2014 13:20:39 -0800 (PST) Received: by mail-qc0-f177.google.com with SMTP id w7so2923737qcr.8 for ; Sun, 02 Mar 2014 13:20:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=HBXv5zyMSMLSSrvbF9SVtrev/bZJh9qj7y0Wn/FZob4=; b=ZZIkWuVjpJEETPiUYoJAIssJ1BtQL7FlB52xqvAnyvfQLqpZVh9Eo+IR4Avgx1uDW0 bwlUxh4QEiFH/4Uf6O2OcYUuMPykXAoFKIKOx1Kvdxk2STMFz9Z9l+HNdn00Xn1Fx35d A3BkuCVeXhnd0jYYg+9hHDBnYRfAlP1HAHM5AxDpvVykami7j7tI3I+PBzM8cfJfL2iH MU75Vf43VBXEwKa6Zg+6X91fOo2xZeAVULKbi17JfhvuBQ1/oVzWW6K8jxqTBBtP9ZKq vXGwdQZZwp5gXfO4EkWBeyj1EnC1ynukPq2rIm6Wxn2jXztZ9oX1r3wD8dJHyjiIc0DH ruFQ== X-Received: by 10.229.66.202 with SMTP id o10mr19147205qci.7.1393795238774; Sun, 02 Mar 2014 13:20:38 -0800 (PST) Received: from [172.30.42.25] (pool-71-241-221-18.ptldme.east.myfairpoint.net. [71.241.221.18]) by mx.google.com with ESMTPSA id r40sm12603999qga.23.2014.03.02.13.20.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 13:20:38 -0800 (PST) From: Rich Brown Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: Date: Sun, 2 Mar 2014 16:20:36 -0500 To: cerowrt-devel Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) X-Mailer: Apple Mail (2.1874) Subject: [Cerowrt-devel] pingstats.sh script to measure and record latency X-BeenThere: cerowrt-devel@lists.bufferbloat.net X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development issues regarding the cerowrt test router project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Mar 2014 21:20:40 -0000 Here's the script that I used to measure the ping latency during RRUL, = Speedtest.net, and other bandwidth tests.=20 Note that this script works fine under the ash shell on CeroWrt if vis = the clean_up() function declaration as noted. Enjoy! Rich =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D #!/bin/sh # pingstats.sh - Script to start pinging a host and # produce summary of the response times after receiving a Ctl-C # Usage: sh pingstats.sh [ host name/ip to ping ] # If there is an option, it is treated as the name/address to ping # Default is gstatic.com # Copyright (c) 2014 - Rich Brown # GPLv2 # Create temp file for ping results PINGFILE=3D`mktemp /tmp/measurepings.XXXXXX` || exit 1 function clean_up { # called when Ctl-C is pressed # clean_up() { # Use this line to declare the = clean_up() function in ash, the CeroWrt shell. =09 # Process the ping times, and summarize the results # grep to keep lines that have "time=3D", then sed to isolate = the time stamps, and sort them # awk builds an array of those values, and prints first & last = (which are min, max)=20 # and computes average and the median grep "time=3D" < $PINGFILE | sed 's/^.*time=3D\([^ ]*\) ms/\1/' | = sort -n | \ awk '{ arr[NR]=3D$1; sum+=3D$1; }END \ { if (NR%2=3D=3D1) med=3Darr[(NR+1)/2]; else = med=3D(arr[NR/2]+arr[NR/2+1])/2; \ pc10=3D"-"; pc90=3D"-"; \ if (NR>=3D10) { ix=3Dint(NR/10); pc10=3Darr[ix]; = ix=3Dint(NR*9/10);pc90=3Darr[ix]; }; \ printf("\nMin: %4.3f 10pct: %4.3f Avg: %4.3f = Median: %4.3f 90pct: %4.3f Max: %4.3f Num pings: %d\n", arr[1], pc10, = sum/NR, med, pc90, arr[NR], NR ) }' # Perform program exit housekeeping # NB: Ctl-C stops the associated background ping job rm $PINGFILE exit } trap clean_up SIGHUP SIGINT SIGTERM PINGHOST=3D"gstatic.com" if [ $# -ne 0 ]; then PINGHOST=3D$1 fi ping $PINGHOST > $PINGFILE & echo "Pinging $PINGHOST... Press Ctl-C to summarize results " wait #! /bin/sh # Take file of pings time readings, compute & display min/max/avg # Found awk scripts on:=20 # http://blog.damiles.com/2008/10/awk-calculate-mean-min-and-max/ # = http://unix.stackexchange.com/questions/13731/is-there-a-way-to-get-the-mi= n-max-median-and-average-of-a-list-of-numbers-in # Found clean_up function on:=20 # http://linuxcommand.org/wss0160.php