diff --git a/contrib/unbound_munin_ b/contrib/unbound_munin_ index 6956d09a4..d4660f4b4 100755 --- a/contrib/unbound_munin_ +++ b/contrib/unbound_munin_ @@ -97,6 +97,7 @@ BSD . ${MUNIN_LIBDIR}/plugins/plugin.sh state="${MUNIN_PLUGSTATE}/unbound.state" +seentags="${MUNIN_PLUGSTATE}/unbound-seentags.state" conf=${unbound_conf:-/usr/local/etc/unbound/unbound.conf} ctrl=${unbound_control:-/usr/local/sbin/unbound-control} warn=${spoof_warn:-1000} @@ -119,6 +120,18 @@ get_value ( ) { fi } +# Update list of seen query types etc to seentags file. This is run while +# holding the lock, after the state file is updated. +update_seentags() { + tmplist="$(cat ${seentags} 2> /dev/null) +num.query.type.A +num.query.class.IN +num.query.opcode.QUERY +num.answer.rcode.NOERROR +" + (echo "${tmplist}"; grep ^num ${state} | sed -e 's/=.*//') | sort -u > ${seentags} +} + # download the state from the unbound server. get_state ( ) { # obtain lock for fetching the state @@ -166,6 +179,7 @@ get_state ( ) { rm -f $lock exit 1 fi + update_seentags rm -f $lock } @@ -282,8 +296,7 @@ if test "$1" = "config" ; then echo "graph_vlabel queries / \${graph_period}" echo "graph_scale no" echo "graph_category DNS" - for x in `grep "^num.query.type" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` + for nm in `grep "^num.query.type" $seentags`; do tp=`echo $nm | sed -e s/num.query.type.//` p_config "$nm" "$tp" "ABSOLUTE" done @@ -295,8 +308,7 @@ if test "$1" = "config" ; then echo "graph_vlabel queries / \${graph_period}" echo "graph_scale no" echo "graph_category DNS" - for x in `grep "^num.query.class" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` + for nm in `grep "^num.query.class" $seentags`; do tp=`echo $nm | sed -e s/num.query.class.//` p_config "$nm" "$tp" "ABSOLUTE" done @@ -308,8 +320,7 @@ if test "$1" = "config" ; then echo "graph_vlabel queries / \${graph_period}" echo "graph_scale no" echo "graph_category DNS" - for x in `grep "^num.query.opcode" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` + for nm in `grep "^num.query.opcode" $seentags`; do tp=`echo $nm | sed -e s/num.query.opcode.//` p_config "$nm" "$tp" "ABSOLUTE" done @@ -321,8 +332,7 @@ if test "$1" = "config" ; then echo "graph_vlabel answer packets / \${graph_period}" echo "graph_scale no" echo "graph_category DNS" - for x in `grep "^num.answer.rcode" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` + for nm in `grep "^num.answer.rcode" $seentags`; do tp=`echo $nm | sed -e s/num.answer.rcode.//` p_config "$nm" "$tp" "ABSOLUTE" done @@ -465,27 +475,23 @@ memory) done ;; by_type) - for x in `grep "^num.query.type" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` - print_value_line $nm $x + for nm in `grep "^num.query.type" $seentags`; do + print_value $nm done ;; by_class) - for x in `grep "^num.query.class" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` - print_value_line $nm $x + for nm in `grep "^num.query.class" $seentags`; do + print_value $nm done ;; by_opcode) - for x in `grep "^num.query.opcode" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` - print_value_line $nm $x + for nm in `grep "^num.query.opcode" $seentags`; do + print_value $nm done ;; by_rcode) - for x in `grep "^num.answer.rcode" $state`; do - nm=`echo $x | sed -e 's/=.*$//'` - print_value_line $nm $x + for nm in `grep "^num.answer.rcode" $seentags`; do + print_value $nm $x done print_value "num.answer.secure" print_value "num.answer.bogus"