A bi directional script that will monitor the TCP/IP connections between two physical

Dear All ,

I'm looking for a unix script that will monitor the TCP/IP connections between two physical ip addresses and when it dectes an IP is down it generates an alarm and sends SMS to mobile numbers.

Can any one help, I need this urgently.

Waiting for positive replies..

==================================

Hi samura,

If I were in your case, I'd be using 2 scripts.

Script 1 will be the one sending all those pings or "hellos" and will only be executed in one server which will serve as the checker.

Script 2 will be the "agent" who will send "acks" or acknowledgents or just simple ping backs to the server to express that the server is alive.

Its like a "I say hey you say ho" program.

Your problem can be solved with one script only but the problem with that is the checker may be able to ping or "see" the other machine but the other machine may not necessarily be able to "see" the server (due to firewalls or whatever reasons). Hence, the need for the "checker" and the "agent". But like I said earlier, just 1 script can suffice in some cases.

As for the sending of SMS, you'll have to have a machine that picks-up SMS messages and send it.

In my current company, we have an SMS server that parses XML files to be sent as SMS.

What we do is the server (checker), when needed to, ftps an XML file to the SMS server in an XML format. The SMS server, which just waits for available files, picks it up, parses it, then sends it.

The main script can be a cron job or an infinite script that uses a flat-file for reference of servers which it must ping (or ftp a file. The point is it must establish some means of communication with the other machine).

Now the 2nd script (if needed) may be a cron job or an infinite script that just waits for pings (or files from the server) then pings (or ftp's back) just to say "Yep, I'm still here"

hi Ango

Thnx for you reply but i need a sample of these scripts if you have any of them.

Say you have your list.

cat <list_of_server> | while read x; do
ping $x
if [ $? -ne 0 ]; then
  # Oh no, there's something wrong with the server. Ping exited with a non-zero. Do stuff here like ftp SMS file to your SMS server
fi
done

Check ping command for more info (man ping)

...
...
If ping does not receive any reply packets at all it will exit with code
1.  On error it exits with code 2. Otherwise it exits with code 0. This
makes it possible to use the exit code to see if a host is alive or not.

This program is intended for use in network testing, measurement and man-
agement.  Because of the load it can impose on the network, it is unwise
to use ping during normal operations or from automated scripts.
...
...