top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to get CPU utilization in Centos machine?

+2 votes
774 views

I want to run a command in every 10 minute which should return the maximum CPU utilization of a linux machine in last 10 min irrespective of no. of core present.
Thanks in advance.

posted Dec 18, 2013 by Satyabrata Mahapatra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
Process of machine????
Sorry, i am not getting.

1 Answer

0 votes
  1. You need to write a crontab which will run after every second and log the output of the following...
    a) If you want the process record ---- ps -eo pcpu,pid,user,args | sort -r -k1
    b) If you want the machine record ---- top -b -n 1|grep Cpu|cut -d " " -f 3 (looks that you want this)

  2. Keep the command in the shell script (say a.sh) and provide the permission as 777

  3. Now use the crontab and write the output to a file. Now you have per minute update going to a file.

  4. Now wite another script which will again be cron job with 10 Min frequency and -
    a) return the max of this file
    b) clean the file created in step 3.

answer Dec 18, 2013 by Salil Agrawal
Similar Questions
+2 votes

Below instruction will start CPU stress with maximum of 100%,

while(1);

Below instructions will start CPU stress with near to 0%.

while(1)
     sleep(1);

Is there any way to control this? I mean what if i want to start CPU stress of >100% and what if want to start CPU stress with particular number?

Can any one help in programming that? I am looking for C/C++/Python solution on Linux...

+3 votes

Result should be in xx.xx format (like 01.65).

...