From 78e1a68b8c1c7ae4c2ebf1acf3715eb1757d2bf3 Mon Sep 17 00:00:00 2001 From: Ken McDonell Date: Fri, 10 Jan 2025 08:48:29 +1100 Subject: [PATCH] bind2 PMDA: fix PMID assignments Earlier commit had a few botches in the assignment of the PMID's item field to known metrics. Fix these, and harden mk.rewrite, so that in addition to generating the pmlogrewrite config, this script now also - reports error and exit status 1 for + duplicate metric names + duplicate PMIDs - reports warning and exit status 0 for + gaps in the range of assigned item field values If these had been in place, the earlier (wrong) changes in pmdabind2.pl would have been caught with build failures. --- qa/1087.out | 12 ++++---- src/pmdas/bind2/mk.rewrite | 54 ++++++++++++++++++++++++++++++++++-- src/pmdas/bind2/pmdabind2.pl | 11 ++++---- 3 files changed, 63 insertions(+), 14 deletions(-) diff --git a/qa/1087.out b/qa/1087.out index 3adc30368b..c28f0bac97 100644 --- a/qa/1087.out +++ b/qa/1087.out @@ -471,13 +471,13 @@ bind2.resolver.total.resstats.QryRTT100 PMID: 25.0.184 [] Help: value 2 -bind2.resolver.total.resstats.QryRTT1600 PMID: 25.0.219 [] +bind2.resolver.total.resstats.QryRTT1600 PMID: 25.0.212 [] Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff Semantics: counter Units: count Help: value 0 -bind2.resolver.total.resstats.QryRTT1600p PMID: 25.0.220 [] +bind2.resolver.total.resstats.QryRTT1600p PMID: 25.0.213 [] Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff Semantics: counter Units: count Help: @@ -1666,13 +1666,13 @@ bind2.resolver.total.resstats.QryRTT100 PMID: 25.0.184 [] Help: value 0 -bind2.resolver.total.resstats.QryRTT1600 PMID: 25.0.219 [] +bind2.resolver.total.resstats.QryRTT1600 PMID: 25.0.212 [] Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff Semantics: counter Units: count Help: value 0 -bind2.resolver.total.resstats.QryRTT1600p PMID: 25.0.220 [] +bind2.resolver.total.resstats.QryRTT1600p PMID: 25.0.213 [] Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff Semantics: counter Units: count Help: @@ -3071,13 +3071,13 @@ bind2.resolver.total.resstats.QryRTT100 PMID: 25.0.184 [] Help: value 3628 -bind2.resolver.total.resstats.QryRTT1600 PMID: 25.0.219 [] +bind2.resolver.total.resstats.QryRTT1600 PMID: 25.0.212 [] Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff Semantics: counter Units: count Help: value 6 -bind2.resolver.total.resstats.QryRTT1600p PMID: 25.0.220 [] +bind2.resolver.total.resstats.QryRTT1600p PMID: 25.0.213 [] Data Type: 32-bit unsigned int InDom: PM_INDOM_NULL 0xffffffff Semantics: counter Units: count Help: diff --git a/src/pmdas/bind2/mk.rewrite b/src/pmdas/bind2/mk.rewrite index 989e8622b0..fd0f3a67a9 100755 --- a/src/pmdas/bind2/mk.rewrite +++ b/src/pmdas/bind2/mk.rewrite @@ -11,6 +11,10 @@ # and generate pmlogrewrite(1) rules to force the PMIDs to be correct. # +tmp=/var/tmp/mk.rewrite-$$ +status=0 +trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15 + cat <rewrite.conf # Rewriting rules for bind2 PMDA metrics to ensure consistent # PMIDs across Bind versions @@ -22,15 +26,18 @@ End-of-File ( grep BIND2 <../../pmns/stdpmid ; awk BIND2.0.\1 }/' \ -) | ../../pmcpp/pmcpp.static -P >>rewrite.conf +) \ +| ../../pmcpp/pmcpp.static -P >>rewrite.conf cat <<'End-of-File' >>rewrite.conf @@ -48,5 +55,46 @@ metric bind2.memory.total.Malloced { units -> 1,0,0,byte,0,0 } metric bind2.memory.total.TotalUse { units -> 1,0,0,byte,0,0 } End-of-File -exit +# check for (a) duplicate metric names (fatal), (b) duplicates in +# the item field of PMID (fatal) and (c) missing values in the sequence +# of item fields (warning) +# +# lines in $tmp.list look like +# 'bind2.memory.total.InUse', 5, +# +export LC_COLLATE=POSIX + +sed <$tmp.list \ + -e "s/^[ ]*'//" \ + -e "s/'.*//" \ +| sort >$tmp.metrics +uniq -c <$tmp.metrics \ +| sed -e '/^ *1 /d' \ +| while read count metric +do + echo "Error: Duplicate metric $metric occurs $count times" + status=1 +done + +sed <$tmp.list \ + -e "s/.*',[^0-9]*//" \ + -e 's/,[ ]*$//' \ +| sort -n >$tmp.items + +uniq -c <$tmp.items \ +| sed -e '/^ *1 /d' \ +| while read count item +do + echo "Error: Duplicate PMID BIND2.0.$item occurs $count times" + status=1 +done + +awk <$tmp.items ' +NR == 1 { last = $1; next } +$1 != last + 1 { for (j = last+1; j < $1; j++) + print "Warning: PMID BIND2.0." j " is missing" + } + { last = $1 }' + +exit diff --git a/src/pmdas/bind2/pmdabind2.pl b/src/pmdas/bind2/pmdabind2.pl index de80118ea1..214eb41f9c 100755 --- a/src/pmdas/bind2/pmdabind2.pl +++ b/src/pmdas/bind2/pmdabind2.pl @@ -402,8 +402,8 @@ 'bind2.resolver.total.resstats.OtherError', 182, 'bind2.resolver.total.resstats.QryRTT10', 183, 'bind2.resolver.total.resstats.QryRTT100', 184, - 'bind2.resolver.total.resstats.QryRTT1800', 165, - 'bind2.resolver.total.resstats.QryRTT1800p', 166, + 'bind2.resolver.total.resstats.QryRTT1800', 185, + 'bind2.resolver.total.resstats.QryRTT1800p', 186, 'bind2.resolver.total.resstats.QryRTT500', 187, 'bind2.resolver.total.resstats.QryRTT800', 188, 'bind2.resolver.total.resstats.QueryAbort', 189, @@ -436,9 +436,10 @@ 'bind2.resolver.total.resstats.CookieClientOk', 216, 'bind2.resolver.total.resstats.CookieIn', 217, 'bind2.resolver.total.resstats.NextItem', 218, - # enabled by resolver metrics patch (for bind version 9.11 or later) - 'bind2.resolver.total.resstats.QryRTT1600', 219, - 'bind2.resolver.total.resstats.QryRTT1600p', 220, + # duplicates from earlier commit botch ... these are available + 'UNASSIGNED.219', 219, + 'UNASSIGNED.220', 220, + 'UNASSIGNED.221', 221, 'bind2.resolver.total.resstats.ServerCookieOut', 222, # enabled by resolver meteric patch (for bind version somwhere between 9.12 and 9.18) 'bind2.resolver.total.resqtype.AAAA', 223,