mirror of
https://github.com/prurigro/darkcloud-tmuxconfig.git
synced 2024-12-28 19:34:34 -05:00
28 lines
530 B
Text
28 lines
530 B
Text
|
#!/usr/bin/env bash
|
||
|
|
||
|
TIMESPAN=1
|
||
|
|
||
|
if [ -z $1 ]; then
|
||
|
echo "Error: no device specified"
|
||
|
exit 1
|
||
|
fi
|
||
|
if [ ! -d /sys/class/net/$1 ]; then
|
||
|
echo "No such device: $1"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
BR1=`cat /sys/class/net/$1/statistics/rx_bytes`
|
||
|
BT1=`cat /sys/class/net/$1/statistics/tx_bytes`
|
||
|
|
||
|
sleep $TIMESPAN
|
||
|
|
||
|
BR2=`cat /sys/class/net/$1/statistics/rx_bytes`
|
||
|
BT2=`cat /sys/class/net/$1/statistics/tx_bytes`
|
||
|
|
||
|
DOWNKB=$(((($BR2-$BR1) / $TIMESPAN) /1024))
|
||
|
UPKB=$(((($BT2-$BT1) / $TIMESPAN) /1024))
|
||
|
|
||
|
echo "D ${DOWNKB}KB/s | U ${UPKB}KB/s"
|
||
|
|
||
|
exit 0
|