blob: baac413d5fca4e7e2fcfe7876ea0bf335400ad7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
|