I am trying to find the top 10 processes which are consuming more CPU and Memory using the command
ps -Ao user,uid,comm,pid,pcpu,pmem --sort=-pcpu | head -n 10
But it's not showing the correct data as I could see for the same process the CPU% value fluctuate in top command like 10% and then 250%.
Please help to list the high CPU consumption process by considering all cores.
We cannot install any tool as its a Prod Server. To clarify, the requirement is whenever there is alert on high CPU usage on the server we are trying to capture the top 10 processes along with CPU and Memory and send it as mail. If we extract only top output at that time it may not show the usage of process across cores as it will fluctuate.
sysstat
tools might be a better choice than trying to find a need in a haystack.