Showing results for 
Search instead for 
Did you mean: 

Sar output on Linux

Jean-Baptiste Broccard
Occasional Advisor

Sar output on Linux

hi all,
i used glance on hpux to gather system metrics, unfortunately on linux, glance has less values. So, i'm trying to use SAR to collect the metrics, unfortunately my tool that processes my datafile expects 1 line per timestamp. With sar, if i specify sar -u and -r then he'll generate 2 lines for the same timestampt:

03:20:27 PM CPU %user %nice %system %iowait %steal %idle
03:20:28 PM all 0.00 0.00 0.00 0.00 0.00 100.00

03:20:27 PM kbmemfree kbmemused %memused kbbuffers kbcached kbswpfree kbswpused %swpused kbswpcad
03:20:28 PM 946668 2706144 74.08 88708 2466876 337196 128 0.04 60

IOs it possible to have everything on the same line for a given timestamp ? With a Awk or perl.

Dennis Handly
Acclaimed Contributor

Re: Sar output on Linux

>Is it possible to have everything on the same line for a given timestamp? With awk or perl.

Sure but you are going to have to explain exactly what you want. It appears something is terribly wrong with your sar output.
It seems you have a title line then data, then a different title and data.

I don't understand why the title line has a different timestamp than the data?

If you have more data in your file, do you have sets of those 4 lines? (Do you have blank lines?)

If you just have repeats of those 4 lines you can do:
awk '
getline L2
getline L3
getline L4
print $0, L3 # title
print L2, L4 # data
}' sar-file