1830234 Members
2053 Online
109999 Solutions
New Discussion

Connectivity Script

 
YogeshG
New Member

Connectivity Script

Hello,
We have a model which contains around 20 production servers. Most of the servers are having connectivity to the external servers(out of Model). Problem is now a days we are facing the problem of dropping connections from our servers to the external systems, which results time consuption to our testing.

Help me in writing the script which will check for the connectivity to the external system, if connectivity dropped, it should Broadscats the message.
We are checking the connectivity as below----

[root@p4ehub02] #: telnet 10.80.10.82 8888
Trying 10.80.10.82...
Connected to 10.80.10.82.
Escape character is '^]'.


If we get the escape character, assume connectivity is in place.
==========================================


[root@p4ehub02] #: telnet 10.80.10.82 8888
Trying 10.80.10.82...

It means connectivity dropped..
==============================================

Could anyone please help me to write the script which will broadscat the message if connectivity dropped on certain interval of time?
1 REPLY 1
Mark Ellzey
Valued Contributor

Re: Connectivity Script

Hi,

You don't say what OS version you are using, but instead of using telnet, I'd use ping.

From a central host, I'd first create a list of all the hosts I want to test, call it hosts.dat. Then I'd do something like the following:

#!/usr/bin/ksh

while read HOST
do
ping $HOST -n 1 > /dev/null 2>&1
STAT=$?
if (( $STAT )) ; then
echo "$HOST is not responding"
fi
done < hosts.dat

Instead of the echo command, you could put some kind of mail, broadcast or pager notification. If the network is flakey, you may want to increase the number of pings from 1 to something bigger.

Regards,
Mark