天天看點

Linux使用sar指令檢視網絡IO、網卡流量、實時網速

指令:

sar –n DEV 1 4
           

解釋:

sar - Collect, report, or save system activity information.

sar,收集、報告或儲存系統活動資訊

-n,Report network statistics.

Possible keywords are DEV, EDEV, NFS, NFSD, SOCK, IP, EIP, ICMP, EICMP, TCP,

ETCP, UDP, SOCK6, IP6, EIP6, ICMP6, EICMP6 and UDP6.

With the DEV keyword, statistics from the network devices are reported.

-n DEV,報告網絡裝置統計資訊,參數還可以是EDEV, NFS, NFSD, SOCK, IP, EIP, ICMP, EICMP, TCP, ETCP, UDP, SOCK6, IP6, EIP6, ICMP6, EICMP6 and UDP6

1 4,每一秒鐘取一次值,取四次

執行結果:

11:45:36 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
11:45:37 AM      eth0      0.99      0.99      0.05      0.10      0.00      0.00      0.00
11:45:37 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:45:37 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
11:45:38 AM      eth0      1.01      1.01      0.05      0.20      0.00      0.00      0.00
11:45:38 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:45:38 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
11:45:39 AM      eth0      1.01      1.01      0.05      0.39      0.00      0.00      0.00
11:45:39 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:45:39 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
11:45:40 AM      eth0      1.01      1.01      0.05      0.39      0.00      0.00      0.00
11:45:40 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
Average:         eth0      1.01      1.01      0.05      0.27      0.00      0.00      0.00
Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
           

輸出資訊說明:

  • IFACE:LAN接口
  • rxpck/s:每秒鐘接收的資料包
  • txpck/s:每秒鐘發送的資料包
  • rxbyt/s:每秒鐘接收的位元組數
  • txbyt/s:每秒鐘發送的位元組數
  • rxcmp/s:每秒鐘接收的壓縮資料包
  • txcmp/s:每秒鐘發送的壓縮資料包
  • rxmcst/s:每秒鐘接收的多點傳播資料包

繼續閱讀