答案1
vnstat -l
做你需要的事情
只需打开一个终端窗口并输入vnstat -l
。然后启动消耗网络带宽的程序。当程序结束时返回终端窗口并按Ctrl+ C。然后终端将显示已用时间和消耗的网络流量:
$ vnstat -l
Monitoring enp59s0... (press CTRL-C to stop)
rx: 1.74 Mbit/s 149 p/s tx: 32 kbit/s 62 p/s^C
enp59s0 / traffic statistics
rx | tx
--------------------------------------+------------------
bytes 7.40 MiB | 142 KiB
--------------------------------------+------------------
max 1.84 Mbit/s | 35 kbit/s
average 1.68 Mbit/s | 31.53 kbit/s
min 1.51 Mbit/s | 29 kbit/s
--------------------------------------+------------------
packets 5215 | 2187
--------------------------------------+------------------
max 157 p/s | 68 p/s
average 144 p/s | 60 p/s
min 129 p/s | 55 p/s
--------------------------------------+------------------
time 36 seconds