当前位置: 首页>>技术教程>>正文


如何监控每个进程的带宽使用情况?

,

问题描述

我使用的是Ubuntu 14.04。我的互联网连接很慢(512 kbps)。有时我发现我没有运行的软件应该从互联网上下载任何东西,但系统监视器仍然显示正在进行一些下载。所以我认为一些隐藏的软件导致了这一点。有没有办法监控每个使用互联网的软件?

最佳解决方法

您可以使用nethogs工具监控接口上的所有流量。

networking,ubuntu

使用安装它

sudo apt-get install nethogs

现在运行它

sudo nethogs <interface name>

例如

sudo nethogs wlan0

networking,ubuntu

有关详细信息,请在安装后输入man nethogs

次佳解决方法

我更喜欢sudo netstat -tunap

vinny@vinny-Bonobo-Extreme:~$ sudo netstat -tunap 
[sudo] password for vinny: 
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8200            0.0.0.0:*               LISTEN      1160/minidlnad  
tcp        0      0 127.0.1.1:53            0.0.0.0:*               LISTEN      927/dnsmasq     
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      2543/cupsd      
tcp        0      0 192.168.2.10:58491      198.252.206.149:443     ESTABLISHED 30401/firefox   
tcp        0      0 192.168.2.10:39824      173.194.219.189:443     ESTABLISHED 30401/firefox   
tcp        0      0 192.168.2.10:58569      198.252.206.149:443     ESTABLISHED 30401/firefox   
tcp        0      0 192.168.2.10:59283      173.194.219.18:443      ESTABLISHED 30401/firefox   
tcp6       0      0 ::1:631                 :::*                    LISTEN      2543/cupsd      
tcp6       1      0 ::1:60390               ::1:631                 CLOSE_WAIT  863/cups-browsed
tcp6       1      0 ::1:34718               ::1:631                 CLOSE_WAIT  1469/plasmashell
tcp6       1      0 ::1:60391               ::1:631                 CLOSE_WAIT  863/cups-browsed
udp        0      0 0.0.0.0:1900            0.0.0.0:*                           1160/minidlnad  
udp        0      0 0.0.0.0:10097           0.0.0.0:*                           26759/dhclient  
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           759/avahi-daemon: r
udp        0      0 0.0.0.0:39609           0.0.0.0:*                           759/avahi-daemon: r
udp        0      0 192.168.2.10:57168      0.0.0.0:*                           1160/minidlnad  
udp        0      0 127.0.1.1:53            0.0.0.0:*                           927/dnsmasq     
udp        0      0 0.0.0.0:68              0.0.0.0:*                           26759/dhclient  
udp        0      0 0.0.0.0:631             0.0.0.0:*                           863/cups-browsed
udp6       0      0 :::5353                 :::*                                759/avahi-daemon: r
udp6       0      0 :::13818                :::*                                26759/dhclient  
udp6       0      0 :::39404                :::*                                759/avahi-daemon: r

甚至显示使用网络的系统散文及其名称。

但实际上并不是一台显示器,因为你继续运行它以查看输出变化。

第三种解决方法

iptraf实用程序是另一种监控流量的方法,由iptraf包提供。 sudo apt-get install iptraf安装它。

networking,ubuntu

iptraf也可以在Red Hat Linux中使用;以root身份运行yum install iptraf进行安装。

第四种方法

使用netstat sudo watch -n1 netstat -tunap稍微舒服一点

它将刷新每1s的数据

第五种方法

终端工具:netstat -tnp。 -n选项显示建立连接的数字地址(ip),-p是已建立该连接的程序,-t列出所有tcplimits到tcp连接。或者,您可以使用netstat -a > networkscan.txt将所有内容输出到txt文件中

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/1446.html,未经允许,请勿转载。