clean up
This commit is contained in:
parent
449c1b9289
commit
e99763c381
15
lib/main.sh
15
lib/main.sh
|
@ -54,14 +54,14 @@ main_init () {
|
|||
|
||||
main_collect () {
|
||||
# check if reporter exists
|
||||
if ! in_array $(resolve_reporter $__REPORTER) "$__AVAILABLE_REPORTERS"; then
|
||||
if ! in_array $(get_name_for_reporter $__REPORTER) "$__AVAILABLE_REPORTERS"; then
|
||||
echo "Error: reporter '$__REPORTER' is not available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if metrics exist
|
||||
for metric in $__METRICS; do
|
||||
if ! in_array $(resolve_metric $metric) "$__AVAILABLE_METRICS"; then
|
||||
if ! in_array $(get_name_for_metric $metric) "$__AVAILABLE_METRICS"; then
|
||||
echo "Error: metric '$metric' is not available"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -76,9 +76,9 @@ main_collect () {
|
|||
' 13 INT TERM EXIT
|
||||
|
||||
# init reporter
|
||||
local reporter_alias=$(resolve_reporter $__REPORTER)
|
||||
local reporter_file=$(resolve_reporter $__REPORTER)
|
||||
load_reporter_with_prefix __r_${reporter_alias}_ ./reporters/${reporter_file}.sh
|
||||
local reporter_name=$(get_name_for_reporter $__REPORTER)
|
||||
local reporter_alias=$(get_alias $__REPORTER)
|
||||
load_reporter_with_prefix __r_${reporter_alias}_ ./reporters/${reporter_name}.sh
|
||||
|
||||
if is_function __r_${reporter_alias}_defaults; then
|
||||
__r_${reporter_alias}_defaults
|
||||
|
@ -94,12 +94,11 @@ main_collect () {
|
|||
for metric in $__METRICS; do
|
||||
# run in subshell to isolate scope
|
||||
(
|
||||
local metric_name=$(get_name $metric)
|
||||
local metric_name=$(get_name_for_metric $metric)
|
||||
local metric_alias=$(get_alias $metric)
|
||||
local metric_file=$(resolve_metric $metric)
|
||||
|
||||
# init metric
|
||||
load_metric_with_prefix __m_${metric_alias}_ ./metrics/${metric_file}.sh
|
||||
load_metric_with_prefix __m_${metric_alias}_ ./metrics/${metric_name}.sh
|
||||
|
||||
if is_function __m_${metric_alias}_defaults; then
|
||||
__m_${metric_alias}_defaults
|
||||
|
|
|
@ -94,10 +94,6 @@ parse_config () {
|
|||
IFS=$RESTORE_IFS
|
||||
}
|
||||
|
||||
get_name () {
|
||||
echo $1 | awk 'BEGIN { FS=":" } { print $1 }'
|
||||
}
|
||||
|
||||
get_alias () {
|
||||
local _alias=$(echo $1 | awk 'BEGIN { FS=":" } { print $2 }')
|
||||
if [ -z "$_alias" ]; then
|
||||
|
@ -106,7 +102,11 @@ get_alias () {
|
|||
echo $_alias
|
||||
}
|
||||
|
||||
resolve_reporter () {
|
||||
get_name () {
|
||||
echo $1 | awk 'BEGIN { FS=":" } { print $1 }'
|
||||
}
|
||||
|
||||
get_name_for_reporter () {
|
||||
local _alias=$(get_alias $1)
|
||||
for reporter in $__CFG_REPORTERS; do
|
||||
local __alias=$(get_alias $reporter)
|
||||
|
@ -118,7 +118,7 @@ resolve_reporter () {
|
|||
echo $_alias
|
||||
}
|
||||
|
||||
resolve_metric () {
|
||||
get_name_for_metric () {
|
||||
local _alias=$(get_alias $1)
|
||||
for metric in $__CFG_METRICS; do
|
||||
local __alias=$(get_alias $metric)
|
||||
|
|
Loading…
Reference in New Issue