How is CPU Usage Calculated by processes Probe?

Document ID : KB000034596
Show Technical Document Details

Question:

How is CPU Usage Calculated by processes Probe?

%cpu in ps command is calculated differently by the processes probe for different operating systems:

Linux- CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage

HPUX- The percentage of CPU time used by this process during the last scheduling interval.

Free BSD- The CPU utilization of the process; this is a decaying average over up to a minute of previous (real) time. Since the time base over which this is computed varies (since processes may be very young) it is possible for the sum of all %cpu fields to exceed 100%.

AIX- The percentage of time the process has used the CPU since the process started. This value is computed by dividing the time the process uses the CPU by the elapsed time of the process. In a multi-processor environment, the value is further divided by the number of available CPUs because several threads in the same process can run on different CPUs at the same time. (Because the time base over which this data is computed varies, the sum of all %CPU fields can exceed 100%.)

Source- man page of ps command on AIX:

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds4/ps.htm

From monitoring perspective, %CPU should depict current CPU usage and not the total of when process was started. Keeping in mind the vast difference in calculation of %cpu among different OS’es, the process Probe calculates %cpu (rather than pick %cpu from ps command) as follows:

%CPU= ((Delta of CPU used by process) * 100)/((Delta of Total Time of Process)* Number of processor)

where delta is difference between current and last sample.

This is essentially the same as process probe computes %cpu except for one difference: in "ps" command the value of processor and CPU time is the time since the process started whereas in the process probe the processor and CPU time is delta of last and current sample.

So
%CPU reported by OS and %CPU reported by processes probe can differ. For example...

%CPU (Process probe) = %CPU(ps command for Linux)/Number of processor

So, when Linux shows 75%. Process probe will show 75/Number of Processor value.