Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- time="1" # one second
- int="enp0s3" # network interface
- while true
- do
- txpkts_old="`cat /sys/class/net/$int/statistics/tx_packets`" # sent packets
- rxpkts_old="`cat /sys/class/net/$int/statistics/tx_packets`" # recv packets
- sleep $time
- txpkts_new="`cat /sys/class/net/$int/statistics/tx_packets`" # sent packets
- rxpkts_new="`cat /sys/class/net/$int/statistics/tx_packets`" # recv packets
- txpkts="`expr $txpkts_new - $txpkts_old`" # evaluate expressions for sent packets
- rxpkts="`expr $rxpkts_new - $rxpkts_old`" # evaluate expressions for recv packets
- echo "tx $txpkts pkts/s - rx $rxpkts pkts/ on interface $int"
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement