1

Net-SNMP のようなツールはどのようにCPU 使用率をキャプチャしますか?

そして、Linux でそれを行うための最も邪魔にならない方法は何でしょうか?

そうすることで、最小限の量のマシン リソース (CPU と RAM の両方) を消費するため、邪魔になりません。最終的にデータはファイルに保存されます。

4

3 に答える 3

4

$top コマンドを試してみましたか?

実際、ここに $top を含むメソッドのリストがあります。これらを試してみてください:)

http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html

于 2012-08-23T14:29:31.367 に答える
4

There is no other way to calculate the current CPU utilization than reading /proc except for the kernel itself. All common tools like ps, top etc. are also just reading /proc, either /proc/stat for an overall CPU usage or /proc/<pid>/stat for a per-process CPU usage. However as /proc is a virtual file system directly provided by the kernel the overhead for reading files in it is way smaller than for regular files.

If you don't want to read /proc yourself try to use a tool that does only little extra computations, like ps as mentioned by @deep.

于 2012-08-24T14:31:04.420 に答える
2

これを試して:

ps -eo pcpu,pid | less

これにより、PID とともに CPU 使用率が表示されます。

于 2012-08-23T14:57:52.243 に答える