1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-25 02:18:08 +00:00

Updated new bind9 plugins to correctly handle differing number of lines in the bind9 stats files.

This commit is contained in:
Dave Fennell 2012-12-20 14:01:26 +00:00
parent b7d0ef9dfe
commit 8c1e0f618d
3 changed files with 48 additions and 56 deletions

View file

@ -26,30 +26,34 @@ if [ "$rndc" = "" ]; then
rndc="/usr/sbin/rndc"
fi
# Blank the stats file (else stats are appended not replaced)
rm ${stat_file}
# Ask to bind to build new one
${rndc} stats
# The section we are looking for in the stats.
section="Resolver Statistics"
lines=18
# Get all the lines in the section:
# - cat the file
# - use sed to get lines after (and excluding) the section start tag
# - use sed to get lines up to (and excluding) the next section start tag
# - use grep to remove any lines starting with a [
cmd='cat "/var/cache/bind/named.stats" | sed "0,/^\+\+ '${section}' \+\+/d" | sed -e "/^\+\+/,\$d" | grep -v "^\["'
# Config mode.
if [ "$1" = "config" ]; then
echo 'graph_args --lower-limit 0'
echo 'graph_category network'
echo 'graph_category dns'
echo 'graph_info '${section}' for the Bind9 Name Server'
echo 'graph_scale no'
echo 'graph_title Bind9 '${section}
echo 'graph_vlabel requests/sec'
# Output the stat configs.
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
eval ${cmd} | while read num name
do
if [ "$num" = "++" ]; then
continue;
fi
if [ ${num:0:1} = "[" ]; then
continue;
fi
# Shorten some names.
label=${name//queries with /}
label=${label//</below}
@ -69,23 +73,9 @@ if [ "$1" = "config" ]; then
exit 0
fi
# Blank the stats file (else stats are appended not replaced)
rm ${stat_file}
# Ask to bind to build new one
${rndc} stats
# Output the stats.
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
eval ${cmd} | while read num name
do
if [ "$num" = "++" ]; then
continue;
fi
if [ ${num:0:1} = "[" ]; then
continue;
fi
# Shorten some names.
label=${name//queries with /}
label=${label//</below}