. ${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}
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
rm -f $lock
exit 1
fi
+ update_seentags
rm -f $lock
}
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
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
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
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
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"