I would like to monitor one process's memory / cpu usage in real time. Similar to top but targeted at only one process, preferably with a history graph of some sort.
|
|
|||||||||
|
|
On Linux,
This is also available on Mac OS X with a different syntax:
|
|||||||||||||||||||||
|
|
Among all of the features, the manpage says you can press F to follow a process. Really, you should try Display a single process:
|
|||||||||||||||||||||
|
|
I normally use following two :
|
|||||
|
|
To use that information on a script you can do this: calcPercCpu.sh
use like: For the specified $nPid, it will measure the average of 10 snapshots of the cpu usage in a whole of 1 second (delay of 0.1s each * nTimes=10); that provides a good and fast accurate result of what is happening in the very moment. Tweak the variables to your needs. |
|||
|
|
|
If you know process name you can use
|
|||||
|
|
Launch a program and monitor it This form is useful if you want to benchmark an executable easily:
Now when you hit Ctrl + C it exits the program and stops monitoring. Sample output:
Tested on Ubuntu 16.04. |
|||
|
|
|
If you need the averages for a period of time of a specific process, try the accumulative -c option of top:
"-c a" found in top for Mac 10.8.5. For Scientific Linux, the option is -S, that can be set interactively. |
|||||||||
|
|
If you have a cut-down Linux distribution where top does not have per process (-p) option or related options, you can parse the output of the top command for your process name to get the CPU usage information per process.
8 represents the CPU usage per process in the output of the top command in my embedded Linux distribution |
||||
|
|
psrecordThe following addresses history graph of some sort. Python
For single process it's the following (stopped by Ctrl+C):
For several processes the following script is helpful to synchronise the charts:
sysdig
|
|||
|
|
