1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

fix crash if access.log is empty

This commit is contained in:
Florent Thiéry 2017-02-21 17:28:44 +01:00
parent 3cbaa078e7
commit af334370db

View file

@ -97,10 +97,12 @@ http_codes[503]='Service Unavailable'
do_ () { # Fetch do_ () { # Fetch
declare -A line_counts declare -A line_counts
values=`awk '{print $9}' $log | sort | uniq -c` values=`awk '{print $9}' $log | sort | uniq -c`
while read -r line; do if [ -n "$values" ]; then
read -a tmp <<< "$line"; while read -r line; do
line_counts[${tmp[1]}]=${tmp[0]}; read -a tmp <<< "$line";
done <<< "$values" 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}" echo "error$k.value ${line_counts[$k]:-0}"