Wednesday 20 April 2016

Ping response check script

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.

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...