summaryrefslogtreecommitdiff
path: root/common/bin/bandwidthtest
diff options
context:
space:
mode:
authorSimon Parri <simonparri@ganzeria.com>2025-07-22 00:56:22 +0200
committerSimon Parri <simonparri@ganzeria.com>2025-07-22 11:49:01 +0200
commitd2c331b9f036951eef062dd5141c75182375ba12 (patch)
tree325bf3c56b70ec845e8de9349f45408ed844e747 /common/bin/bandwidthtest
downloaddotfiles-d2c331b9f036951eef062dd5141c75182375ba12.tar.gz
dotfiles-d2c331b9f036951eef062dd5141c75182375ba12.zip
Add current configuration
Diffstat (limited to 'common/bin/bandwidthtest')
-rwxr-xr-xcommon/bin/bandwidthtest20
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