a powerful tool for viewing network port traffic in Linux--SAR There is a small tool that allows you to view IP packet traffic statistics for each network port.
With the SAR command, plus the-n dev parameter, you can count the traffic on all network cards, in the fifth and sixth columns shown, the data traffic received and the data sent, in units of kb/s, that is, the number of kilobytes per second. The following 1 2 refers to the report every 1 seconds, a total of 2 times reported.
# Sar-n DEV 1 2
Linux 2.6.32.59-0.7-default (vmcie) 04/02/14 _x86_64_
21:12:47 IFACE rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s
21:12:48 lo 147.47 147.47 27.76 27.76 0.00 0.00 0.00
21:12:48 eth0 14.14 1.01 1.38 0.05 0.00 0.00 0.00
21:12:48 eth1 17.17 5.05 3.35 3.20 0.00 0.00 0.00
21:12:48 IFACE rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s
21:12:49 lo 128.71 128.71 25.19 25.19 0.00 0.00 0.00
21:12:49 eth0 18.81 0.99 2.47 0.05 0.00 0.00 0.00
21:12:49 eth1 21.78 4.95 2.94 1.23 0.00 0.00 0.00
Average:iface rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s
Average:lo 138.00 138.00 26.46 26.46 0.00 0.00 0.00
Average:eth0 16.50 1.00 1.93 0.05 0.00 0.00 0.00
Average:eth1 19.50 5.00 3.15 2.21 0.00 0.00 0.00
If you want to see only the traffic for a certain network card, you can filter it with Sar-n DEV 1 2|grep eth0 .
# sar-n DEV 1 2|grep eth0
21:15:35 eth0 17.00 0.00 1.03 0.00 0.00 0.00 0.00
21:15:36 eth0 23.76 0.00 2.09 0.00 0.00 0.00 0.00
average: eth0 20.40 0.00 1.56 0.00 0.00 0.00 0.00
From for notes (Wiz)
A powerful tool for viewing network port traffic in Linux--SAR