Created
December 3, 2013 20:41
-
-
Save drldcsta/7777126 to your computer and use it in GitHub Desktop.
awk profiling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@mgmt01 logs]# time zfgrep -vw CM manager.log.7.gz|awk --profile 'BEGIN{print "Date,Time,FX SessID,USRM SessID,Home,Asset";OFS=","};$7 == 17018{split($NF,HA,"[$_]"); A[$8] = HA[3];H[$8] = HA[4]} $7 == 17031 && $0 ~ /available/ || $0 ~ /unusable/ {dec=substr($8,14);ses=substr($8,2,12);dec_ses[$8]=ses"/"strtonum("0x"dec); print $1,$2,$8,dec_ses[$8],H[$8],A[$8];home[H[$8]]++};END{print "home,# of errors";K = asorti(home,n);for (i=1;i<=K;i++) print n[i],home[n[i]]} ' | |
Date,Time,FX SessID,USRM SessID,Home,Asset | |
12/02/13,18:44:16.636,@00223A25759201250256,00223A257592/19202646,35674934,65019706 | |
12/02/13,19:13:21.379,@001AC3FDF72C04530C7A,001AC3FDF72C/72551546,36959215,64824121 | |
12/02/13,19:38:54.079,@ECE09B07960105E4B090,ECE09B079601/98873488,43795953,65057265 | |
12/02/13,19:47:34.777,@001AC3FDF72C04530C7E,001AC3FDF72C/72551550,36959215,64824121 | |
home,# of errors | |
35674934,1 | |
36959215,2 | |
43795953,1 | |
real 0m3.016s | |
user 0m4.493s | |
sys 0m0.273s | |
[root@mgmt01 logs]# cat awkprof.out | |
# gawk profile, created Tue Dec 3 15:40:00 2013 | |
# BEGIN block(s) | |
BEGIN { | |
print "Date,Time,FX SessID,USRM SessID,Home,Asset" | |
OFS = "," | |
} | |
# Rule(s) | |
$7 == 17018 { | |
split($NF, HA, "[$_]") | |
A[$8] = HA[3] | |
H[$8] = HA[4] | |
} | |
$7 == 17031 && $0 ~ /available/ || $0 ~ /unusable/ { | |
dec = substr($8, 14) | |
ses = substr($8, 2, 12) | |
dec_ses[$8] = ((ses "/") strtonum(("0x" dec))) | |
print $1, $2, $8, dec_ses[$8], H[$8], A[$8] | |
home[H[$8]]++ | |
} | |
# END block(s) | |
END { | |
print "home,# of errors" | |
K = asorti(home, n) | |
for (i = 1; i <= K; i++) { | |
print n[i], home[n[i]] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment