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