From 16e27beaa24c6c551eaa0d3e6d115017939593a1 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sun, 25 Aug 2019 06:06:41 +0200 Subject: Support multi-reports --- remote/lib/status.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'remote/lib/status.sh') diff --git a/remote/lib/status.sh b/remote/lib/status.sh index 644f20a..95e7bbb 100644 --- a/remote/lib/status.sh +++ b/remote/lib/status.sh @@ -1,6 +1,7 @@ . lib/parameters.sh . lib/print.sh . lib/report.sh +. lib/run.sh function check_server_traffic { local result="$1" @@ -97,7 +98,7 @@ function check_server_status { service_status=${BASH_REMATCH[1]} service_output=$(sed "1 d" <<< "$service_output") if [ -n "${BASH_REMATCH[2]}" ]; then - service_header=$(sed -r "s/\\$\{color\s+([^}]*)\}/$(set_color \\1)/g" <<< "${BASH_REMATCH[2]}") #" + service_header=$(sed -r "s/\\$\{color\s+([^}]*)\}/\$(set_color \\1)/g" <<< "${BASH_REMATCH[2]}") #" headers="$headers $service_header" fi else @@ -144,21 +145,21 @@ function check_service { health=${BASH_REMATCH[2]} header=${BASH_REMATCH[3]} - output=$(sed '$ d' <<< $ouput) + output=$(sed '$ d' <<< "$output") fi print_status "$online" print_status "$health" - headers=$(sed -r "s/\\$\{color\s+([^}]*)\}/$(set_color \\1)/g" <<< "$header") # " - print " ::: ${headers}" + header=$(sed -r "s/\\$\{color\s+([^}]*)\}/\$(set_color \\1)/g" <<< "$header") # " + print " ::: ${header}" - important=$(grep "^\*" <<< $output) - messages=$(grep -v "^\*" <<< $output) + important=$(grep "^\*" <<< "$output") + messages=$(grep -v "^\*" <<< "$output") if [ -n "$output" ]; then - output="\n$(decorate "$service:$id" "cyan" "u")\n$(set_color white)$important\n$(reset_color)$messages\n" + output="\n$(decorate "$service:$id" "cyan" "u")\n$important\n$(set_color gray)$messages$(reset_color)\n" flock -x $0 echo "${output}" >&12 fi } @@ -170,7 +171,7 @@ function check__ { read -ra args <<< "$1" && shift local host=${args[0]}; - print "$(decorate $title "purple") ::: " | sed -r "s/\\$\{color\s+([^}]*)\}/$(set_color \\1)/g; " + print "$(decorate $title "purple") ::: " | sed -r "s/\\$\{color\s+([^}]*)\}/\$(set_color \\1)/g; " local service for service in "$@"; do -- cgit v1.2.1