Skip to content

Instantly share code, notes, and snippets.

@steren
Last active January 10, 2016 16:06
Show Gist options
  • Save steren/5585b54bb9e6b403a955 to your computer and use it in GitHub Desktop.
Save steren/5585b54bb9e6b403a955 to your computer and use it in GitHub Desktop.
ping every 30 sec and store result in a file, used to diagnose internet connection
#!/bin/bash
FILE=$(echo pingstats-$(date '+%Y-%m-%d-%H-%M').csv)
echo "datetime,min,avg,max,stddev" > ${FILE}
while true
do
NOW=$(date -u +"%Y-%m-%d %H:%M:%S")
# retrieve data from ping: min,avg,max,stddev
VALUES=$(ping -c 4 steren.fr | tail -1 | awk '{print $4}' | sed 's/\//,/g')
echo "${NOW},${VALUES}" >> ${FILE}
sleep 30
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment