Last active
December 18, 2020 15:36
-
-
Save Rycieos/4fe47ced46ed88b231ce5d53ea623452 to your computer and use it in GitHub Desktop.
Ping flood a remote destination and log the results
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
#!/bin/bash | |
date=$(date '+%Y-%m-%dT%H:%M:%S%z') | |
data=$(ping -nfqc1000 '2606:4700:4700::1111') | |
IFS=' ' read min avg max mdev <<<"$(printf '%s' "$data" | grep rtt | sed 's|.* = \([0-9.]*\)/\([0-9.]*\)/\([0-9.]*\)/\([0-9.]*\) ms.*|\1 \2 \3 \4|')" | |
loss=$(printf '%s' "$data" | grep 'packet loss' | sed 's/.*, \([0-9.]*\)\% packet loss.*/\1/') | |
printf '{"date":"%s","min":%s,"avg":%s,"max":%s,"mdev":%s,"ploss":%s}\n' "$date" "${min:-null}" "${avg:-null}" "${max:-null}" "${mdev:-null}" "${loss:-null}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment