We got the output from “sar -ruq” in a file, we stored in sar2.txt, and it looks like this:
11:44:51 633773 22954346 4 1 3 93 0.0 0 0.0 0 11:44:56 633773 22954288 2 2 1 94 0.0 0 0.0 0 11:45:01 632206 22786120 13 18 13 56 9.0 20 0.0 0 11:45:06 625509 22462685 53 47 0 0 5.0 99 0.0 0
So we want to plot it in excel, we need one line per sample, much like this:
11:45:06 625509 22462685 53 47 0 0 5.0 99 0.0 0 11:45:11 628749 22770298 59 41 0 0 4.8 100 0.0 0 11:45:16 630432 22733837 55 45 0 0 6.8 100 0.0 0
So we wrote a small gawk expression to do it:
gawk 'ORS=NR%3?" ":"n"' sar2.txt
So simple, we’re using the modulus function here to do the job. Coming to a blog near you!