Skip to content

Instantly share code, notes, and snippets.

@danielef
Created November 1, 2016 04:04
Show Gist options
  • Select an option

  • Save danielef/44834986c8dca86486f16c8643d14887 to your computer and use it in GitHub Desktop.

Select an option

Save danielef/44834986c8dca86486f16c8643d14887 to your computer and use it in GitHub Desktop.
AWK gets a log with specified line starts and write a CSV
;; Query time: 13 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Oct 27 14:05:26 2016
;; MSG SIZE rcvd: 53
size inuse free pin virtual mmode
memory 4030464 3606573 423891 821507 2071729 Ded
pg space 4325376 28186
work pers clnt other
pin 700377 0 0 121130
in use 2062769 0 1543804
PageSize PoolSize inuse pgsp pin virtual
s 4 KB - 1973261 7674 175315 429457
m 64 KB - 102082 1282 40387 102642
System configuration: type=Dedicated mode=Capped smt=On lcpu=4 mem=15744MB
%user %sys %wait %idle
----- ----- ------ ------
73.8 5.6 0.0 20.6
===
;; Query time: 45 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Oct 27 14:05:37 2016
;; MSG SIZE rcvd: 53
size inuse free pin virtual mmode
memory 4030464 3607151 423313 821511 2071742 Ded
pg space 4325376 28186
work pers clnt other
pin 700381 0 0 121130
in use 2062782 0 1544369
PageSize PoolSize inuse pgsp pin virtual
s 4 KB - 1973839 7674 175319 429470
m 64 KB - 102082 1282 40387 102642
System configuration: type=Dedicated mode=Capped smt=On lcpu=4 mem=15744MB
%user %sys %wait %idle
----- ----- ------ ------
30.6 6.2 10.9 52.3
===
/^;; Query time: /{q=$4}
/^;; SERVER: /{s=$3}
/^;; WHEN: /{w=$3" "$4" "$5" "$6" "$7}
/^;; MSG SIZE rcvd:/{mes=$5}
/^memory /{memsize=$2; memuse=$3; memfre=$4; mempin=$5; memvir=$6; memmod=$7}
/^pg space /{pgsize=$3; pguse=$4}
/^pin /{pw=$2; pp=$3; pc=$4; po=$5}
/^in use /{iuw=$3; iup=$4; iuc=$5}
/^s /{s1=$2; s2=$5; s3=$6; s4=$7; s5=$8}
/^m /{m1=$2; m2=$5; m3=$6; m4=$7; m5=$8}
/^System configuration: /{split($3,sc1,"="); split($4,sc2,"="); split($5,sc3,"="); split($6,sc4,"="); split($7,tmp,"="); split(tmp[2],sc5,"MB")}
/^ [0-9]+\.[0-9] /{t1=$1; t2=$2; t3=$3; t4=$4}
/^===$/{print ""q","s","w","mes","memsize","memuse","memfre","mempin","memvir","memmod","pgsize","pguse","pw","pp","pc","po","iuw","iup","iuc","s1","s2","s3","s4","s5","m1","m2","m3","m4","m5","sc1[2]","sc2[2]","sc3[2]","sc4[2]","sc5[1]","t1","t2","t3","t4}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment