Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question

The top command is not the best choice for parsing data. Try to use sar instead (if not installed by default, run yum install sysstat), or iostat -c.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .