[add] added legend alignment option
This commit is contained in:
@@ -19,7 +19,11 @@ col_average=5
|
|||||||
col_max=6
|
col_max=6
|
||||||
col_deviation=7
|
col_deviation=7
|
||||||
|
|
||||||
|
# legend alignment
|
||||||
|
legend_align="center"
|
||||||
|
|
||||||
if(exists("TZ")) tz=TZ*3600
|
if(exists("TZ")) tz=TZ*3600
|
||||||
|
if(exists("LEGEND_ALIGN")) legend_align=LEGEND_ALIGN
|
||||||
# gnuplot does not like spaces in -e so we recreate them here via system call to sed
|
# gnuplot does not like spaces in -e so we recreate them here via system call to sed
|
||||||
if(exists("SERVERS")) server_list=system("echo '".SERVERS."' | sed 's|;| |g'")
|
if(exists("SERVERS")) server_list=system("echo '".SERVERS."' | sed 's|;| |g'")
|
||||||
if(exists("CSV_FILE")) csv_file=CSV_FILE
|
if(exists("CSV_FILE")) csv_file=CSV_FILE
|
||||||
@@ -46,7 +50,9 @@ set key box lt rgb "#000000"
|
|||||||
set key width 1.5
|
set key width 1.5
|
||||||
set key height 0.5
|
set key height 0.5
|
||||||
set key samplen 0.1
|
set key samplen 0.1
|
||||||
set key center top
|
if (legend_align eq "left") set key left top
|
||||||
|
if (legend_align eq "center") set key center top
|
||||||
|
if (legend_align eq "right") set key right top
|
||||||
## axis
|
## axis
|
||||||
set y2tics # enable second axis
|
set y2tics # enable second axis
|
||||||
set ytics nomirror # dont show the tics on that side
|
set ytics nomirror # dont show the tics on that side
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Backup Script Version $script_version
|
|||||||
usage: SERVER:LABEL [...]
|
usage: SERVER:LABEL [...]
|
||||||
[--file|-f CSV_FILE] [--limit-y|-l Y_MAX] [--time-zone|-t UTC_HOURS]
|
[--file|-f CSV_FILE] [--limit-y|-l Y_MAX] [--time-zone|-t UTC_HOURS]
|
||||||
[--start-date|-S DATE] [--end-date|-E DATE] [--show-hours|-H HOURS]
|
[--start-date|-S DATE] [--end-date|-E DATE] [--show-hours|-H HOURS]
|
||||||
|
[--align-legend|-a POSITION]
|
||||||
|
|
||||||
args: SERVER:LABEL [...]
|
args: SERVER:LABEL [...]
|
||||||
Space sperated list of servers to plot. Needs to be before any other args.
|
Space sperated list of servers to plot. Needs to be before any other args.
|
||||||
@@ -35,6 +36,10 @@ Backup Script Version $script_version
|
|||||||
HOURSE defaults to $default_hours and sets the Y Axis starting point HOURS before the end point.
|
HOURSE defaults to $default_hours and sets the Y Axis starting point HOURS before the end point.
|
||||||
Will be overwritten by -s if declared later.
|
Will be overwritten by -s if declared later.
|
||||||
|
|
||||||
|
--align-legend|-a POSITION
|
||||||
|
POSITION can be left, center or right and aligns the legend of the plot.
|
||||||
|
Default is $default_align alignment.
|
||||||
|
|
||||||
example: ${BASH_SOURCE[0]} example.com:example 0.0.0.0:localhost --limit-y 100 --show-hours 5 --end-date "$(date +"%Y-%m-%d %H:%M")" --time-zone $(date +%-:::z)
|
example: ${BASH_SOURCE[0]} example.com:example 0.0.0.0:localhost --limit-y 100 --show-hours 5 --end-date "$(date +"%Y-%m-%d %H:%M")" --time-zone $(date +%-:::z)
|
||||||
${BASH_SOURCE[0]} example.com:example 0.0.0.0:localhost -S "$(date --date='yesterday' +"%Y-%m-%d")" -E "$(date +"%Y-%m-%d")" -f data.csv
|
${BASH_SOURCE[0]} example.com:example 0.0.0.0:localhost -S "$(date --date='yesterday' +"%Y-%m-%d")" -E "$(date +"%Y-%m-%d")" -f data.csv
|
||||||
|
|
||||||
@@ -56,6 +61,7 @@ default_start_date=$(date --date="1 week ago" -Is)
|
|||||||
default_end_date=$(date -Is)
|
default_end_date=$(date -Is)
|
||||||
default_hours=24
|
default_hours=24
|
||||||
default_tz=$(date +%-:::z)
|
default_tz=$(date +%-:::z)
|
||||||
|
default_align=center
|
||||||
|
|
||||||
# end configuration
|
# end configuration
|
||||||
##############################
|
##############################
|
||||||
@@ -131,7 +137,8 @@ main()
|
|||||||
{
|
{
|
||||||
local unknown_args=()
|
local unknown_args=()
|
||||||
local servers=$(load_server_env)
|
local servers=$(load_server_env)
|
||||||
local csv_file="$default_csv" limit time_zone="$default_tz" start_date end_date hours
|
local csv_file="$default_csv"
|
||||||
|
local limit time_zone="$default_tz" start_date end_date hours legend="$default_align"
|
||||||
|
|
||||||
# if servers passed as args reset list and parse
|
# if servers passed as args reset list and parse
|
||||||
[[ $# -gt 0 ]] && [[ $1 != -* ]] && servers=""
|
[[ $# -gt 0 ]] && [[ $1 != -* ]] && servers=""
|
||||||
@@ -205,6 +212,16 @@ main()
|
|||||||
shift # past value
|
shift # past value
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
--align-legend|-a)
|
||||||
|
if [[ $2 == -* ]] || [[ -z "$2" ]]; then
|
||||||
|
echo "log WAR main Invalid legend alignment, using default: $legend"
|
||||||
|
shift # past argument, no value
|
||||||
|
else
|
||||||
|
legend=$2
|
||||||
|
shift # past argument
|
||||||
|
shift # past value
|
||||||
|
fi
|
||||||
|
;;
|
||||||
--help|-h)
|
--help|-h)
|
||||||
help
|
help
|
||||||
exit
|
exit
|
||||||
@@ -230,6 +247,7 @@ main()
|
|||||||
[[ ! -z "$start_date" ]] && plot_env[X_MIN]=$start_date
|
[[ ! -z "$start_date" ]] && plot_env[X_MIN]=$start_date
|
||||||
[[ ! -z "$end_date" ]] && plot_env[X_MAX]=$end_date
|
[[ ! -z "$end_date" ]] && plot_env[X_MAX]=$end_date
|
||||||
[[ ! -z "$hours" ]] && set_relative_X_MIN $hours
|
[[ ! -z "$hours" ]] && set_relative_X_MIN $hours
|
||||||
|
[[ ! -z "$legend" ]] && plot_env[LEGEND_ALIGN]=\"$legend\"
|
||||||
|
|
||||||
[[ ${#unknown_args[@]} -ne 0 ]] && log main WARNING "ignored unknown args: ${unknown_args[@]}"
|
[[ ${#unknown_args[@]} -ne 0 ]] && log main WARNING "ignored unknown args: ${unknown_args[@]}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user