From b4c36290e7985bceebbb32519c3a85a4b96e6d91 Mon Sep 17 00:00:00 2001 From: Sven Wick Date: Sun, 20 Aug 2017 01:53:11 +0200 Subject: [PATCH] colors for statistics --- TODO.md | 4 ---- ssh-ping | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) delete mode 100644 TODO.md diff --git a/TODO.md b/TODO.md deleted file mode 100644 index ea39aa0..0000000 --- a/TODO.md +++ /dev/null @@ -1,4 +0,0 @@ - -# TODO - -- colors in statistics diff --git a/ssh-ping b/ssh-ping index e7a82a0..4f98e43 100755 --- a/ssh-ping +++ b/ssh-ping @@ -85,9 +85,23 @@ function print_statistics() { requests_loss=$(( 100 * requests_lost / requests_transmitted )) echo - echo "--- $host ping statistics ---" - echo "$requests_transmitted requests transmitted, $requests_received requests received, $requests_loss% request loss" - exit + echo "${WHITE}---${RESET} ${YELLOW}$host${RESET} ${WHITE}ping statistics${RESET} ${WHITE}---${RESET}" + + statistics_ok="${GREEN}$requests_transmitted${RESET} ${WHITE}requests transmitted${RESET}, " + statistics_ok+="${GREEN}$requests_received${RESET} ${WHITE}requests received${RESET}, " + statistics_ok+="${GREEN}$requests_loss%${RESET} ${WHITE}request loss${RESET}" + + statistics_warn="${YELLOW}$requests_transmitted${RESET} ${WHITE}requests transmitted${RESET}, " + statistics_warn+="${YELLOW}$requests_received${RESET} ${WHITE}requests received${RESET}, " + statistics_warn+="${YELLOW}$requests_loss%${RESET} ${WHITE}request loss${RESET}" + + statistics_crit="${RED}$requests_transmitted${RESET} ${WHITE}requests transmitted${RESET}, " + statistics_crit+="${RED}$requests_received${RESET} ${WHITE}requests received${RESET}, " + statistics_crit+="${RED}$requests_loss%${RESET} ${WHITE}request loss${RESET}" + + [[ $requests_loss -eq 100 ]] && echo "$statistics_crit" && exit + [[ $requests_loss -gt 1 ]] && echo "$statistics_warn" && exit + [[ $requests_loss -eq 0 ]] && echo "$statistics_ok" && exit }