From accce12933b80f23f0ea9b939cf8f89a4dfc7e8b Mon Sep 17 00:00:00 2001 From: Austin Songer Date: Tue, 21 Jan 2020 21:46:27 +0000 Subject: [PATCH] ANSWERED: Write a script to determine whether a host is up or down --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 +``` +