Need to grep two lines from the topas command through a Korn Script


 
Thread Tools Search this Thread
Operating Systems AIX Need to grep two lines from the topas command through a Korn Script
# 1  
Old 01-29-2014
Lightbulb Need to grep two lines from the topas command through a Korn Script

I need to grep two lines from topas command in one of my AIX server.


Code:
Topas Monitor for host:    semas001             EVENTS/QUEUES    FILE/TTY
Wed Jan 29 10:12:06 2014   Interval:  2         Cswitch     764  Readch  4473.1K
                                                Syscall    5166  Writech  122.4K
CPU  User%  Kern%  Wait%  Idle%  Physc   Entc   Reads      1181  Rawin         0
ALL   15.5    4.6    0.2   79.6   0.18   21.7   Writes       24  Ttyout      466
                                                Forks         1  Igets         0
Network  KBPS   I-Pack  O-Pack   KB-In  KB-Out  Execs         1  Namei       756
en0      54.3    172.2   152.2    21.8    32.4  Runqueue    0.5  Dirblk        0
en1      11.6     11.0     0.0    11.6     0.0  Waitqueue   0.0
lo0       2.3      2.0     2.0     1.1     1.1
                                                PAGING           MEMORY
Disk    Busy%     KBPS     TPS KB-Read KB-Writ  Faults      338  Real,MB    4608
hdisk34   1.0   240.3     12.0   20.2   120.2   Steals        0  % Comp     46
hdisk35   0.0    22.5      3.0   22.5     0.0   PgspIn        0  % Noncomp  51
hdisk24   0.0     0.0      0.0    0.0     0.0   PgspOut       0  % Client   51
hdisk25   0.0     0.0      0.0    0.0     0.0   PageIn        0
hdisk26   0.0     0.0      0.0    0.0     0.0   PageOut       0  PAGING SPACE
hdisk27   0.0     0.0      0.0    0.0     0.0   Sios          0  Size,MB    4096
hdisk22   0.0     0.0      0.0    0.0     0.0                    % Used      0
hdisk20   0.0     0.0      0.0    0.0     0.0   NFS (calls/sec)  % Free    100
hdisk28   0.0     0.0      0.0    0.0     0.0   ServerV2      0
hdisk23   0.0     0.0      0.0    0.0     0.0   ClientV2      0    Press:
hdisk36   0.0     0.0      0.0    0.0     0.0   ServerV3      0    "h" for help
hdisk29   0.0     0.0      0.0    0.0     0.0   ClientV3      0    "q" to quit
hdisk30   0.0     0.0      0.0    0.0     0.0

Name            PID  CPU%  PgSp Owner
DOCs         594150  14.5   1.5 fnsw
topas       1458282   0.9   2.1 fnsw
COR_List     675936   0.4  34.5 fnsw
scopeux      454898   0.4   3.0 root
CSMs        1257584   0.3   1.0 fnsw
xmtopasa     413914   0.2   1.6 root
gil           69666   0.1   0.9 root
llbd         311538   0.1   0.4 root
ksh         1413288   0.1   0.6 fnsw
getty        250094   0.1   0.4 root
xmtopas      258198   0.1   1.0 root
kulagent     483354   0.1   7.9 root
kcawd        626752   0.1   4.4 root
ovcd         278732   0.0   4.6 root
opcacta      389346   0.0   2.7 root
random       237800   0.0   0.4 root

I need the below output in file

Code:
CPU  User%  Kern%  Wait%  Idle%  Physc   Entc
ALL   15.5    4.6    0.2   79.6   0.18   21.7

# 2  
Old 01-29-2014
Hello,

Following may help.

Code:
awk '/CPU  User%  Kern%  Wait%/ {a=$0;getline;b=$0} {gsub(/Reads.*/,X,a) gsub(/Writes.*/,Y,b);} END{print a"\n"b}' file_name


Output will be as follows.

Code:
CPU  User%  Kern%  Wait%  Idle%  Physc   Entc
ALL   15.5    4.6    0.2   79.6   0.18   21.7


Thanks,
R. Singh
# 3  
Old 01-29-2014
or if the format doesn't matter:
Code:
awk '/^(CPU|ALL)/{NF=7;print}' myFile

# 4  
Old 01-30-2014
Hi,

instead of "greping" the ouput from topas, You could use the output from lparstat,vmstat or sar.

Regards

Last edited by -=XrAy=-; 01-30-2014 at 10:31 AM..
# 5  
Old 02-01-2014
The AIX grep has a special and to my knowledge on no other UNIX system available option: -p. This will return not the line but the whole paragraph (lines delimited by blank lines) with the match, hence:

Code:
grep -p '^CPU' /file/with/your/output

should do exactly what you want. Beware, though: option -p is NOT POSIX, therefore avoid it when the script has to run outside AIX.

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

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. (5 Replies)
Discussion started by: rpm120
5 Replies

2. AIX

Alternative command for topas

hi, I need alternative command for topas to check cpu %, i tried with ps but their is lot of diffference between the outputs of two commands... Thanks (3 Replies)
Discussion started by: sumanthupar
3 Replies

3. AIX

Need help on topas command

Hi, how to grep data from topas command...for example i have to grep owner from topas command Thanks (2 Replies)
Discussion started by: sumanthupar
2 Replies

4. AIX

Record topas command output

How to record output of below command in a text file. topas -P or is there any other command which will do the same thing in AIX. I would like to get a report something similar to below commands. top -b prstat -c (5 Replies)
Discussion started by: NarayanaPrakash
5 Replies

5. Shell Programming and Scripting

Help with topas command

How do i display only one iteration of topas command. Ideally i would topas -P to show only one instance rather than keep on running. is there any swicth? (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

6. UNIX for Dummies Questions & Answers

TOPAS command in Unix

Hi, I am able to see the output of TOP command in my unix server whereas i could not see for TOPAS $ topas nologin: topas: not found May i know what is topas in unix and how to resolve this? Thanks (3 Replies)
Discussion started by: Maddy123
3 Replies

7. UNIX for Dummies Questions & Answers

Grep command to remove blank lines

The following grep command grep -v "^$" filename > newfilename does not populate the new file with any data. I see it search the entire input file but the output file never gets filled. Is this not the correct command for what Im looking to do? (2 Replies)
Discussion started by: aispg8
2 Replies

8. Shell Programming and Scripting

getting two lines by using grep command

i hav a text file(abc.txt) in which it have 2 lines as shown Number of agencies didnt send the file= 0 sum of reject files= 0 ###### to get one line from the text file ... i use grep command grep 'Number of agencies didnt send the file= 0' abc.txt ... (7 Replies)
Discussion started by: nani1984
7 Replies

9. UNIX for Dummies Questions & Answers

Help with TOPAS command

I used the TOPAS command to get top 20 process information by routing the output to a file. But the output is not very readable. can ayone explain how to read the output, or how to interpret the information? Thanks! (3 Replies)
Discussion started by: ginnyr1
3 Replies

10. UNIX for Dummies Questions & Answers

command topas

hi, everybody i have a problem about performane in unix when i run topas, there 1 form show, there are many parameter about memory,cpu,.... i want to know detail about those example : MEMORY Real,MB 12287 % Comp 25.0 % Noncomp 75.8 % Client 0.5 comp mean ? 25 mean ? 25MB or 25%memory... (6 Replies)
Discussion started by: tokienlua
6 Replies
Login or Register to Ask a Question