法1: 使用ifconfig + interface name
ex:
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0C:29:A6:F8:0D
inet addr:192.168.10.128 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fea6:f80d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:150 errors:0 dropped:0 overruns:0 frame:0 ==>看Rx
TX packets:146 errors:0 dropped:0 overruns:0 carrier:0 ==>看Tx
collisions:0 txqueuelen:1000
RX bytes:17994 (17.5 KiB) TX bytes:21413 (20.9 KiB)
Interrupt:18 Base address:0x2000
法2: 使用sys 的 statistics
ex:
cat /sys/class/net/eth0/statistics/rx_packets
(看Rx ,以packet為單位)
cat /sys/class/net/eth0/statistics/tx_packets
(看Tx ,以packet為單位)
cat /sys/class/net/eth0/statistics/rx_bytes
(看Rx ,以byte為單位)
cat /sys/class/net/eth0/statistics/tx_bytes
(看Rx ,以byte為單位)
法3: 利用/proc/net/dev
cat /proc/net/dev 可以check所有interface的traffic
ex:
[root@localhost ~]# cat /proc/net/dev
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 560 8 0 0 0 0 0 0 560 8 0 0 0 0 0 0
eth0: 35898 360 0 0 0 0 0 0 36441 284 0 0 0 0 0 0
[root@localhost ~]#