Skip to content

Commit

Permalink
bind2 PMDA: fix PMID assignments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kmcdonell committed Jan 9, 2025
1 parent 2116cd2 commit 78e1a68
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 14 deletions.
12 changes: 6 additions & 6 deletions qa/1087.out
Original file line number Diff line number Diff line change
Expand Up @@ -471,13 +471,13 @@ bind2.resolver.total.resstats.QryRTT100 PMID: 25.0.184 []
Help: <empty entry>
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: <empty entry>
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: <empty entry>
Expand Down Expand Up @@ -1666,13 +1666,13 @@ bind2.resolver.total.resstats.QryRTT100 PMID: 25.0.184 []
Help: <empty entry>
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: <empty entry>
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: <empty entry>
Expand Down Expand Up @@ -3071,13 +3071,13 @@ bind2.resolver.total.resstats.QryRTT100 PMID: 25.0.184 []
Help: <empty entry>
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: <empty entry>
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: <empty entry>
Expand Down
54 changes: 51 additions & 3 deletions src/pmdas/bind2/mk.rewrite
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<End-of-File >rewrite.conf
# Rewriting rules for bind2 PMDA metrics to ensure consistent
# PMIDs across Bind versions
Expand All @@ -22,15 +26,18 @@ End-of-File
( grep BIND2 <../../pmns/stdpmid ;
awk <pmdabind2.pl '
$2 == "%known_pmids" { inlist = 1; next }
$1 == "#" { next }
/^[ ]*#/ { next }
inlist == 1 && $1 == ");" { exit }
inlist == 1 { print }' \
| tee $tmp.list \
| sed \
-e '/UNASSIGNED/d' \
-e "s/'//g" \
-e 's/,//g' \
-e 's/^ */metric /' \
-e 's/[ ][ ]*\([0-9][0-9]*\)/ { pmid -> BIND2.0.\1 }/' \
) | ../../pmcpp/pmcpp.static -P >>rewrite.conf
) \
| ../../pmcpp/pmcpp.static -P >>rewrite.conf

cat <<'End-of-File' >>rewrite.conf
Expand All @@ -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
11 changes: 6 additions & 5 deletions src/pmdas/bind2/pmdabind2.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 78e1a68

Please sign in to comment.