Sponsored Content
Full Discussion: Extract info from sar output
Top Forums Shell Programming and Scripting Extract info from sar output Post 302950289 by fretagi on Thursday 23rd of July 2015 06:13:29 AM
Old 07-23-2015
Extract info from sar output

Hi

I have an output of sarcommand which is as follows:
Code:
10:22:18 bread/s lread/s %rcache bwrit/s lwrit/s %wcache pread/s pwrit/s
10:23:18       0     398     100       5      13      64       0       0
10:24:18       0     332     100       5      15      65       0       0
10:25:18       0     301     100       6      17      67       0       0
10:26:18       0     309     100       5      16      69       1       0
10:27:18       0     178     100       5      13      61       0       0
10:28:18       0     118     100      14      17      16       0       0
10:29:18       0     189     100      10      16      35       0       0
10:30:18       0     249     100       5      20      74       0       0
10:31:18       0     147     100      14      21      32       1       0
10:32:18       0     325     100       6      14      59       0       0
10:33:18       0     570     100       6      15      60       0       0
10:34:18       0     734     100       6      16      62       0       0
10:35:18       0     704     100       6      22      70       0       0
10:36:18       0     718     100       6      15      59       0       0
10:37:18       0     794     100       6      15      59       0       0
10:38:18       0     796     100       5      12      57       0       0
10:39:18       0     739     100       5      11      51       0       0
10:40:18       0     714     100       6      17      65       0       0
10:41:18       0    1281     100      18      21      17       0       0
10:42:18       0     700     100       6      17      64       1       0
10:43:18       0     720     100       5      14      60       0       0
10:44:18       0     846     100       6      15      60       0       0
10:45:18       0     799     100       6      19      67       0       0
10:46:18       0     663     100       6      15      62       0       0
10:47:18       0     710     100       6      17      64       1       0
10:48:18       0     642     100       6      12      53       0       0
10:49:18       0     713     100       6      13      56       0       0
10:50:18       0     746     100       6      18      69       0       0
10:51:18       0    1241     100      17      22      23       0       0
10:52:18       0     773     100       6      18      68       1       0

Average        0     605     100       7      16      56       0       0

and I want to extract the 1st, 4th and 7th column but adding before the hour column another column with 1, 2, 3, and so on like:
Code:
1
2
3
4
5
6
7

I have try to use the following piece of code:
Code:
cat sarb.out | \
awk 'BEGIN {LINE=1; printf "#Spl Date     %%rcache %%wcache\n"; }
 { if ( NF == 9 ) {
  if($1 != "Average") DATE=$1
  if($1 == "Average") {
   printf "%4d %s %7d %7d\n", LINE, DATE, $4, $7
   LINE++}
   }
 }'

but my output is only one line.

please can you help

---------- Post updated at 12:13 PM ---------- Previous update was at 11:37 AM ----------

my expected output should be:
Code:
	10:22:18          %rcache          %wcache 
1	10:23:18            100             64       
2	10:24:18            100             65       
3	10:25:18            100             67      
4	10:26:18            100             69       
5	10:27:18            100             61       
6	10:28:18            100             16     
7	10:29:18            100             35       
8	10:30:18            100             74       
9	10:31:18            100             32       
10	10:32:18            100             59


Last edited by rbatte1; 07-24-2015 at 05:59 AM.. Reason: Changed ICODE tags to CODE tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sar -q output for one processor

Hello, We like to know if there is a way to report the sar -q per processor on AIX 4.3 . Please help RGDS,Elie. (1 Reply)
Discussion started by: eyounes
1 Replies

2. UNIX for Advanced & Expert Users

Why my sar is not updating the output file.

I am trying to collect the sar output for around 90minutes. When i do sar 1 5000 >> /tmp/sar.out It's not updating the sar.out file. When we decrease the 5000 to smaller number like 10, i can see the file sar.out updated after the 10seconds.If i kill my sar while it is running it's not... (1 Reply)
Discussion started by: skneeli
1 Replies

3. Shell Programming and Scripting

sar today's output

Hi All, i tried sar command the output appears to be for several days I would like to just see today's SAR output: Please advice me. $sar Linux 2.6.9-67.ELsmp (lrtp50) 02/28/09 00:00:01 CPU %user %nice %system %iowait %idle 00:05:02 all 3.10... (4 Replies)
Discussion started by: raghur77
4 Replies

4. Shell Programming and Scripting

Formatting Sar Output script

Hi, We have 2 scripts below for reporting sar output which are pretty same. In first script i want to add to the program whatever is given in the comments. In second script I want to use while true to run this program every hour and everything that is in comment. Finally I want to club... (0 Replies)
Discussion started by: noorm
0 Replies

5. Solaris

extraction of sar output

Hi, Anyone knows how to extract sar command output to excel or Is there any free grapical tools to extract this sar log file. thanks, regards (2 Replies)
Discussion started by: vijill
2 Replies

6. Solaris

Strange sar output

I was reviewing yesterday's sar file and came across this strange output! What in the world? Any reason why there's output like that? SunOS unixbox 5.10 Generic_144488-07 sun4v sparc SUNW,T5240 Solaris 00:00:58 device %busy avque r+w/s blks/s avwait avserv 11:20:01 ... (4 Replies)
Discussion started by: dangral
4 Replies

7. Solaris

sar output

One of my servers giving all zero sar output. Could anyone explain this behaviour. Thanks CHaandana Sample: 10:43:37 %usr %sys %wio %idle 16:15:01 2 1 0 97 16:20:02 2 1 0 97 16:25:02 2 1 0 97 16:30:01 ... (3 Replies)
Discussion started by: chaandana
3 Replies

8. Solaris

Odd output from sar

We're experiencing some intermittent freezes on one of our systems and I'm trying to figure out what is happening. We're running Solaris 10 zones mounting shares from netapp through nfs. On the zone that freezes we have sar running and are getting this output: SunOS prodserver 5.10... (3 Replies)
Discussion started by: Jyda
3 Replies

9. Red Hat

Sar output

I am facing situation where sar -u command is showing 0 for all cps, so does it mean all the cpus are fully utilized, os is oracle Linux 6.8 01:34:13 PM all 0 0 0 0 0.00 0 (2 Replies)
Discussion started by: manoj.solaris
2 Replies
All times are GMT -4. The time now is 05:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy