今天在服務器上進行測試程序,發現網速占用比較大,但不是我的程序。可能是其他同學在下載或者上傳數據,所以需要看到底是哪個進程。
這時候使用 iftop, vnstat 等命令不能看出具體是哪個進程占用,因為它們常用來統計和監控網卡流量。通過搜索發現,NetHogs 可以滿足我的需求;
具體界面如下:
下面簡要記錄一些程序相關的信息,方便之后回顧。
安裝:
apt install nethogs
程序說明:(其中有一些可以交互的操作)
NAME
nethogs - Net top tool grouping bandwidth per process
SYNOPSIS
nethogs [-h] [-V] [-d] [-v] [-t] [-c] [-p] [-s] [device(s)]
DESCRIPTION
NetHogs is a small 'net top' tool. Instead of breaking the traffic down per protocol or per subnet,
like most such tools do, it groups bandwidth by process - and does not rely on a special kernel module to be loaded.
So if there's suddenly a lot of network traffic, you can fire up NetHogs and immediately see which PID is causing this,
and if it's some kind of spinning process, kill it.
Options
-h display available commands usage.
-V prints Version info.
-d delay for refresh rate.
-v select view mode
-p sniff in promiscious mode (not recommended).
-t tracemode.
-c limit number of refreshes
-s sort by traffic sent
device(s) to monitor. By default eth0 is being used.
INTERACTIVE CONTROL
m cycle between display modes (kb/s, kb, b, mb)
r sort by 'received'
s sort by 'sent'
q quit
SEE ALSO
netstat(8) tcpdump(1) pcap(3)
之前寫過的關於網絡監控工具的文章,可以參考:
slurm 網路監控軟件使用:https://www.cnblogs.com/xuyaowen/p/linux-slurm.html
觀察網絡流量的工具-iptraf-ng:https://www.cnblogs.com/xuyaowen/p/linux-iptraf.html
netperf 網絡測試工具:https://www.cnblogs.com/xuyaowen/p/netperf.html
iperf 一個測試網絡吞吐的工具:https://www.cnblogs.com/xuyaowen/p/iperf-for-network.html
保持更新;cnblogs.com/xuyaowen