From 7ed71b441d4debfa427c2860d32e921b78df4727 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Sat, 20 Jan 2018 01:36:03 +0100 Subject: [PATCH] nginx_error: add support for 'dirty config' capability --- plugins/nginx/nginx_error | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/nginx/nginx_error b/plugins/nginx/nginx_error index 667aef2c..4b22081e 100755 --- a/plugins/nginx/nginx_error +++ b/plugins/nginx/nginx_error @@ -49,6 +49,7 @@ None known. =head1 VERSION 1.1 - 2018/01/20 + * add 'dirty config' capability support * fix shell style issues reported by shellcheck * improve readability of symlink configuration code @@ -102,7 +103,7 @@ http_codes[503]='Service Unavailable' # parse error counts from log file -do_ () { +do_fetch () { local count status_code declare -A line_counts while read -r count status_code; do @@ -112,7 +113,6 @@ do_ () { for status_code in "${!http_codes[@]}"; do echo "error${status_code}.value ${line_counts[$status_code]:-0}" done - exit 0 } @@ -128,19 +128,26 @@ do_config () { echo "error${status_code}.min 0" echo "error${status_code}.label $status_code ${http_codes[$status_code]}" done - exit 0 } do_autoconf () { echo yes - exit 0 } case $1 in - config|autoconf|'') - eval "do_$1" + config) + do_config + # support "dirty config" capability + if [ "${MUNIN_CAP_DIRTYCONFIG:-}" = "1" ]; then do_fetch; fi + ;; + autoconf) + do_autoconf + ;; + '') + do_fetch + ;; esac exit $?