Created
December 16, 2018 18:08
-
-
Save andli/c2720bc425569e323925164e43f3e189 to your computer and use it in GitHub Desktop.
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/bash | |
IF=$1 | |
if [ -z "$IF" ]; then | |
IF=`ls -1 /sys/class/net/ | head -1` | |
fi | |
RXPREV=-1 | |
TXPREV=-1 | |
echo "Listening $IF..." | |
while [ 1 == 1 ] ; do | |
RX=`cat /sys/class/net/${IF}/statistics/rx_bytes` | |
TX=`cat /sys/class/net/${IF}/statistics/tx_bytes` | |
if [ $RXPREV -ne -1 ] ; then | |
let BWRX=$RX-$RXPREV | |
let BWTX=$TX-$TXPREV | |
echo "Received: $BWRX B/s Sent: $BWTX B/s" | |
fi | |
RXPREV=$RX | |
TXPREV=$TX | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment