To get only the cpu info from the topas command terminal

To get only the cpu info from the topas command terminal.

CPU  User%  Kern%  Wait%  Idle%  Physc   Entc   
  ALL    2.3    4.4    0.0   93.3   0.07    7.7

I tried some thing like this but did not work

topas << done
  grep "ALL"
  q
  done

Can someone help me in this.

The topas tool is a full-screen tool and its output is not well suited for filtering it in a pipeline. I suggest you use vmstat instead, which presents the same information (albeit in different form, but well suited for filtering).

I hope this helps.

bakunin

1 Like

Can you please help me to match these two outputs?

Theses were captured one after other

topas command o/p (Only CPU)

CPU  User%  Kern%  Wait%  Idle%  Physc   Entc   
ALL    3.1    4.9    0.0   92.0   0.08    9.0 

vmstat o/p

System configuration: lcpu=4 mem=4608MB ent=0.85

kthr    memory              page              faults              cpu
----- ----------- ------------------------ ------------ -----------------------
 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa    pc    ec
 1  1 447273 571345   0   0   0   9   25   0  21 3802 472  0  0 99  0  0.00   0.0

No problem. Have a look at vmstats "CPU" part:

us=user(%)
sy=system(=kernel)(%)
id=idle(%)
wa=wait(%)

ec=entitled capacity consumed

"us" is what your running programs need
"sy" are system calls and kernel internals needed to keep the system running
"id"/"wa" is what is left over. Together these 4 values add up to 100% (rounding errors notwithstanding).

The difference between "id" and "wa" is: if the processor is idle and there is an I/O operation outstanding it counts towards "wa", otherwise it counts towards "id".

Entitled capacity consumed is: compare the entitled processing power in the LPAR profile against what in reality is allocated right now and express this as a percentage. "50", for instance, means that half of what the LPAR is entitled to use is in fact used right now.

I hope this helps.

bakunin

/ps: i suggest you try the "-w" and the "-t" options of vmstat: one makes for neater columns and the other includes a time stamp for each line which makes it easier to assess.

/pps: another suggestion: vmstat always displays a summary info as the first output line (not counting headers), so disregard this first line if you want to know something about the system right now.

1 Like

Thanks a lot bakunin!

The doubt I have is in the results of the commands output.

For Instance,

Let's take the "User%" from the output of the topas command and compare it with
"us" in the vmstat command

It is 3.1 and 0 respectively. They are not matching though they gauge the same.

In the same way all the values such as Kern%,Wait%,Idle%,Physc and Entc from topas and sy,wa,id,pc &ec are not matching.

Infact the sample output's given were captured one after the other in the same server but the results seems to be not matching.

First, the first line of output of "vmstat" should always be ignored, as i said. Because you only have shown one line you should not use this output at all to base any assumption on it. IIRC it displays an average since last reboot or so, which is meaningless.

Second, the system is next to idle. Between 3.1% and 0% there is not much difference and the "load" could well change that much within one or two seconds (the time you needed to stop one and start the other process).

Third, both tools, "topas" and "vmstat" use a certain sampling interval, which is probably not the same per default. I use "topas" only rarely, so i could be wrong, but i believe the default sampling rate to be 2 sec. With "vmstat" there is no default, you have to provide a sampling rate (in secs). I usually start with 1 sec (my internal clock is counting that way) for intensive monitoring and (up to) 60 seconds for long-term observation.

Both, "topas" and "vmstat" get their data from the same OS interfaces, but because they treat these data differently they might end up displaying different values. I have never attempted to search for it, but i am sure you could find the OS calls both are using documented somewhere and you could write your own monitoring tool if you are determined enough. I always found that "vmstat" is giving me the data i need and in a form i can easily manipulate with the abundant UNIX text filters there are (grep, awk, sed, ksh, ....). This is why i myself use "vmstat" and hardly ever "topas": personal preference rather than technical reasons.

I hope this clears it up.

bakunin

1 Like