#! /bin/awk -f # fsstructlx.awk will decode Linux error messages in /var/log/messages to be more readable. # setting all=1 will print out all error entries, all=0 will just print out # GPFS related error entries. ############################################################################# # # Usage: fsstructlx.awk [] # ############################################################################# BEGIN { if (ARGC<2) { print "Usage: fsstructlx.awk [] " terminate=1 exit 1 } wide=1 #set to 0 for pre-gpfs2.3 versions that do not use wide disk addresses all=0 decode=1 CONVFMT="%.12g" OFMT="%.12g" name[101]="FSErrInconsistentInode "; sens[101]=5; fmt[101]="4 8 8 2 v" name[102]="FSErrIndirectBlock "; sens[102]=5; fmt[102]="f 4 4 4 v" name[104]="FSErrBadReplicationCounts"; sens[104]=5; fmt[104]="4 v" name[105]="FSErrBadPtrReplications "; sens[105]=5; fmt[105]="4 2 2 2 v" name[106]="FSErrIndirectionLevel "; sens[106]=5; fmt[106]="4 2 v" name[107]="FSErrDeallocBlock "; sens[107]=1; fmt[107]="4 4 4 4 4 4 4 4" #wide alt#name[107]="FSErrDeallocBlock "; sens[107]=1; fmt[107]="4 4 8 4 4 4 4" name[108]="FSErrValidate "; sens[108]=5; fmt[108]="2 d 2 r v" name[109]="FSErrBadDiskAddrIndex "; sens[109]=1; fmt[109]="d 2" name[110]="FSErrBadDiskAddrSector "; sens[110]=1; fmt[110]="d 2 2" name[111]="FSErrBadDirBlock "; sens[111]=2; fmt[111]="4 4 4 4 4 4 4 4 4 4" name[112]="FSErrBadInodeStatus "; sens[112]=5; fmt[112]="4 v" name[113]="FSErrBadInodeOrGen "; sens[113]=5; fmt[113]="4 4 4 v" name[114]="FSErrAllocBlock "; sens[114]=1; fmt[114]="4 4 4 4" name[115]="FSErrBadDittoAddr "; sens[115]=2; fmt[115]="4 4 4 4 4 4 4 4 8" name[116]="FSErrSnapInodeModified "; sens[116]=5; fmt[116]="4 4 4 4 v" # subcode of 111 FSErrBadDirBlock name[201]="DirErrCheckHeaderFailed "; sens[201]=2; fmt[201]="4 4 4 4 4 4 4 4 4 4" name[202]="DirErrDotDotNotFound "; sens[202]=2; fmt[202]="4 4 4 4 4 4" name[203]="DirErrGenNumMismatch "; sens[203]=2; fmt[203]="4 4 4 4 4 4" name[204]="DirErrInodeNumMismatch "; sens[204]=2; fmt[204]="4 4 4 4 4 4" name[205]="DirErrInodeCorrupted "; sens[205]=2; fmt[205]="4 4 4 4 4 4" name[206]="DirErrDirectCorrupted "; sens[206]=2; fmt[206]="4 4 4 4 4 4" valtype[1]="inode" valtype[2]="indBlock" valtype[3]="dataAllocmap" valtype[4]="inodeAllocmap" valtype[5]="dirBlock" valtype[6]="bufDataAllocMap" buftype[0]="PBT_UNKNOWN" buftype[1]="PBT_FREE" buftype[2]="PBT_METADATA" buftype[3]="PBT_TEMP" buftype[4]="PBT_DISKDESC" buftype[5]="PBT_SGDESC" buftype[6]="PBT_DATA" buftype[7]="PBT_IND" buftype[8]="PBT_INODE" buftype[9]="PBT_LLDATA" buftype[10]="PBT_LLINDIRECT" buftype[11]="PBT_LLINODE" buftype[12]="PBT_ALLOC" buftype[13]="PBT_IALLOC" buftype[14]="PBT_LOG" buftype[15]="PBT_LOGDESC" buftype[16]="PBT_RECOV" buftype[17]="PBT_LOG_WRAP" buftype[18]="PBT_ISCAN" allerrtype["FFFF"]="NoBlock" allerrtype["FFFE"]="LinkListFirst" allerrtype["FFFD"]="NoConsecutive" allerrtype["FFFC"]="LinkListNth" allerrtype["FFFB"]="LinkListNew" monthof["Jan"]="01" monthof["Feb"]="02" monthof["Mar"]="03" monthof["Apr"]="04" monthof["May"]="05" monthof["Jun"]="06" monthof["Jul"]="07" monthof["Aug"]="08" monthof["Sep"]="09" monthof["Oct"]="10" monthof["Nov"]="11" monthof["Dec"]="12" } function hexToDecimal(hex, d, ch, i, val) { d = 0 for (i=1 ; i<=length(hex) ; i++) { ch = substr(hex,i,1) val = index("0123456789ABCDEF", ch) if (val == 0) val = index("0123456789abcdef", ch) d = d*16 + val - 1 } return d } function handle_mmfs_line(ln) { $0=ln mon=monthof[$1]; if (mon == "") mon=$1 day=$2; if (day < 10) day="0"day date=mon"/"day"@"$3 node=$4 printed=0 if (index($0, "mmfs: Generic error") > 0) { module=$9 pos=index(module,"/") while (pos > 0) { module=substr(module,pos+1) pos=index(module,"/") } lineno=$11 rcode=substr($13,1,length($13)-1) rscode=$15 # assume it belongs to last tag seen sense[subscr] = sense[subscr] " rc="rcode" reason="rscode" line "lineno" "module printed=1 } else if (index($0, "mmfs: Tag=") > 0) { pos=index($0,"Tag=") tag=substr($6,5) subscr=FILENAME SUBSEP tag rest=substr($0,pos+length($6)+1) sense[subscr] = sense[subscr] " failedassert=" rest printed=1 } else if (substr($6,1,6) == "Error=" || substr($7,1,6) == "Error=" ) { if ($6 == "mmfsd:") { label=substr($7,7) id=substr($8,6) tag=substr($9,5) } else { label=substr($6,7) id=substr($7,6) tag=substr($8,5) } label=substr(label,1,length(label)-1) id=substr(id,1,length(id)-1) if (substr(tag,length(tag)) == ":") tag=substr(tag,1,length(tag)-1) subscr=FILENAME SUBSEP tag if (seentag[subscr] == "") { tags++ taglist[tags]=subscr seentag[subscr]=sprintf("%s %s %s %s", date, node, label, id) } pos=index($0,"Tag=") if (pos > 0) { rest=substr($0,pos) pos=index(rest,":") if (pos > 0) rest=substr(rest,pos+1) sense[subscr] = sense[subscr] " " rest } if (label == "MMFS_FSSTRUCT") { pos=index($0,"Error code") if (pos > 0) { ingpfs=1; infsstruct=1 $0=substr($0,pos) code=substr($3,1,length($3)-1) count[code]++ vol=$5 seentag[subscr] = seentag[subscr] " " code " " vol sense[subscr] = "" } printed=1 } else if (label == "MMFS_PHOENIX") {printed=1; ingpfs=1; inphoenix=1} else if (label == "MMFS_GENERIC") {printed=1; ingpfs=1; ingeneric=1} else if (label == "MMFS_ABNORMAL_SHUTDOWN") {printed=1; ingpfs=1; inshutdown=1} else if (label == "MMFS_LONGDISKIO") {printed=1; ingpfs=1; inlongdiskio=1} else if (label == "MMFS_SYSTEM_UNMOUNT") {printed=1; ingpfs=1; inunmount=1} else if (label == "MMFS_DISKFAIL") {printed=1; ingpfs=1; indiskfail=1} else if (label == "MMFS_TRACEBACK") {printed=1; ingpfs=1; intraceback=1} else if (label == "MMFS_MOREINFO") {printed=1; ingpfs=1; inmoreinfo=1} else if (label == "MMFS_QUOTA") {printed=1; ingpfs=1; inquota=1} else if (label == "MMFS_ENVIRON") {printed=1; ingpfs=1; inenviron=1} else if (label == "MMFS_RECOVERY") {printed=1; ingpfs=1; inrecovery=1} else if (label == "MMFS_SYSTEM_WARNING") {printed=1; ingpfs=1; inwarning=1} else { rest="" pos=index($0,"Tag=") if (pos > 0) { $0=substr($0,pos) cpos=index($0,":") if (cpos > 0) rest=substr($0,cpos+2) else {$1=""; rest=$0} sense[subscr] = sense[subscr] " " rest printed=1 } } } else { if (all) { mon=monthof[$1]; if (mon == "") mon=$1 day=$2; if (day < 10) day="0"day date=mon"/"day"@"$3 node=$4 $1=date; $2=node; $3=""; $4="" print $0 } printed=1 } if (!printed) print $0 } # Main loop per record { if (substr($1,length($1)) == ":") { prenode=$1 pos=index($0,":") $0=substr($0,pos+2) } origln=$0 if (index(origln,"mmfs:") > 0) { if (index(origln,"unsupported module") == 0 && index(origln,"module license") == 0) { handle_mmfs_line(origln) lastline=origln } } else { pos=index(origln,"last message repeated") if (pos > 0 && index(lastline,"mmfs:") > 0) { $0=substr(origln,pos+21) for (cnt=$1; cnt > 0; cnt--) handle_mmfs_line(lastline) } else { lastline=origln if (all) { $0 = origln mon=monthof[$1]; if (mon == "") mon=$1 day=$2; if (day < 10) day="0"day date=mon"/"day"@"$3 node=$4 $1=date; $2=node; $3=""; $4="" print $0 } } } } function print_gpfstag(tag) { $0=seentag[tag] date=$1; node=$2; label=$3; id=$4; code=$5; vol=$6 if (label != "MMFS_FSSTRUCT") { print seentag[tag] sense[tag] } if (label == "MMFS_FSSTRUCT") { $0=sense[tag] NF = split($0, wds) wd=3 if (code == 111) # FSErrBadDirBlock { code=hexToDecimal($(wd)); if (code >= 201 && code <= 206) wd+=4 else code=111 } formt=fmt[code] if (!decode || formt == "") printf("%s %s %s %s %s %s %s\n", date, node, "FSSTRUCTX", vol, code, name[code], sense[tag]) else { tokens=0 for (f=1; f <= length(formt); f++) { ch = substr(formt,f,1) if (ch != " ") { tokens++ if (ch == "4") { tok[tokens] = $(wd+3) $(wd+2) $(wd+1) $wd ; wd+=4 } else if (ch == "2") { tok[tokens] = $(wd+1) $wd; wd+=2 } else if (ch == "8") { tok[tokens] = $(wd+7) $(wd+6) $(wd+5) $(wd+4) $(wd+3) $(wd+2) $(wd+1) $wd; wd+=8 } else if (ch == "d") { if (wide) { tok[tokens] = $wd $(wd+1) $(wd+2) $(wd+3)":"$(wd+4) $(wd+5) $(wd+6) $(wd+7) $(wd+8) $(wd+9) $(wd+10) $(wd+11)"("hexToDecimal($wd $(wd+1) $(wd+2) $(wd+3))":"hexToDecimal($(wd+4) $(wd+5) $(wd+6) $(wd+7) $(wd+8) $(wd+9) $(wd+10) $(wd+11))")"; wd+=12 } else { tok[tokens] = $wd $(wd+1)":"$(wd+2) $(wd+3) $(wd+4) $(wd+5)"("hexToDecimal($wd $(wd+1))":"hexToDecimal($(wd+2) $(wd+3) $(wd+4) $(wd+5))")"; wd+=6 } } else if (ch == "r") { nval=$(wd+1) $wd; wd+=2 if (nval == "FFFF") tok[tokens]="[broken]" else { nval+=0 tok[tokens] = "[nVal="nval while (nval > 0) { if (wide) { tok[tokens] = tok[tokens]" "$wd $(wd+1) $(wd+2) $(wd+3)":"$(wd+4) $(wd+5) $(wd+6) $(wd+7) $(wd+8) $(wd+9) $(wd+10) $(wd+11)"("hexToDecimal($wd $(wd+1) $(wd+2) $(wd+3))":"hexToDecimal($(wd+4) $(wd+5) $(wd+6) $(wd+7) $(wd+8) $(wd+9) $(wd+10) $(wd+11))")"; wd+=12 } else { tok[tokens] = tok[tokens]" "$wd $(wd+1)":"$(wd+2) $(wd+3) $(wd+4) $(wd+5)"("hexToDecimal($wd $(wd+1))":"hexToDecimal($(wd+2) $(wd+3) $(wd+4) $(wd+5))")"; wd+=6 } nval-- } tok[tokens] = tok[tokens]"]" } } else if (ch == "f") { nval=$(wd+1) $wd; wd+=2 if (nval == "FFFF") tok[tokens]="[broken" else { nval+=0 tok[tokens] = "[nVal="nval while (nval > 0) { if (wide) { tok[tokens] = tok[tokens]" "$wd $(wd+1) $(wd+2) $(wd+3)":"$(wd+4) $(wd+5) $(wd+6) $(wd+7) $(wd+8) $(wd+9) $(wd+10) $(wd+11)"("hexToDecimal($wd $(wd+1) $(wd+2) $(wd+3))":"hexToDecimal($(wd+4) $(wd+5) $(wd+6) $(wd+7) $(wd+8) $(wd+9) $(wd+10) $(wd+11))")"; wd+=12 } else { tok[tokens] = tok[tokens]" "$wd $(wd+1)":"$(wd+2) $(wd+3) $(wd+4) $(wd+5)"("hexToDecimal($wd $(wd+1))":"hexToDecimal($(wd+2) $(wd+3) $(wd+4) $(wd+5))")"; wd+=6 } nval-- } } tok[tokens] = tok[tokens]" subl="$(wd+1) $wd"]"; wd+=2 } else if (ch == "v") { tok[tokens] = "(len="$(wd+3) $(wd+2) $(wd+1) $wd")"; wd+=4 while (NF >= wd && $NF == "00") NF-- while (wd <= NF-3) { tok[tokens] = tok[tokens]" "$wd $(wd+1) $(wd+2) $(wd+3); wd+=4 } while (wd <= NF-1) { tok[tokens] = tok[tokens]" "$wd $(wd+1); wd+=2 } while (wd <= NF) { tok[tokens] = tok[tokens]" "$wd; wd++ } } } if (debug) print ch"="tok[tokens] } rest="" while (NF >= wd && $NF == "00") NF-- while (wd <= NF) { rest = rest" "$wd; wd++ } if (code == 101) # FSErrInconsistentInode { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="allocBlks="tok[2] tok[3]="lastBlock="tok[3] tok[4]="fragSubbl="tok[4] tok[5]="inode="tok[5] } else if (code == 102) # FSErrIndirectBlock { tok[1]="da="tok[1] tok[2]="gen="tok[2] tok[3]="inodeNum="tok[3]"("hexToDecimal(tok[3])")" tok[4]="expectBlkNum="tok[4] tok[5]="indBlock="tok[5] } else if (code == 104) # FSErrBadReplicationCounts { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="inode="tok[2] } else if (code == 105) # FSErrBadPtrReplications { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="dataPtrsPerInode="tok[2] tok[3]="indPtrsPerInode="tok[3] tok[4]="dataPtrsPerIndBlk="tok[4] tok[5]="inode="tok[5] } else if (code == 106) # FSErrIndirectionLevel { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="invalIndLvl="tok[2] tok[3]="inode="tok[3] } else if (code == 107) # FSErrDeallocBlock { tok[1]="errno="tok[1] tok[2]="diskNum="tok[2] if (wide || tok[4] > 32) # subblocks too big, assume 8 byte sector number { tok[3]="sector="tok[3] tok[4] tok[4]="nSubblocks="tok[5] tok[5]="region="tok[6] tok[6]="segment="tok[7] tok[7]="subBlock="tok[8] } else # assume 4 byte sector number { tok[3]="sector="tok[3] tok[4]="nSubblocks="tok[4] tok[5]="region="tok[5] tok[6]="segment="tok[6] tok[7]="subBlock="tok[7] } } else if (code == 108) # FSErrValidate { type=valtype[tok[1]+0] if (type == "") type=tok[1] tok[1]="type="type tok[2]="da="tok[2] tok[3]="sectors="tok[3] tok[4]="repda="tok[4] tok[5]="data="tok[5] } else if (code == 109) # FSErrBadDiskAddrIndex { tok[1]="da="tok[1] type=buftype[tok[2]+0] if (type == "") type=tok[2] tok[2]="type="type } else if (code == 110) # FSErrBadDiskAddrSector { tok[1]="da="tok[1] tok[2]="sectors="tok[2] type=buftype[hexToDecimal(tok[3])] if (type == "") type=tok[3] tok[3]="type="type } else if (code == 111) # FSErrBadDirBlock { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="blockNum="tok[2] tok[3]="errorcode="tok[3] tok[4]="errno="tok[4] tok[5]="dirhdr="tok[5] # and pick up tok[6 7 8 9] } else if (code == 112) # FSErrBadInodeStatus { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="inode="tok[2] } else if (code == 113) # FSErrBadInodeOrGen { tok[1]="fileInodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="dirInodeNum="tok[2]"("hexToDecimal(tok[2])")" tok[3]="gen="tok[3] tok[4]="filename="tok[4] } else if (code == 114) # FSErrAllocBlock { type=allerrtype[tok[1]] if (type == "") type=tok[1] tok[1]="type="type tok[2]="diskIndex="tok[2] tok[3]="recordNo="tok[3] tok[4]="nSubblocks="tok[4] } else if (code == 115) # FSErrBadDittoAddr { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="gen="tok[2] tok[3]="snapId="tok[3] tok[4]="inodeStatus="tok[4] tok[5]="InodeNumPrevSnap="tok[5]"("hexToDecimal(tok[5])")" tok[6]="genPrevSnap="tok[6] tok[7]="snapIdPrevSnap="tok[7] tok[8]="inodeStatusPrevSnap="tok[8] tok[9]="blockNum="tok[9] } else if (code == 116) # FSErrSnapInodeModified { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="snapId="tok[2] tok[3]="nextSnapId="tok[3] tok[4]="fileModifiedSnapId="tok[4] tok[5]="inode="tok[5] } else if (code == 201) # DirErrCheckHeaderFailed { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="snapId="tok[2] tok[3]="blockNum="tok[3] tok[4]="errorcode="tok[4] tok[5]="rc="tok[5] tok[6]="dirhdr="tok[6] # and pick up tok[7 8 9 10 11] } else if (code == 202) # DirErrDotDotNotFound { tok[1]="errorcode="tok[1] tok[2]="rc="tok[2] tok[3]="srcInodeNum="tok[3]"("hexToDecimal(tok[3])")" tok[4]="srcGen="tok[4] } else if (code == 203) # DirErrGenNumMismatch { tok[1]="errorcode="tok[1] tok[2]="rc="tok[2] tok[3]="srcInodeNum="tok[3]"("hexToDecimal(tok[3])")" tok[4]="srcGen="tok[4] tok[5]="entryGen="tok[5] } else if (code == 204) # DirErrInodeNumMismatch { tok[1]="errorcode="tok[1] tok[2]="rc="tok[2] tok[3]="srcInodeNum="tok[3]"("hexToDecimal(tok[3])")" tok[4]="entryInodeNum="tok[4]"("hexToDecimal(tok[4])")" } else if (code == 205) # DirErrInodeCorrupted { tok[3]="inodeNum="tok[3]"("hexToDecimal(tok[3])")" tok[4]="srcGen="tok[4] tok[5]="entryGen="tok[5] tok[6]="entryInodeStatus="tok[6] } else if (code == 206) # DirErrDirectCorrupted { tok[1]="inodeNum="tok[1]"("hexToDecimal(tok[1])")" tok[2]="blockNum="tok[2] tok[3]="errorcode="tok[3] tok[4]="errno="tok[4] tok[5]="dirhdr="tok[5] # and pick up tok[6 7 8 9] } printf("%s %s %s %s %s %s", date, node, "FSSTRUCT", vol, code, name[code]) for (i = 1; i <= tokens; i++) printf(" %s", tok[i]) if (rest != "") printf(" rest =%s\n", rest) else printf("\n") } } } END { if (terminate) exit 1 for (tag=1; tag <= tags; tag++) print_gpfstag(taglist[tag]) for (code in count) printf("+++code: %4d %s %9d times\n", code, name[code], count[code]) }