mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
nginx_error: improve readability of symlink configuration code
This commit is contained in:
parent
f4c192469f
commit
808a21d4fb
1 changed files with 19 additions and 14 deletions
|
@ -48,8 +48,12 @@ None known.
|
|||
|
||||
=head1 VERSION
|
||||
|
||||
1.1 - 2018/01/20
|
||||
* improve readability of symlink configuration code
|
||||
|
||||
1.0 - 2017/02/21
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
vovansystems@gmail.com, 2013
|
||||
|
@ -60,24 +64,25 @@ GPLv3
|
|||
|
||||
=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
|
||||
domain=${domain:1}
|
||||
if [ -z $logpattern ]; then
|
||||
logpattern='a.*.log'
|
||||
fi
|
||||
logpattern=${logpattern/\*/$domain}
|
||||
|
||||
# derive the name of the log file from a potential symlink-configured virtual host
|
||||
script_name=$(basename "$0")
|
||||
plugin_suffix=${script_name#nginx_error}
|
||||
if [ -n "${plugin_suffix#_}" ]; then
|
||||
# a domain was given via symlink configuration: adjust the logpattern
|
||||
domain=${plugin_suffix#_}
|
||||
# default logpattern for symlink configuration mode
|
||||
logpattern=${logpattern:-a.*.log}
|
||||
log_filename=${logpattern/\*/$domain}
|
||||
else
|
||||
logpattern='access.log'
|
||||
log_filename='access.log'
|
||||
fi
|
||||
|
||||
log="$logpath/$logpattern"
|
||||
log="$logpath/$log_filename"
|
||||
|
||||
# declaring an array with http status codes, we are interested in
|
||||
declare -A http_codes
|
||||
|
@ -111,7 +116,7 @@ do_ () { # Fetch
|
|||
}
|
||||
|
||||
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_category webserver"
|
||||
echo "graph_period minute"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue