查看网卡流量:sar

sar(System Activity Reporter 系统活动情况报告)是目前 Linux 上最为全面的系统性能分析工具之一,可以从多方面对系统的活动进行报告,但我们一般用来监控网卡流量

[root@localhost ~]$ yum install -y sysstat    # 安装sar命令
[root@localhost ~]$ sar -q 1 5        # 查看系统负载
[root@localhost ~]$ sar -b 1 5        # 查看磁盘读写
[root@localhost ~]$ sar -n DEV 1 5    # 查看网卡流量

查看网卡流量:

[root@center /data]# sar -n DEV 1 5    # 每秒输出一次,总共输出五次                                 
Linux 2.6.32-504.1.3.el6.x86_64 (center)        01/21/2019      _x86_64_        (8 CPU)        # IFACE 具体的网卡名称
                                                                                               # rxpck/s 每秒接收的数据包的数量
11:30:08 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s    # txpck/s 每秒发送的数据包的数量
11:30:09 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00    # rxkB/s 每秒接收的字节数大小
11:30:09 AM      eth0   1432.99   3226.80    113.69   4432.38      0.00      0.00      0.00    # txkB/s 每秒发送的字节数大小
11:30:09 AM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00    # rxcmp/s 每秒接收的压缩数据包的数量
11:30:09 AM      eth2      0.00      0.00      0.00      0.00      0.00      0.00      0.00    # txcmp/s 每秒发送的压缩数据包的数量
                                                                                               # rxmcst/s 每秒接收的多播数据包的数量

sar 默认会每隔十分钟生成一个 sar 文件,以当天日期来命名,我们可以查看某一天的网卡流量:

[root@localhost ~]$ ls /var/log/sa/
sa01  sa04  sa07  sa10  sa13  sa16  sa19  sa23  sa26  sa29  sar01  sar04  sar07  sar10  sar13  sar16  sar19  sar23  sar26  sar29
sa02  sa05  sa08  sa11  sa14  sa17  sa20  sa24  sa27  sa30  sar02  sar05  sar08  sar11  sar14  sar17  sar20  sar24  sar27  sar30
sa03  sa06  sa09  sa12  sa15  sa18  sa21  sa25  sa28  sa31  sar03  sar06  sar09  sar12  sar15  sar18  sar22  sar25  sar28  sar31
[root@localhost ~]$ sar -n DEV -f /var/log/sa/sa21    # -f 指定使用哪一天的文件来查看网卡流量

 

 

 

 

 

 

 

    

posted @ 2019-01-21 11:37  孔雀东南飞  阅读(787)  评论(0编辑  收藏  举报