Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/awk -f
- BEGIN{
- newCommandName = ""
- lastCommandName = ""
- firstTag = 1
- firstMetric = 1
- }
- function red(s) {
- printf "\033[1;31m" s "\033[0m "
- }
- function green(s) {
- printf "\033[1;32m" s "\033[0m "
- }
- function blue(s) {
- printf "\033[1;34m" s "\033[0m "
- }
- /^Command: .+ output: Map/{
- if(firstTag == 1){
- print(blue("============================ Tags found ============================"))
- firstTag = 0
- }
- commandName = $2
- gsub(/'+/, "", commandName)
- split($0, tagArray, "(")
- split(tagArray[2], tagArray, ")")
- if(tagArray[1] != ""){
- print(red(commandName))
- split(tagArray[1], tagArray, ", ")
- for(i in tagArray){
- print(tagArray[i])
- }
- print("\r")
- }
- }
- /INFO -- Command: '/{
- if(firstMetric == 1){
- firstMetric = 0
- } else {
- print(red("\nCount per metric:"))
- }
- for(metric in foundMetrics){
- print metric " had " foundMetrics[metric] " results"
- }
- delete foundMetrics
- print("")
- commandName = $NF
- }
- /INFO -- Found [0-9]+ metrics:/{
- metricsFound = $4
- gsub(/[[\r']+/, "", commandName)
- print(green("================================== indeni script: " commandName " ==================================\n"))
- print(red("Total results:\n") metricsFound "\n")
- print(red("Metric examples:"))
- }
- /Metric Name/{
- sub(/^INFO -- Metric Name: /, "", $0)
- if($1 in foundMetrics){
- newMetric = 0
- foundMetrics[$1] = foundMetrics[$1] + 1
- } else {
- newMetric = 1
- print($0)
- foundMetrics[$1] = 1
- }
- }
- /^[ \}]+/{
- if(newMetric == 1){
- if(!(match($0, /^[:]+/))){
- print($0)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement