Net-SNMP のようなツールはどのようにCPU 使用率をキャプチャしますか?
そして、Linux でそれを行うための最も邪魔にならない方法は何でしょうか?
そうすることで、最小限の量のマシン リソース (CPU と RAM の両方) を消費するため、邪魔になりません。最終的にデータはファイルに保存されます。
Net-SNMP のようなツールはどのようにCPU 使用率をキャプチャしますか?
そして、Linux でそれを行うための最も邪魔にならない方法は何でしょうか?
そうすることで、最小限の量のマシン リソース (CPU と RAM の両方) を消費するため、邪魔になりません。最終的にデータはファイルに保存されます。
$top コマンドを試してみましたか?
実際、ここに $top を含むメソッドのリストがあります。これらを試してみてください:)
http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
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.
これを試して:
ps -eo pcpu,pid | less
これにより、PID とともに CPU 使用率が表示されます。