流量监控位置看哪里

使用iftop能监控所有程序占用的网络带宽,一般情况下,手动执行iftop就可查看

在linux下监控网卡流量的一个shell脚本,通过读取/proc/net/dev/中的数据

通过第3方工具获得网卡流量,这个大家一定很清楚。其实通过脚本一样可以实现效果。下面是我个人工作中整理的数据。以下是shell脚本统计网卡流量。

  •实现原理:

[chengmo@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:1068205690 1288942839    0    0    0     0          0         0 1068205690 1288942839    0    0    0     0       0          0    eth0:91581844 334143895    0    0    0     0          0 145541676 4205113078 3435231517    0    0    0     0       0          0

proc/net/dev 文件保存了网卡总流量信息,通过间隔一段间隔,将入网卡与出记录加起来。减去之前就得到实际速率。

原文地址:https://www.cnblogs.com/gaoyuechen/p/7572207.html