Operating System - HP-UX
1833894 Members
1903 Online
110063 Solutions
New Discussion

Inerpretaion of an output from top command

 
Greg Melnik
New Member

Inerpretaion of an output from top command

I have problem with output of a top command.

Unfortunately man pages do not give definition of %CPU nor explain how it was weighted for %WCPU. So far I can not find answer anywhere.

The seems to become even worse because numbers for the LOAD part do not correspond with %CPU or %WCPU for the process. You can see from example from the similar conversation at this forum and I have similar data that average IDLE load is 99.8, while, if you add %CPU, the result is 1.96% or 0.49% as an average between 4 CPUs.

Based on output it seems that top reports utilization by CPU for multi-processors system.

Does anybody have a good idea?

Thanks, Greg
6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: Inerpretaion of an output from top command

>You can see from example from the similar conversation at this forum

Rather than make us hunt for it, why not provide a link?
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1223591

You are reading too much into the output of top (and too trusting :-). If you want accuracy you should be using glance.

Note since a process could migrate over multiple CPUs, the process info may not add up for a specific CPU. Also if using threads, it could be included in multiple loads.
YAQUB_1
Respected Contributor

Re: Inerpretaion of an output from top command

Hi,

CPU = Processor number on which the process is
executing (only on multi-processor
systems).

TTY = Terminal interface used by the process.

PID = Process ID number.

PSET = ID of the processor set to which the
processor belongs.This is shown only when -P option is used.

PRI = Current priority of the process

NI = Nice value ranging from -20 to +20

SIZE = Total size of the process in kilobytes.This includes text, data, and stack.

RES = Resident size of the process in kilobytes.The resident size information is, at best,an approximate value.

STATE = Current state of the process. The various states are sleep, wait, run, idl, zomb, orstop.

%WCPU = Weighted CPU (central processing unit) percentage.

%CPU = Raw CPU percentage. This field is used to sort the top processes.

BR/
Yaqub
Bill Hassell
Honored Contributor

Re: Inerpretaion of an output from top command

uptime and top report a load value -- it is not what you think it is. It is the average depth of the kernel runqueue, that is, the number of programs that are running or ready to run. A single compute-bound process makes the runqueue full so it reads: 1.0 but if you start another copy (and they perform no I/O), then the load rises to 2.0. NOTE: The CPU is not working twice as hard, it is running 100% with the total time split between two programs.

If you extrapolate this metric to a multi-CPU system, say an 8-CPU system, then a load of 8.0 is 8 separate programs consuming 100% of one CPU. A load of 16 would be 16 programs running or waiting to run. Note also that compute-bound programs will context switch several times per second which makes the processes appear to be running at the same time.

It is not unusual in sime situations to a load value 3 to 5 times larger than the number of CPUs. This is often seen with service programs such a daemons that may run dozens of times per second. They run for a very short time but during that time they will consume 100% CPU. Now comes the problem in measuring CPU usage over very long periods of time (like one second which is a long time for the kernel). Context switching can occur 10 times per second so a lot can happen in just a second of time.

top is a legacy application and uses very crude methods to report usage. That's why you need Glance for accurate (and extensive) metrics. top just reports CPU time, not a complete picture at all.


Bill Hassell, sysadmin
Greg Melnik
New Member

Re: Inerpretaion of an output from top command

Thanks everyone!

Dennis, I am sorry I did not provide a link.

Yaqub, I did not mean that I did not read man pages, rather I wanted to say man pages did not provide much info. For example regarding %WCPU instead of explaining what CPU is it would be better state how it was weighted. and what exactly Raw CPU percentage is. I could guess from output that it is by individual CPU, but for commercial product they could provide full description.

Bill, I was clearly unclear in my question and did not make a point that I am trying to estimate resource CPU utilization by process, something I could not get straight enough from "ps".

I wanted to find if %CPU is actually percent of CPU spent on particular process on this CPU during measurement interval. We are using somewhat similar measurement from sar, but sar combine processes together based on if it either user or system processes.

My concern was and still is as following. If %CPU is percentage of CPU time (on particular CPU in multi-processor system) spent on process, the sum of this measurements for all process divided on number of CPUs should be approximately the same as 100% - average IDLE, as reported in the beginning of top output.

If you check data in Sajjar Sahir post at http://forums12.itrc.hp.com/service/forums/questionanswer.do?threadId=1223591&admit=109447627+1215100789352+28353475 you will see it does not match. It also should match similar results from sar. I compared fields in my system's output and compared it with sar output taken in parallel and results are inconclusive.

So my question is what %CPU in top's output really represents and how reliable it is?

About universal suggestion to use glance. I could not find glance on my system. I tried to run glance from the terminal prompt and got "# glance
sh: glance: not found."

I also tried to find it by name from the root directory and find did not come back with anything.

Thanks, Greg
Bill Hassell
Honored Contributor

Re: Inerpretaion of an output from top command

Glance is a priced product so you'll have to buy it from HP. It is well worth it considering the huge amount of time (and knowledge) you'll need to write your own utilities to monitor programs and kernel activities. With glance, you can sort by CPU usage or by disk activity (not possible with top) and inspect any selected process while it is running to see the open files and r/w activity.


Bill Hassell, sysadmin