Guest User

Untitled

a guest
Jan 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ -z "$1" ]; then
  4. echo
  5. echo usage: $0 network-interface
  6. echo
  7. echo e.g. $0 eth0
  8. echo
  9. exit
  10. fi
  11.  
  12. interface=$1
  13.  
  14. while true
  15. do
  16. r1=`cat /sys/class/net/$interface/statistics/rx_bytes`
  17. t1=`cat /sys/class/net/$interface/statistics/tx_bytes`
  18. sleep 1
  19. r2=`cat /sys/class/net/$interface/statistics/rx_bytes`
  20. t2=`cat /sys/class/net/$interface/statistics/tx_bytes`
  21. tbps=`expr $T2 - $T1`
  22. rbps=`expr $R2 - $R1`
  23. tkbps=`expr $tbps / 1024`
  24. rkbps=`expr $rbps / 1024`
  25. echo "tx $interface: $tkbps kb/s rx $interface: $rkbps kb/s"
  26. done
Add Comment
Please, Sign In to add comment