Finding total Percentage CPU usage


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding total Percentage CPU usage
# 8  
Old 04-30-2010
MySQL

Code:
 
man vmstat

# 9  
Old 04-30-2010
Quote:
Originally Posted by jal_capri
Code:
$ vmstat
procs                      memory      swap          io     system         cpu
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 0  0      0 10982104 232072 2817792    0    0     0     0    2     2  0  0  0  0

Can you please help me understand the output above?
This output is broken. The last four numbers should sum to 100.
Can you please clarify what you are exactly looking for beyond "total percentage CPU usage" ?
# 10  
Old 04-30-2010
In most versions of "vmstat" the first line of statistics are garbage and can be discarded. On most version the output from "vmstat" with no parameters is meaningless.

All of the basic statistics commands like "sar" "mpstat" and "vmstat" take parameters from the command line for the sample period.

For example to take samples every 10 seconds for one minute:
Code:
sar 10 6
sar 10 6 | grep "Average"   #  Just show the average line

Many sites set up the "sadc" suite of statistics data collection crons to record statistics for the machine on an hour-by hour basis. This enables the full use of "sar" to provide historical analysis data which you can manipulate as you see fit. Use of trend data is much more useful in server monitoring than trying to do a spot check after there is a problem.

Really depends on what you are trying to achieve and how you will be presenting the information and the time periods involved.
# 11  
Old 04-30-2010
Quote:
Originally Posted by methyl
In most versions of "vmstat" the first line of statistics are garbage and can be discarded.
That would be a bug. All vmstat implementations I'm aware of (Unix derivatives, BSD, Gnu/Linux) document the first line to show average values since last reboot.
Quote:
On most version the output from "vmstat" with no parameters is meaningless.
ditto.
# 12  
Old 04-30-2010
I much prefer a properly set up "sar" system even thought the statistics files use disc space. I usually keep 3-months worth of raw data for rolling trend analysis.


Example of "vmstat" from a HP-UX development system: Note that the first line is garbage. The scripts which I have ported over many years ignore the first line of any "vmstat" or "iostat" output. This is not a new issue at all.

Code:
vmstat
         procs           memory                   page                          
    faults       cpu
    r     b     w      avm    free   re   at    pi   po    fr   de    sr     in     sy    cs  us sy id
    1     0     0   522676  907141   10    2     0    0     0    0     0   1168   5757   663  31 79 4231861895168


vmstat 10 6
         procs           memory                   page                          
    faults       cpu
    r     b     w      avm    free   re   at    pi   po    fr   de    sr     in     sy    cs  us sy id
    1     0     0   518736  907250   10    2     0    0     0    0     0   1168   5757   663  31 79 4232048017408
    1     0     0   515225  907224    0    0     0    0     0    0     0    976   9249   668   0  0 100
    1     0     0   520765  907224    0    0     0    0     0    0     0    984   1979   659   0  0 100
    1     0     0   520373  907224    0    0     0    0     0    0     0    986   4095   826   0  0 100
    1     0     0   523508  907224    6    0     0    0     0    0     0   1022   1590   762   0  0 100
    1     0     0   522832  907172    0    0     0    0     0    0     0    990   2188   657   0  0 100

# 13  
Old 04-30-2010
There is indeed a well known issue with implementations where 32 bit counters are still used to store these values and then overflow when the OS hasn't been rebooted for a while. I would say that's a documentation bug as this limitation should be mentioned:
Quote:
Originally Posted by hp-ux vmstat manual page
If none of these options is given, vmstat displays a one-line summary of the virtual memory activity since boot-up or since the -z option was last executed.
Even with that bug, I wouldn't expect all CPU values to be 0 like the OP sent though.
# 14  
Old 04-30-2010
Just looked at a machine which booted less than a day ago.

Code:
us sy id
0   1 99

Plausible? No. When it wasn't running a backup it was running an active database.
Ignoring the field overflow issues (which were and extreme example) I've always found the first line to be garbage.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Capture PRSTAT based on CPU usage percentage

Hi, Recently i have write a simple script to capture CPU high usage based on prstat but i found out that it did capture correctly. I need to capture the rows that contains CPU usage more than 3%. Below line which i thought will capture CPU usage based CPU column in prstat(9th parameter) which is... (3 Replies)
Discussion started by: tharmendran
3 Replies

2. Solaris

Total CPU usage on a server

hi, i am using solaris server. I want to find the total CPU usage on a server. Top command will give that result, but here that command is not working. So anyone can help me to find the total CPU usage. (2 Replies)
Discussion started by: Arasu123
2 Replies

3. UNIX for Advanced & Expert Users

Finding out total memory usage

Hi, I have a server box with 16GB ram in it, within the server box there are 3 VMs running with a total allocation of 9GB. if I add up all the numbers under memory info using vmstat I get 15.8GB so I can say it adds up to 16Gb... Is there a way to see from the command line how much memory... (2 Replies)
Discussion started by: speedhunt3r
2 Replies

4. Linux

How to calculate total CPU usage from SAR report?

Hi, I want to calculate the total cpu usage from the sar report. Say for example, Linux 2.6.24-21-generic (blade10) 09/10/2012 04:54:36 PM CPU %user %nice %system %iowait %steal %idle 04:54:37 PM all 0.00 0.00 0.00 0.00 ... (1 Reply)
Discussion started by: rohitmd
1 Replies

5. UNIX for Dummies Questions & Answers

Is total CPU usage for sar %user+%system+%iowait?

Hi all Can anyone advise/confirm whether total CPU usage when running sar is %user+%system+%iowait or is it %user+%system only? I want to confirm whether I am having a CPU-bound problem or not. This is a single-CPU VMware machine. $ sar 5 20 Linux 2.6.18-238.5.1.el5... (7 Replies)
Discussion started by: newbie_01
7 Replies

6. UNIX for Dummies Questions & Answers

Total cpu usage in percent(%)

How to determine the total percentage cpu usage of a server having 4 cpu cores(quad core)? (3 Replies)
Discussion started by: proactiveaditya
3 Replies

7. UNIX for Dummies Questions & Answers

HOWTO - Total memory and CPU usage ... without top?

Hi all, Is it possible to get total memory usage and free memory usage without top? By Googling I found for total memory usage, use vmstat, for CPU, use mpstat, for disk I/O use iostat, is this correct? Will using sar gives the same result as ALL of these three (3) commands? What about if I... (2 Replies)
Discussion started by: newbie_01
2 Replies

8. Shell Programming and Scripting

Help with bash script - Need to get CPU usage as a percentage

I'm writing a bash script to log some selections from a sensors output (core temp, mb temp, etc.) and I would also like to have the current cpu usage as a percentage. I have no idea how to go about getting it in a form that a bash script can use. For example, I would simply look in the output of... (3 Replies)
Discussion started by: graysky
3 Replies

9. UNIX for Advanced & Expert Users

Finding CPU usage by a Unix Process

Hi, I am designing a load balancer for an application. I am trying to find out the CPU usage by a specifc Unix process (PID is known). I guess I can use ps command to find that. can somebody help me in finding what exact command I should use to find? It is on AIX 5.3. Regards Asutosh (2 Replies)
Discussion started by: asutoshch
2 Replies

10. HP-UX

How to determine cpu&memory percentage usage per user

Using HP-UX v11 Need to monitor cpu and memory usage, total for system and separately for each user in command-line mode. Found out next ways to monitor total cpu usage under hp-ux: 1) vmstat, also shows free memory 2) sar -M ps -eo user,pcpu - does not work, means 'user-defined format'... (4 Replies)
Discussion started by: hp-ux-user
4 Replies
Login or Register to Ask a Question