Hi,

Discussion last night included spotting if one's connection to the
Internet suffered problems overnight.  The conclusion was a simple
script to log data for later inspection with journalctl(1) was probably
good enough.  Attached is such a bash script.  I haven't run it as I'm
in a hurry today, so bugs are left as an exercise to the reader to
discover.  :-)

mtr(1) was also mentioned, e.g. `mtr -i3 8.8.4.4'.

-- 
Cheers, Ralph.
#! /bin/bash

progname=${0##*/}
peer=8.8.8.8 # Google's Public DNS server.
wait=3 # Seconds to wait for pong.
breather=61 # Seconds between pings to avoid taxing $peer.

today=$(date +%d) # Stop at the end of the day.
lastr=start
let sent=0 changes=0
while true; do
    # ping(1)'s -w ignores -c and a timeout doesn't affect exit(2),
    # so use timeout(1).
    timeout $wait ping -qc1 $peer >/dev/null
    r=$?
    let sent++

    if [[ $r != $lastr ]]; then
        echo logger -t $progname $peer: transition: $lastr to $r
        lastr=$r
        let changes++
    fi

    [[ $(date +%d) == $today ]] || break

    sleep $breather
done

echo $progname: sent: $sent changes: $changes
--
  Next meeting: BEC, Bournemouth, Tuesday, 2019-03-05 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk/
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to