This is a short script which determines if the server is live or not on the basis of ping responses.
The source machine will send 2 ICMP packets to the destination machine.
If the source machine does not receive a response it will send an email stating that the server is down.
#!/bin/bash
ping -c 2 <Destination IP address>
RESULT="$?"
if [ $RESULT != 0 ]
then
echo "<host name> is no longer responding to ping messages" | mail -s " <host name> server is down" admin@example.com
fi
Replace host name with destination server name in the above code.
The source machine will send 2 ICMP packets to the destination machine.
If the source machine does not receive a response it will send an email stating that the server is down.
#!/bin/bash
ping -c 2 <Destination IP address>
RESULT="$?"
if [ $RESULT != 0 ]
then
echo "<host name> is no longer responding to ping messages" | mail -s " <host name> server is down" admin@example.com
fi
Replace host name with destination server name in the above code.
No comments:
Post a Comment