1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 22:25:23 +00:00

nginx_error: improve readability of symlink configuration code

This commit is contained in:
Lars Kruse 2018-01-20 01:00:12 +01:00
parent f4c192469f
commit 808a21d4fb

View file

@ -48,8 +48,12 @@ None known.
=head1 VERSION =head1 VERSION
1.1 - 2018/01/20
* improve readability of symlink configuration code
1.0 - 2017/02/21 1.0 - 2017/02/21
=head1 AUTHOR =head1 AUTHOR
vovansystems@gmail.com, 2013 vovansystems@gmail.com, 2013
@ -60,24 +64,25 @@ GPLv3
=cut =cut
if [ -z $logpath ]; then
logpath='/var/log/nginx'
fi
name=`basename $0` # default environment variable values
logpath=${logpath:-/var/log/nginx}
domain=${name/nginx_error/}
if [[ $domain != '_' && ${#domain} -ne 0 ]]; then # derive the name of the log file from a potential symlink-configured virtual host
domain=${domain:1} script_name=$(basename "$0")
if [ -z $logpattern ]; then plugin_suffix=${script_name#nginx_error}
logpattern='a.*.log' if [ -n "${plugin_suffix#_}" ]; then
fi # a domain was given via symlink configuration: adjust the logpattern
logpattern=${logpattern/\*/$domain} domain=${plugin_suffix#_}
# default logpattern for symlink configuration mode
logpattern=${logpattern:-a.*.log}
log_filename=${logpattern/\*/$domain}
else else
logpattern='access.log' log_filename='access.log'
fi fi
log="$logpath/$logpattern" log="$logpath/$log_filename"
# declaring an array with http status codes, we are interested in # declaring an array with http status codes, we are interested in
declare -A http_codes declare -A http_codes
@ -111,7 +116,7 @@ do_ () { # Fetch
} }
do_config () { do_config () {
echo "graph_title $logpattern - 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"