#!/bin/bash HOSTS="10.9.8.10" COUNT=120 DOWN=0 for myHost in $HOSTS do count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }') if [ $count -eq 0 ]; then if [ $DOWN -eq 0 ]; then echo "sol ($myHost) is down at $(date)" | mail -s "sol down" mail@reudnetz.org DOWN=1 fi else if [ $DOWN -eq 1 ]; then echo "sol ($myHost) is up again at $(date)" | mail -s "sol recovered" mail@reudnetz.org DOWN=0 fi fi done