使用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 文件保存了网卡总流量信息,通过间隔一段间隔,将入网卡与出记录加起来。减去之前就得到实际速率。

相关文章:

  • 2021-06-14
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-13
  • 2021-07-29
  • 2021-07-09
  • 2021-05-29
  • 2021-09-22
  • 2021-09-10
相关资源
相似解决方案