2021-05-07 08:18:41 +02:00
|
|
|
#!/usr/bin/awk -f
|
|
|
|
|
|
|
|
BEGIN {
|
2021-05-07 09:07:20 +02:00
|
|
|
RS="\n"
|
|
|
|
FS=" "
|
2021-05-07 08:18:41 +02:00
|
|
|
CSV_HEADER=""
|
|
|
|
CSV_DATA=""
|
2021-05-07 09:07:20 +02:00
|
|
|
# ENERGY created below
|
2021-05-07 08:18:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/LOG2PARSE/{
|
|
|
|
# First extract what we need
|
2021-05-07 09:07:20 +02:00
|
|
|
split($0,fields," ")
|
|
|
|
to_parse=fields[8]
|
2021-05-07 08:18:41 +02:00
|
|
|
gsub(/\[LOG2PARSE\]\(/,"",to_parse)
|
|
|
|
gsub(/\)/,"",to_parse)
|
|
|
|
split(to_parse,tokens,"|")
|
|
|
|
|
|
|
|
# Check if we have to build the csv header
|
|
|
|
if(CSV_HEADER==""){
|
2021-05-07 09:07:20 +02:00
|
|
|
for(i = 1; i<=length(tokens);i++){
|
2021-05-07 08:18:41 +02:00
|
|
|
split(tokens[i],h,":")
|
|
|
|
if(CSV_HEADER=="")
|
|
|
|
CSV_HEADER=h[1]
|
|
|
|
else
|
|
|
|
CSV_HEADER=CSV_HEADER","h[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Build a row
|
|
|
|
row=""
|
2021-05-07 09:07:20 +02:00
|
|
|
for(i = 1; i<=length(tokens);i++){
|
2021-05-07 08:18:41 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-07 09:07:20 +02:00
|
|
|
/\[surf_energy\/INFO\] Energy/ {
|
|
|
|
$7=substr($7, 1, length($7)-1)
|
|
|
|
ENERGY[$7]=$8
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-07 08:18:41 +02:00
|
|
|
END {
|
2021-05-07 09:07:20 +02:00
|
|
|
print(CSV_HEADER",energy");
|
|
|
|
|
|
|
|
# Print data and add up energy values
|
|
|
|
split(CSV_DATA,rows, "\n")
|
|
|
|
for(i=1;i<=length(rows);i++){
|
|
|
|
split(rows[i],fields, ",")
|
|
|
|
print(rows[i]","ENERGY[fields[1]])
|
|
|
|
}
|
2021-05-07 08:18:41 +02:00
|
|
|
}
|