diff options
Diffstat (limited to 'common/bin/bandwidthtest')
-rwxr-xr-x | common/bin/bandwidthtest | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/bin/bandwidthtest b/common/bin/bandwidthtest new file mode 100755 index 0000000..baac413 --- /dev/null +++ b/common/bin/bandwidthtest @@ -0,0 +1,20 @@ +#!/bin/sh + +start="$(($(cat /sys/class/net/$1/statistics/rx_bytes | paste -sd '+')))" +end="$(($(cat /sys/class/net/$1/statistics/rx_bytes | paste -sd '+')))" +if [ "$2" ]; then + delay="$2" +else + delay=10 +fi + +printf "Recording bandwidth.\n" + +report() { +printf '%4dB\n' $(numfmt --to=iec $(($end - $start))) +} + +trap report SIGINT +while sleep "$delay"; do + report +done |