# Created on savesnippets.com · https://savesnippets.com/PCzNhAtGQCnGLV HOSTS=(web1 web2 web3 db1 db2) CMD="uptime && df -h /" declare -A status for h in "${HOSTS[@]}"; do echo "──── $h ────" if ssh -n -o ConnectTimeout=5 -o BatchMode=yes "$h" "$CMD"; then status[$h]="OK" else status[$h]="FAIL" fi done echo echo "──── Summary ────" for h in "${HOSTS[@]}"; do case "${status[$h]}" in OK) printf '\e[32m✓\e[0m %s\n' "$h" ;; FAIL) printf '\e[31m✗\e[0m %s\n' "$h" ;; esac done