Last active
October 30, 2015 19:14
-
-
Save Jcpetrucci/706949028d015e88e31d to your computer and use it in GitHub Desktop.
Plot ping response times in ASCII graph.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pingplot { | |
local destination="$1" | |
[[ -n $destination ]] || read -rp 'Ping host: ' destination; | |
results="$(mktemp)"; | |
ping "$destination" | sed -ur 's/^PING.*//;s/.*seq=([0-9]+)/\1/;s/ttl.*time=([0-9]+).*/\1/' > "$results" & | |
sleep 1 && pidof ping || { echo Something went wrong with the ping.; return 1; } | |
watch "tail -100 "$results" | gnuplot -e \"set key off; set title 'Pinging: $destination'; set terminal dumb size $((COLUMNS - 5)) 25; plot '/dev/stdin' w lp;\""; | |
kill %ping | |
rm "$results" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment