mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
nginx_error: improve readability of array accesses
This commit is contained in:
parent
8a68200a67
commit
0e864944d7
@ -103,34 +103,30 @@ http_codes[503]='Service Unavailable'
|
||||
|
||||
# parse error counts from log file
|
||||
do_ () {
|
||||
local k values
|
||||
local count status_code
|
||||
declare -A line_counts
|
||||
values=$(awk '{print $9}' "$log" | sort | uniq -c)
|
||||
if [ -n "$values" ]; then
|
||||
while read -r line; do
|
||||
read -r -a tmp <<< "$line"
|
||||
line_counts[${tmp[1]}]=${tmp[0]}
|
||||
done <<< "$values"
|
||||
fi
|
||||
while read -r count status_code; do
|
||||
line_counts[$status_code]=$count
|
||||
done <<< "$(awk '{print $9}' "$log" | sort | uniq -c)"
|
||||
|
||||
for k in "${!http_codes[@]}"; do
|
||||
echo "error$k.value ${line_counts[$k]:-0}"
|
||||
for status_code in "${!http_codes[@]}"; do
|
||||
echo "error${status_code}.value ${line_counts[$status_code]:-0}"
|
||||
done
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
do_config () {
|
||||
local k
|
||||
local status_code
|
||||
echo "graph_title $(basename "$log") - Nginx errors per minute"
|
||||
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
|
||||
echo "error$k.type DERIVE"
|
||||
echo "error$k.min 0"
|
||||
echo "error$k.label $k ${http_codes[$k]}"
|
||||
for status_code in "${!http_codes[@]}"; do
|
||||
echo "error${status_code}.type DERIVE"
|
||||
echo "error${status_code}.min 0"
|
||||
echo "error${status_code}.label $status_code ${http_codes[$status_code]}"
|
||||
done
|
||||
exit 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user