Testing
cat > vm_parser.awk << 'EOF'
{
if (match($0, /(VM_[^ ]+?|CreateVM)/)) {
task = substr($0, RSTART, RLENGTH)
# Clean task name more thoroughly
gsub(/_REQ[0-9]+.*/, "", task)
gsub(/_VDA[0-9A-Z]+.*/, "", task)
gsub(/_is-[^ ,]+.*/, "", task)
gsub(/_db-[^ ,]+.*/, "", task)
gsub(/_ap-[^ ,]+.*/, "", task)
gsub(/_pg.*01c.*/, "", task)
# Prevent duplicate processing on same line
if (processed[$0]) next
processed[$0] = 1
# Get status
if (index(tolower($0), "failed") > 0) {
status = "FAILED"
} else if (index(tolower($0), "completed") > 0) {
status = "completed"
} else {
status = "unknown"
}
print task "," status
}
}
EOF
{
echo "task_name,status"
awk -f vm_parser.awk vm_tasks.log
} > vm_tasks.csv
Comments
Post a Comment