Last active
August 26, 2021 11:19
-
-
Save parthpower/b4f70b85774d944a51ac03ce6d37130e to your computer and use it in GitHub Desktop.
get rate from netdev stats
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/sh | |
if [ $# -lt 1 ]; then | |
echo "Usage: $0 <ifname> [delay (s) default=10s]"; | |
exit 1; | |
fi | |
eth=$1 | |
if [ "x$2" -eq "x" ]; then | |
delay=10 | |
else | |
delay=$2 | |
fi | |
arx=$(cat /sys/class/net/$eth/statistics/rx_bytes); | |
atx=$(cat /sys/class/net/$eth/statistics/tx_bytes); | |
sleep $delay; | |
btx=$(cat /sys/class/net/$eth/statistics/tx_bytes); | |
brx=$(cat /sys/class/net/$eth/statistics/rx_bytes); | |
echo rx: $(( ($brx - $arx)/$delay/1024 )) kBps | |
echo tx: $(( ($btx - $atx)/$delay/1024 )) kBps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment