Computing.Net > Forums > Unix > CPU usage calculation

CPU usage calculation

Reply to Message Icon

Original Message
Name: Kwang
Date: July 25, 2002 at 21:02:56 Pacific
Subject: CPU usage calculation
Comment:

Hi all
I need to create a shell script to list out only the average of CPU usage for a particular period, and direct it to the file. But when I used "top > top.lis" this output file is in a mesh, how can I extract only the CPU usage at a particular moment? Thanks for help?
Best Regards
Kwang


Report Offensive Message For Removal


Response Number 1
Name: Frank
Date: July 29, 2002 at 01:08:04 Pacific
Subject: CPU usage calculation
Reply: (edit)

Kwang,

which OS you are using ?
try e.g.
"iostat -t 10 10 >> /tmp/average.txt"

This will show the overall CPU stat.

Or are you more interested in a special proccess?

No RISK no fun
Frank


Report Offensive Follow Up For Removal

Response Number 2
Name: ramesh
Date: July 30, 2002 at 01:32:44 Pacific
Subject: CPU usage calculation
Reply: (edit)

hi, try this one it shows the top 10 process cpu useage and memory usage good luck

while [ 1 ]
do
tput clear
ps -efa -o pcpu= -o vsz= -o args= | grep -v "2 87" | sort -n -r -k 1 | a
wk 'BEGIN {print "CPU% MEM(Kb) PROCESS";pr-----"}
NR <= 10'
sleep 2
done


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: CPU usage calculation

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software