CPU utilization
does anyone has a script to get cpu average ?
|
Probably yes.
|
appreciate if someone provide one script to me
|
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. |
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? |
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. |
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. |