在日志文件中捕获nethogs输出

时间:2021-03-03 13:56:04

I want to check the network bandwidth used by my process. For this i found that nethogs tool is useful. Using this tool i can see which process is eating up a network bandwidth and process behaviour. But how do I capture data from nethogs for a my process and store it into log file ?

我想检查我的进程使用的网络带宽。为此我发现nethogs工具很有用。使用此工具,我可以看到哪个进程占用了网络带宽和进程行为。但是如何从我的进程的nethogs中捕获数据并将其存储到日志文件中?

3 个解决方案

#1


0  

You can try this command to capture output:

您可以尝试使用此命令捕获输出:

nethogs -d 5 | sed 's/[^[:print:][:cntrl:]]//g' > output.txt

#2


2  

I dont know when these options got implemented but you can use nethogs -t or nethogs -b, the pid and user are strangely placed at the end of the pid command string, but easy enough to parse.

我不知道这些选项何时实现,但你可以使用nethogs -t或nethogs -b,pid和用户奇怪地放在pid命令字符串的末尾,但很容易解析。

I think you need to use the latest cvs version 0.8.1-SNAPSHOT

我想你需要使用最新的cvs版本0.8.1-SNAPSHOT

#3


1  

The right command of nethogs is

nethogs的正确命令是

 nethogs -d 1 eth0 > output.txt

You need to specify the network interface otherwise, the default interface eth0 will be used. Sometime, nethogs might not show the proper output because of the network interface. It is always better to provide the network interface and generate some traffic during the experimentation. You can print the output to a file by adding > output.txt -d argument specifies how frequently the output will be shown. Here, I gave 1, this indicates that the output will be shown per second.

您需要指定网络接口,否则将使用默认接口eth0。有时,由于网络接口,nethogs可能无法显示正确的输出。在实验过程中提供网络接口并生成一些流量总是更好。您可以通过添加> output.txt将输出打印到文件。-d参数指定输出显示的频率。在这里,我给了1,这表明输出将每秒显示。

Hope this might be useful.

希望这可能有用。

#1


0  

You can try this command to capture output:

您可以尝试使用此命令捕获输出:

nethogs -d 5 | sed 's/[^[:print:][:cntrl:]]//g' > output.txt

#2


2  

I dont know when these options got implemented but you can use nethogs -t or nethogs -b, the pid and user are strangely placed at the end of the pid command string, but easy enough to parse.

我不知道这些选项何时实现,但你可以使用nethogs -t或nethogs -b,pid和用户奇怪地放在pid命令字符串的末尾,但很容易解析。

I think you need to use the latest cvs version 0.8.1-SNAPSHOT

我想你需要使用最新的cvs版本0.8.1-SNAPSHOT

#3


1  

The right command of nethogs is

nethogs的正确命令是

 nethogs -d 1 eth0 > output.txt

You need to specify the network interface otherwise, the default interface eth0 will be used. Sometime, nethogs might not show the proper output because of the network interface. It is always better to provide the network interface and generate some traffic during the experimentation. You can print the output to a file by adding > output.txt -d argument specifies how frequently the output will be shown. Here, I gave 1, this indicates that the output will be shown per second.

您需要指定网络接口,否则将使用默认接口eth0。有时,由于网络接口,nethogs可能无法显示正确的输出。在实验过程中提供网络接口并生成一些流量总是更好。您可以通过添加> output.txt将输出打印到文件。-d参数指定输出显示的频率。在这里,我给了1,这表明输出将每秒显示。

Hope this might be useful.

希望这可能有用。

相关文章