Ping a Server for Status in BASH Script [Linux]

#!/bin/bash
################################################################
# AUTHOR: Saqib Mujtaba
# SCRIPT: Ping servers status in a network 
# DATED : 07/02/2014
# TYPE  : BASH Shell Script
################################################################
array_serverIP="192.168.01.1 10.0.0.01"
#PINGS FOR COMPUTER STATUS
for ip in $array_serverIP ;
do
(
ping $ip  -c2 &> /dev/null ;
if [ $? -eq 0 ];
then
        echo "$ip is Up" >> tmpoutput

else
        echo "$ip is Down" >>  tmpoutput
fi
)&
done
wait

In this example, tmpoutout reflects to a tmp location which we can ourself or the administrator can schedule a tmp clearup latter.

rm -r tmpoutput

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: