From 364e5c063e0877c234e88f7e63ec0dda8b6b17b5 Mon Sep 17 00:00:00 2001 From: Nils Date: Mon, 20 Sep 2021 12:12:41 +0200 Subject: [PATCH] add ping and http result functions --- status.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/status.sh b/status.sh index c3b8d88..3524493 100755 --- a/status.sh +++ b/status.sh @@ -8,5 +8,16 @@ if [[ -z "$http_hosts" ]];then fi function get_code { - http_results="$(curl -s -I $http_hosts | grep HTTP)" + http_results="$(curl -s -I $http_hosts | grep HTTP | cut -d " " -f 2)" } + +function get_ping { + ping_raw="$(fping -e "$ping_hosts")" + ping_reach="$(echo "$ping_raw" | grep -o -e "alive" -e "unreachable")" + ping_ms="$(echo "$ping_raw" | cut -d "(" -f 2 | cut -d ")" -f 1)" + ping_results="$ping_reach / $ping_ms" +} + +get_code +get_ping +echo "$http_results $ping_results"