mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-26 02:48:28 +00:00
Updated new bind9 plugins to correctly handle differing number of lines in the bind9 stats files.
This commit is contained in:
parent
b7d0ef9dfe
commit
8c1e0f618d
3 changed files with 48 additions and 56 deletions
|
@ -26,30 +26,34 @@ if [ "$rndc" = "" ]; then
|
||||||
rndc="/usr/sbin/rndc"
|
rndc="/usr/sbin/rndc"
|
||||||
fi
|
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.
|
# The section we are looking for in the stats.
|
||||||
section="Resolver Statistics"
|
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.
|
# Config mode.
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
echo 'graph_args --lower-limit 0'
|
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_info '${section}' for the Bind9 Name Server'
|
||||||
echo 'graph_scale no'
|
echo 'graph_scale no'
|
||||||
echo 'graph_title Bind9 '${section}
|
echo 'graph_title Bind9 '${section}
|
||||||
echo 'graph_vlabel requests/sec'
|
echo 'graph_vlabel requests/sec'
|
||||||
|
|
||||||
# Output the stat configs.
|
# Output the stat configs.
|
||||||
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
|
eval ${cmd} | while read num name
|
||||||
do
|
do
|
||||||
if [ "$num" = "++" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${num:0:1} = "[" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Shorten some names.
|
# Shorten some names.
|
||||||
label=${name//queries with /}
|
label=${name//queries with /}
|
||||||
label=${label//</below}
|
label=${label//</below}
|
||||||
|
@ -69,23 +73,9 @@ if [ "$1" = "config" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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.
|
# Output the stats.
|
||||||
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
|
eval ${cmd} | while read num name
|
||||||
do
|
do
|
||||||
if [ "$num" = "++" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${num:0:1} = "[" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Shorten some names.
|
# Shorten some names.
|
||||||
label=${name//queries with /}
|
label=${name//queries with /}
|
||||||
label=${label//</below}
|
label=${label//</below}
|
||||||
|
|
|
@ -26,26 +26,34 @@ if [ "$rndc" = "" ]; then
|
||||||
rndc="/usr/sbin/rndc"
|
rndc="/usr/sbin/rndc"
|
||||||
fi
|
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.
|
# The section we are looking for in the stats.
|
||||||
section="Name Server Statistics"
|
section="Name Server Statistics"
|
||||||
lines=10
|
|
||||||
|
# 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.
|
# Config mode.
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
echo 'graph_args --lower-limit 0'
|
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_info '${section}' for the Bind9 Name Server'
|
||||||
echo 'graph_scale no'
|
echo 'graph_scale no'
|
||||||
echo 'graph_title Bind9 '${section}
|
echo 'graph_title Bind9 '${section}
|
||||||
echo 'graph_vlabel requests/sec'
|
echo 'graph_vlabel requests/sec'
|
||||||
|
|
||||||
# Output the stat configs.
|
# Output the stat configs.
|
||||||
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
|
eval ${cmd} | while read num name
|
||||||
do
|
do
|
||||||
if [ "$num" = "++" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Shorten some names.
|
# Shorten some names.
|
||||||
label=${name//queries resulted in /}
|
label=${name//queries resulted in /}
|
||||||
label=${label// answer/}
|
label=${label// answer/}
|
||||||
|
@ -64,19 +72,9 @@ if [ "$1" = "config" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
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.
|
# Output the stats.
|
||||||
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
|
eval ${cmd} | while read num name
|
||||||
do
|
do
|
||||||
if [ "$num" = "++" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Shorten some names.
|
# Shorten some names.
|
||||||
label=${name//queries resulted in /}
|
label=${name//queries resulted in /}
|
||||||
label=${label// answer/}
|
label=${label// answer/}
|
||||||
|
|
|
@ -26,26 +26,34 @@ if [ "$rndc" = "" ]; then
|
||||||
rndc="/usr/sbin/rndc"
|
rndc="/usr/sbin/rndc"
|
||||||
fi
|
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.
|
# The section we are looking for in the stats.
|
||||||
section="Socket I/O Statistics"
|
section="Socket I/O Statistics"
|
||||||
lines=12
|
|
||||||
|
# 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.
|
# Config mode.
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
echo 'graph_args --lower-limit 0'
|
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_info '${section}' for the Bind9 Name Server'
|
||||||
echo 'graph_scale no'
|
echo 'graph_scale no'
|
||||||
echo 'graph_title Bind9 '${section}
|
echo 'graph_title Bind9 '${section}
|
||||||
echo 'graph_vlabel requests/sec'
|
echo 'graph_vlabel requests/sec'
|
||||||
|
|
||||||
# Output the stat configs.
|
# Output the stat configs.
|
||||||
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
|
eval ${cmd} | while read num name
|
||||||
do
|
do
|
||||||
if [ "$num" = "++" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
label=${name}
|
label=${name}
|
||||||
|
|
||||||
# All lowercase.
|
# All lowercase.
|
||||||
|
@ -69,12 +77,8 @@ rm ${stat_file}
|
||||||
${rndc} stats
|
${rndc} stats
|
||||||
|
|
||||||
# Output the stats.
|
# Output the stats.
|
||||||
grep "++ ${section} ++" ${stat_file} -A${lines} | while read num name
|
eval ${cmd} | while read num name
|
||||||
do
|
do
|
||||||
if [ "$num" = "++" ]; then
|
|
||||||
continue;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# All lowercase.
|
# All lowercase.
|
||||||
key=$(echo "$name" | tr 'A-Z' 'a-z')
|
key=$(echo "$name" | tr 'A-Z' 'a-z')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue