1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-25 17:33:28 +04:00
rCore/tools/pkttop.sh

18 lines
738 B
Bash
Raw Normal View History

#!/bin/bash
# https://www.unixteacher.org/blog/linux/display-packets-per-second-on-linux/
time="1" # one second
int="enp3s0f0" # 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