mic*_*ula 21 networking linux debian bash iptables
iftop是查看几乎实时带宽使用情况的好工具,可以通过 source-ip source-port destination-ip 目标端口区分。
我正在使用它来查看哪个客户端的 ip 使用了最多的带宽。现在我想将输出存储在某处。
iftop 使用 ncurses 所以
iftop > log.txt
Run Code Online (Sandbox Code Playgroud)
没有按预期工作,结果文件不可读。
有没有这样的工具可用于将输出通过管道传输到文本文件?
小智 19
从iftop-1.0pre3 (2014-01-01) 开始,增加了文本输出模式。这对任何试图解析 iftop 输出的人都非常有用。
激活文本(批处理)模式的命令行选项是:
-t use text interface without ncurses
Run Code Online (Sandbox Code Playgroud)
使用文本模式时,可以使用以下选项:
-s num print one single text output afer num seconds, then quit
-L num number of lines to print
Run Code Online (Sandbox Code Playgroud)
使用该-h选项获取有关 iftop 使用的帮助。
示例用法是:
iftop -t > log.txt
iftop -t -s 180 > log.txt
Run Code Online (Sandbox Code Playgroud)
如果您希望它在后台运行 5 小时:
iftop -t -s 18000 > log.txt &
Run Code Online (Sandbox Code Playgroud)
使用job命令检查后台作业。
iptraf 可以记录这种详细程度。输出如下所示:
Wed Apr 25 23:08:42 2012; UDP; eth0; 65 bytes; from 192.168.1.20:45061 to 192.168.1.254:53
Wed Apr 25 23:08:42 2012; UDP; eth0; 133 bytes; from 192.168.1.254:53 to 192.168.1.20:45061
Wed Apr 25 23:08:43 2012; UDP; eth0; 96 bytes; from 192.168.1.21:137 to 192.168.1.20:137
Wed Apr 25 23:08:44 2012; UDP; eth0; 472 bytes; from 192.168.1.21:1900 to 239.255.255.250:1900
Wed Apr 25 23:08:47 2012; ICMP; eth0; 159 bytes; from 192.168.1.20 to 173.176.222.82; dest unrch (port)
Run Code Online (Sandbox Code Playgroud)