Skip to content

Instantly share code, notes, and snippets.

@marcobazzani
Last active August 18, 2017 17:33
Show Gist options
  • Save marcobazzani/c200da3de3e6e8b33c2ca7952b5137d1 to your computer and use it in GitHub Desktop.
Save marcobazzani/c200da3de3e6e8b33c2ca7952b5137d1 to your computer and use it in GitHub Desktop.
rx speed all networks
#!/usr/bin/env bash
for a in `ls -1 /sys/class/net/`
do
declare pre_${a}_rxbytes=`cat /sys/class/net/$a/statistics/rx_bytes`
declare pre_${a}_txbytes=`cat /sys/class/net/$a/statistics/tx_bytes`
done
while true
do
sleep 1
for a in pppoe0
do
declare post_${a}_rxbytes=`cat /sys/class/net/$a/statistics/rx_bytes`
declare post_${a}_txbytes=`cat /sys/class/net/$a/statistics/tx_bytes`
echo speed $a Down: $[ (post_${a}_rxbytes - pre_${a}_rxbytes)*8/1024/1024 ] Up: $[ (post_${a}_txbytes - pre_${a}_txbytes)*8/1024/1024 ]
declare pre_${a}_rxbytes=`cat /sys/class/net/$a/statistics/rx_bytes`
declare pre_${a}_txbytes=`cat /sys/class/net/$a/statistics/tx_bytes`
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment