From: W.C.A. Wijngaards Date: Fri, 27 Nov 2020 14:08:31 +0000 (+0100) Subject: - Fix contrib/metrics.awk for FreeBSD awk compatibility. X-Git-Tag: release-1.13.0rc3^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56a80fbbf448df7c80ab54467b73bbf5608f129b;p=thirdparty%2Funbound.git - Fix contrib/metrics.awk for FreeBSD awk compatibility. --- diff --git a/contrib/metrics.awk b/contrib/metrics.awk index 4c5a57585..5a7a2569c 100644 --- a/contrib/metrics.awk +++ b/contrib/metrics.awk @@ -7,7 +7,7 @@ # remote-control: control-enable: yes # Can use it like unbound-control stats | awk -f "metrics.awk" -BEGINFILE { +BEGIN { FS="="; } # everything like total.num.queries=value is put in val["total.num.queries"] @@ -15,10 +15,7 @@ BEGINFILE { val[$1]=$2; } # print the output metrics -ENDFILE { - # sort array by index - asorti(val, sorted); - +END { print "# HELP unbound_hits_queries Unbound DNS traffic and cache hits" print "# TYPE unbound_hits_queries gauge" print "unbound_hits_queries{type=\"total.num.queries\"} " val["total.num.queries"]; @@ -73,8 +70,7 @@ ENDFILE { print "# HELP unbound_by_type_queries Unbound DNS queries by type" print "# TYPE unbound_by_type_queries gauge" - for(s in sorted) { - x = sorted[s]; + for(x in val) { if(x ~ /^num.query.type./) { if(val[x] != "") { split(x, a, "."); @@ -86,8 +82,7 @@ ENDFILE { print "# HELP unbound_by_class_queries Unbound DNS queries by class" print "# TYPE unbound_by_class_queries gauge" - for(s in sorted) { - x = sorted[s]; + for(x in val) { if(x ~ /^num.query.class./) { if(val[x] != "") { split(x, a, "."); @@ -99,8 +94,7 @@ ENDFILE { print "# HELP unbound_by_opcode_queries Unbound DNS queries by opcode" print "# TYPE unbound_by_opcode_queries gauge" - for(s in sorted) { - x = sorted[s]; + for(x in val) { if(x ~ /^num.query.opcode./) { if(val[x] != "") { split(x, a, "."); @@ -112,8 +106,7 @@ ENDFILE { print "# HELP unbound_by_rcode_queries Unbound DNS answers by rcode" print "# TYPE unbound_by_rcode_queries gauge" - for(s in sorted) { - x = sorted[s]; + for(x in val) { if(x ~ /^num.answer.rcode./) { if(val[x] != "") { split(x, a, "."); @@ -125,8 +118,7 @@ ENDFILE { print "# HELP unbound_by_flags_queries Unbound DNS queries by flags" print "# TYPE unbound_by_flags_queries gauge" - for(s in sorted) { - x = sorted[s]; + for(x in val) { if(x ~ /^num.query.flags./) { if(val[x] != "") { split(x, a, "."); diff --git a/doc/Changelog b/doc/Changelog index 355222bf4..1019e32ae 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -3,6 +3,7 @@ - Fix when use free buffer to initialize rbtree for stream reuse. - Fix compile warnings for windows. - Fix compile warnings in rpz initialization. + - Fix contrib/metrics.awk for FreeBSD awk compatibility. 26 November 2020: Wouter - Fix to omit UDP receive errors from log, if verbosity low.