I need to monitor CPU usage by users of two servers' (Ubuntu and CentOS). For example:
user1 5%
user2 10%
...
Is there a tool similar to top
or htop
that can do that?
centoscpuUbuntu
I need to monitor CPU usage by users of two servers' (Ubuntu and CentOS). For example:
user1 5%
user2 10%
...
Is there a tool similar to top
or htop
that can do that?
Best Answer
Here is a script to print the total CPU usage for each user currently logged in, showPerUserCPU.sh:
And here is a slightly modified version for printing the CPU usage of all available users (but skipping the ones with a CPU usage of zero), showAllPerUserCPU.sh:
The first column represents the user name, the second column the aggregated CPU usage and the third column the normalized CPU use according to the number of CPU cores.
There is also a related script for showing the total memory usage for each user: showPerUserMem.sh
For live-monitoring just execute these scripts periodically via the
watch
command.For sorting by CPU usage, pipe the output to
sort -k2 -nr
.