Skip to content

Instantly share code, notes, and snippets.

@pglezen
Created September 21, 2017 18:25
Show Gist options
  • Save pglezen/23994d6d7ce903a953d79ec179a15ebe to your computer and use it in GitHub Desktop.
Save pglezen/23994d6d7ce903a953d79ec179a15ebe to your computer and use it in GitHub Desktop.
Organize Cloverleaf Error DB Output
# Presents hcidbdump -l output one entry per line.
#
# Usage: hcidbdump -e -l -O i | awk -f errdbtimes.awk
#
# This is useful because the raw output spreads each entry across
# several lines. This makes the output difficult to script and
# overly verbose. Here is a sample
#
#------- Begin Sample Raw Output -----------------
#
# hcidbdump -e -l | head -30
# Source
# Dest
# C Owner
# l T Orig Source
# a y F Orig Dest
# s p w Xlate Thread
# Created Message Id s e d Prio State Length Format
# -------- -------------- - - - ---- ----- ------ -------------------------------
# Tue Apr 11
# 09:38:04 [0.0.848589978 E D N 5120 302 5529 tccoal
# ims_ob
# tcis_xlate
# tccoal
# ims_ob
#
#
# Tue Apr 11
# 09:42:37 [0.0.848605822 E D N 5120 302 5528 tccoal
# ims_ob
# tcis_xlate
# tccoal
# ims_ob
#------- End Sample Raw Output -----------------
#
#------- Begin AWK Sample Output -----------------
# Tue Apr 11 09:38:04 0.0.848589978 302 tccoal ims_ob tcis_xlate
# Tue Apr 11 09:42:37 0.0.848605822 302 tccoal ims_ob tcis_xlate
# Fri May 12 09:41:10 0.0.896230696 301 pims_ib ims_ob da_xlate
#------- End AWK Sample Output -----------------
# Match a date line.
# This represents the start of a multi-line record.
# Assign FNR to dateline to track where we are relative to this line.
# Since this represents a new record, assign other fields to blank.
#
/^[[:alpha:]]{3} [[:alpha:]]{3} ?[0-9]+/ {
weekday = $1
month = $2
day = $3
dateline = FNR
# Since this represents a new record, assign other fields to blank.
time = ""
msgid = ""
state = ""
source = ""
target = ""
owner = ""
}
# Match the main part of the multi-line record.
# It should occur on the line AFTER the dateline.
#
/^[0-9]{2}:[0-9]{2}:[0-9]{2} / && (FNR == dateline + 1) {
time = $1
msgid = $2
state = $7
source = $9
}
# Match a few more fields on extra lines.
# Print the summary once we're four lines past the date line.
#
FNR == dateline + 2 { target = $1 }
FNR == dateline + 3 { owner = $1 }
(FNR == dateline + 4) && (FNR > 10) {
printf("%3s %3s %2d %s %-15s %s %-10.10s %-10.10s %s\n",
weekday, month, day, time, msgid, state, source, target, owner)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment