mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss.git
synced 2025-04-19 04:09:43 +00:00
Enable extended mode and add log parser
This commit is contained in:
parent
0ba773d913
commit
1c283a21a9
3 changed files with 98 additions and 9 deletions
48
parser.awk
Executable file
48
parser.awk
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/awk -f
|
||||
|
||||
BEGIN {
|
||||
RS=" "
|
||||
CSV_HEADER=""
|
||||
CSV_DATA=""
|
||||
}
|
||||
|
||||
/LOG2PARSE/{
|
||||
# First extract what we need
|
||||
to_parse=$1
|
||||
gsub(/\[LOG2PARSE\]\(/,"",to_parse)
|
||||
gsub(/\)/,"",to_parse)
|
||||
split(to_parse,tokens,"|")
|
||||
|
||||
# Check if we have to build the csv header
|
||||
if(CSV_HEADER==""){
|
||||
for(i = 1; i<length(tokens);i++){
|
||||
split(tokens[i],h,":")
|
||||
if(CSV_HEADER=="")
|
||||
CSV_HEADER=h[1]
|
||||
else
|
||||
CSV_HEADER=CSV_HEADER","h[1]
|
||||
}
|
||||
}
|
||||
|
||||
# Build a row
|
||||
row=""
|
||||
for(i = 1; i<length(tokens);i++){
|
||||
split(tokens[i],h,":")
|
||||
if(row=="")
|
||||
row=h[2]
|
||||
else
|
||||
row=row","h[2]
|
||||
}
|
||||
|
||||
# Add the row to the csv data
|
||||
if(CSV_DATA=="")
|
||||
CSV_DATA=row
|
||||
else
|
||||
CSV_DATA=CSV_DATA"\n"row
|
||||
}
|
||||
|
||||
|
||||
END {
|
||||
print(CSV_HEADER);
|
||||
print(CSV_DATA)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue