#!/bin/sh # Author: Tim van Erven # Version: 1.0 # Options HOST='localhost' # Change this to a remote host near you TIMEOUT=2 WAIT=1 PING=`which ping` DATE=`which date` # Don't change anything below this line IPHOST=`host $HOST | awk '{print $3;}'` UP=false echo -n "Starting monitor at:\t" $DATE trap 'echo -n "Stopping monitor at:\t"; $DATE; exit 0' 2 9 while true; do $PING -q -W $TIMEOUT -c1 "$IPHOST" > /dev/null 2> /dev/null if [ $? -eq 0 ]; then if [ $UP = false ]; then echo -n "$HOST up:\t" $DATE UP=true fi else if [ $UP = true ]; then echo -n "$HOST down:\t" $DATE UP=false fi fi sleep $WAIT done