Advertisement
Stybyk

PPSscript

Apr 17th, 2019
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. time="1"     # one second
  4. int="enp0s3"   # network interface
  5.  
  6. while true
  7.     do
  8.         txpkts_old="`cat /sys/class/net/$int/statistics/tx_packets`" # sent packets
  9.         rxpkts_old="`cat /sys/class/net/$int/statistics/tx_packets`" # recv packets
  10.             sleep $time
  11.         txpkts_new="`cat /sys/class/net/$int/statistics/tx_packets`" # sent packets
  12.                 rxpkts_new="`cat /sys/class/net/$int/statistics/tx_packets`" # recv packets
  13.         txpkts="`expr $txpkts_new - $txpkts_old`"            # evaluate expressions for sent packets
  14.         rxpkts="`expr $rxpkts_new - $rxpkts_old`"            # evaluate expressions for recv packets
  15.             echo "tx $txpkts pkts/s - rx $rxpkts pkts/ on interface $int"
  16.     done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement