1
I am trying to monitor my CentOS processes using top command to see if there are any processes where CPU usage is greater than X%, below is the command I am using to see if any processes CPU usage is greater than 10%.
top | awk '{if (NF == 14) {
if ( int($10) >= 10 ) { print $0; system("ps -ef | grep " $13); }
}}' >> top.txt
It seems like the above command will miss some results. While the above command is running, I open another session and execute top command. I have noticed that sometimes when I saw some processes CPU usage are greater than 10%, but the results are not captured via the command above.
Not sure if there are better ways, or I the above script is wrong.
Many thanks!