diff --git a/README.md b/README.md index b006ee0..830ffc5 100644 --- a/README.md +++ b/README.md @@ -4799,6 +4799,20 @@ Using the keyword read so for example read x will wait
Write a script to determine whether a host is up or down
+ +``` +#!/bin/bash +SERVERIP= +NOTIFYEMAIL=test@example.com + +ping -c 3 $SERVERIP > /dev/null 2>&1 +if [ $? -ne 0 ] +then + # Use mailer here: + mailx -s "Server $SERVERIP is down" -t "$NOTIFYEMAIL" < /dev/null +fi +``` +