1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

bind9_*_stats: fix using env variable stat_file

previously only stat_file would only be used for data cleanup not for
fetching the data. also fixed some shellcheck warnings.
This commit is contained in:
Andreas Perhab 2021-07-23 10:10:53 +02:00 committed by Lars Kruse
parent 07e747a1e8
commit 323f69fd86
3 changed files with 26 additions and 26 deletions

View file

@ -40,15 +40,15 @@ section="Socket I/O Statistics"
# - 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 "^\["'
cmd='cat "'"$stat_file"'" | sed "0,/^\+\+ '"${section//\//\\/}"' \+\+/d" | sed -e "/^\+\+/,\$d" | grep -v "^\["'
# Config mode.
if [ "$1" = "config" ]; then
echo 'graph_args --lower-limit 0'
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_title Bind9 '${section}
echo 'graph_title Bind9 '"${section}"
echo 'graph_vlabel requests/${graph_period}'
# Output the stat configs.
@ -62,9 +62,9 @@ if [ "$1" = "config" ]; then
# Now change names to all have no spaces.
key=${key//[\/ - ]/_}
echo ${key}.label ${label}
echo ${key}.info ${name}
echo ${key}.type COUNTER
echo "${key}.label ${label}"
echo "${key}.info ${name}"
echo "${key}.type COUNTER"
done
# If dirty config capability is enabled then fall through
@ -73,7 +73,7 @@ if [ "$1" = "config" ]; then
fi
# Output the stats.
eval ${cmd} | while read num name
eval "${cmd}" | while read -r num name
do
# All lowercase.
key=$(echo "$name" | tr 'A-Z' 'a-z')
@ -81,5 +81,5 @@ do
# Now change names to all have no spaces.
key=${key//[\/ - ]/_}
echo ${key}.value ${num}
echo "${key}.value ${num}"
done