HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
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.


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