Haron_Prime

XMNetSpeed

Jul 19th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/usr/bin/env zsh
  2. while true; do
  3.     ORX=`cat /sys/class/net/enp3s0/statistics/rx_bytes`
  4.     OTX=`cat /sys/class/net/enp3s0/statistics/tx_bytes`
  5.     sleep 1
  6.     NRX=`cat /sys/class/net/enp3s0/statistics/rx_bytes`
  7.     NTX=`cat /sys/class/net/enp3s0/statistics/tx_bytes`
  8.     TRX=`echo "scale=2; ($NRX-$ORX)" | bc -l`
  9.     TTX=`echo "scale=2; ($NTX-$OTX)" | bc -l`
  10.  
  11.     if [ $TRX -gt 1048576 ]; then
  12.         RX=`echo "scale=2; ($TRX/1048576)" | bc -l`"MB/s"
  13.     elif [ $TRX -gt 1024 ]; then
  14.         RX=`echo "scale=2; ($TRX/1024)" | bc -l`"KB/s"
  15.     else
  16.         RX=$TRX"B/s"
  17.     fi
  18.  
  19.     if [ $TTX -gt 1048576 ]; then
  20.         TX=`echo "scale=2; ($TTX/1048576)" | bc -l`"MB/s"
  21.     elif [ $TTX -gt 1024 ]; then
  22.         TX=`echo "scale=2; ($TTX/1024)" | bc -l`"KB/s"
  23.     else
  24.         TX=$TTX"B/s"
  25.     fi
  26.  
  27.     echo $RX $TX
  28. done
Advertisement
Add Comment
Please, Sign In to add comment