2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

nginx_error: fix style issues reported by shellcheck

This commit is contained in:
Lars Kruse 2018-01-20 01:02:19 +01:00
parent 808a21d4fb
commit 8a68200a67

View File

@ -49,6 +49,7 @@ None known.
=head1 VERSION
1.1 - 2018/01/20
* fix shell style issues reported by shellcheck
* improve readability of symlink configuration code
1.0 - 2017/02/21
@ -99,29 +100,34 @@ http_codes[500]='Internal Server Error'
http_codes[502]='Bad Gateway'
http_codes[503]='Service Unavailable'
do_ () { # Fetch
# parse error counts from log file
do_ () {
local k values
declare -A line_counts
values=`awk '{print $9}' $log | sort | uniq -c`
values=$(awk '{print $9}' "$log" | sort | uniq -c)
if [ -n "$values" ]; then
while read -r line; do
read -a tmp <<< "$line";
line_counts[${tmp[1]}]=${tmp[0]};
read -r -a tmp <<< "$line"
line_counts[${tmp[1]}]=${tmp[0]}
done <<< "$values"
fi
for k in ${!http_codes[@]}; do
for k in "${!http_codes[@]}"; do
echo "error$k.value ${line_counts[$k]:-0}"
done
exit 0
}
do_config () {
local k
echo "graph_title $(basename "$log") - Nginx errors per minute"
echo 'graph_vlabel pages with http error codes / ${graph_period}'
echo "graph_vlabel pages with http error codes / \${graph_period}"
echo "graph_category webserver"
echo "graph_period minute"
echo "graph_info This graph shows nginx error amount per minute"
for k in ${!http_codes[@]}; do
for k in "${!http_codes[@]}"; do
echo "error$k.type DERIVE"
echo "error$k.min 0"
echo "error$k.label $k ${http_codes[$k]}"
@ -129,14 +135,16 @@ do_config () {
exit 0
}
do_autoconf () {
echo yes
exit 0
}
case $1 in
config|autoconf|'')
eval do_$1
eval "do_$1"
esac
exit $?