ANSWERED: Write a script to determine whether a host is up or down
This commit is contained in:
parent
72ded52b76
commit
accce12933
14
README.md
14
README.md
@ -4799,6 +4799,20 @@ Using the keyword <code>read</code> so for example <code>read x</code> will wait
|
|||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Write a script to determine whether a host is up or down</summary><br><b>
|
<summary>Write a script to determine whether a host is up or down</summary><br><b>
|
||||||
|
|
||||||
|
```
|
||||||
|
#!/bin/bash
|
||||||
|
SERVERIP=<IP Address>
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
</b></details>
|
</b></details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
Loading…
Reference in New Issue
Block a user