Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
colors for statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Wick committed Aug 19, 2017
1 parent e0a83c6 commit b4c3629
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 0 additions & 4 deletions TODO.md

This file was deleted.

20 changes: 17 additions & 3 deletions ssh-ping
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

Expand Down

0 comments on commit b4c3629

Please sign in to comment.