Ping is a program used to detect a host's reachability on a network. Probably it's executing from the command line followed by hostname or IP address. This ping command is utilizing the ICMP protocol, the target host is sent an ECHO_REQUEST packet and responds with an ECHO_RESPONSE if available.

If you would like to be checked the ping status by the scripting, ping the multiple destination IP addresses for every second. This script can check the ping status to all the IP's which is you have included in hostname.txt and send E-mail alerts If any one of the server ping status is down.

Create a file with the name of and give execute permission, then create an another file name hostname.txt and add your IP addresses or host name.


You have to install the below packages,
1. Open-ssh
2.  Mutt,
3. Postfix (or) Exim

SetParamRun() {

    export TIME_HTTP=`date +%F_%T:%3N` 
    export STATUS_DOWN_HTTP=`echo -e "\E[31m[ DOWN ]\E[0m"` 
    export STATUS_UP_HTTP=`echo -e "\E[32m[ RUNNING ]\E[0m"` 

Ping_Hosts() { 
    cat hostname.txt | while read next 
            server=`echo $next | awk -F":" '{print $1}'`  
            ping -i 1 -c 1 $server > /dev/null 2>&1 
                if [ $? -eq 0 ] ; then 
                    echo "$TIME_HTTP : Status Of Host $server = $STATUS_UP_HTTP"; 
                    echo "$TIME_HTTP : Status Of Host $server = $STATUS_DOWN_HTTP";  
                    echo "$TIME_HTTP : Status Of Host $server = $STATUS_DOWN_HTTP" | mutt -s "$server Host DOWN!!!" 

while [ $i -le 2 ]   
    sleep 1s 
    Ping_Hosts | tee -a /var/log/ping.log  

We might give execute permission,

$ chmod +x