root@Dev[09:41:51]$ ll /sys/class/net/eth0/statistics total 0 -r--r--r-- 1 root root 4096 Jun 29 14:59 collisions -r--r--r-- 1 root root 4096 Jun 29 14:59 multicast -r--r--r-- 1 root root 4096 Jun 29 14:47 rx_bytes -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_compressed -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_crc_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_dropped -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_fifo_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_frame_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_length_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_missed_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_nohandler -r--r--r-- 1 root root 4096 Jun 29 14:59 rx_over_errors -r--r--r-- 1 root root 4096 Jun 29 14:44 rx_packets -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_aborted_errors -r--r--r-- 1 root root 4096 Jun 29 14:47 tx_bytes -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_carrier_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_compressed -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_dropped -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_fifo_errors -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_heartbeat_errors -r--r--r-- 1 root root 4096 Jun 29 14:44 tx_packets -r--r--r-- 1 root root 4096 Jun 29 14:59 tx_window_errors root@Dev[09:48:12]$
#!/bin/bash
INTERVAL="1" # update interval in seconds
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
echo
echo shows packets-per-second
exit
fi
while true
do
R1=`cat /sys/class/net/$1/statistics/rx_packets`
T1=`cat /sys/class/net/$1/statistics/tx_packets`
sleep $INTERVAL
R2=`cat /sys/class/net/$1/statistics/rx_packets`
T2=`cat /sys/class/net/$1/statistics/tx_packets`
TXPPS=`expr $T2 - $T1`
RXPPS=`expr $R2 - $R1`
echo "TX $1: $TXPPS pkts/s RX $1: $RXPPS pkts/s"
done
#!/bin/bash
INTERVAL="1" # update interval in seconds
if [ -z "$1" ]; then
echo
echo usage: $0 [network-interface]
echo
echo e.g. $0 eth0
echo
exit
fi
while true
do
R1=`cat /sys/class/net/$1/statistics/rx_bytes`
T1=`cat /sys/class/net/$1/statistics/tx_bytes`
sleep $INTERVAL
R2=`cat /sys/class/net/$1/statistics/rx_bytes`
T2=`cat /sys/class/net/$1/statistics/tx_bytes`
TBPS=`expr $T2 - $T1`
RBPS=`expr $R2 - $R1`
TKBPS=`expr $TBPS / 1024`
RKBPS=`expr $RBPS / 1024`
echo "TX $1: $TKBPS kB/s RX $1: $RKBPS kB/s"
done
原文:https://www.cnblogs.com/standby/p/13212078.html