LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   CPU utilization (https://www.linuxquestions.org/questions/programming-9/cpu-utilization-693989/)

scbops 12-30-2008 11:57 PM

CPU utilization
 
does anyone has a script to get cpu average ?

Hko 12-31-2008 05:46 AM

Probably yes.

scbops 12-31-2008 06:16 AM

appreciate if someone provide one script to me

wje_lq 12-31-2008 06:36 AM

Most of us are busy with our own projects, so we're not likely to actually write scripts for you, but if you have a specific question about the behavior of a script you've already written, here's the place to ask it!

In the meantime, these aren't exactly scripts, but for a start, go here.

scbops 12-31-2008 08:00 AM

top - 19:37:42 up 14 days, 9:17, 6 users, load average: 0.00, 0.00, 0.00
Tasks: 91 total, 1 running, 90 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.2% us, 0.4% sy, 0.0% ni, 94.5% id, 1.7% wa, 0.1% hi, 0.0% si
Mem: 1555972k total, 949324k used, 606648k free, 92004k buffers
Swap: 2031608k total, 160k used, 2031448k free, 627112k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13754 root 16 0 1948 832 652 R 3.9 0.1 0:00.02 top
1 root 16 0 3568 560 480 S 0.0 0.0 0:02.25 init



This the output of top command, as you can see there are seven outputs in cpu(s) row, how can I get CPU% as one value?

wje_lq 12-31-2008 08:49 AM

Those numbers add up to 99.9%. You can pretty well predict that the "one value" will always be very, very close to 100.0%. That makes your initial problem very, very simple, if I understand it correctly.

But if you want the sum of only some of those, use sed to isolate the numbers you want.

jiml8 12-31-2008 06:43 PM

I'll give you a hint. 94.5% id means 94.5 percent IDLE.


All times are GMT -5. The time now is 10:32 AM.