Hi Pete, 

You could use PHP's command line execution programs to execute the ping
command, then either check the output or check the return status of
ping, if you do this make sure you pass ping some parameters that will
limit the timeout and retries otherwise your PHP script may hang waiting
for ping to finish for a long time.

Another thing you could do would be download a file from both servers
from the web or ftp or open a socket connection to a service that is
running on the machine (like port 80).

If you go to hotscripts.com you may find something that does what you
are looking for that already exists.

Jason
On Tue, 2003-02-18 at 06:17, Petre Agenbag wrote:
> Hi
> I have two servers on two different networks. I would like to implement
> some sort of a watchdog application between the two to inform me should
> either of the machines go down or has a connection problem.
> I was thinking along the line of using a PHP script running from cron on
> an hourly basis to "ping" the server as well as another server such as
> google.com (they seem to be always up) and to only raise the alarm when
> google can be reached, but NOT the other server.
> 
> My only problem is with the actual recognition of a "failed" ping, or
> for that matter a successful one?
> 
> Can anyone give me some brain food as to the code for detecting a
> up/down connection?
> 
> pseudo code:
> 
> make connection with server1
> get result of connection_server1
> make connection with google.com
> get result of connection_google
> 
> if connection_google && !connection_server1
>       sms me
> else
>       chill out
> 
> 
> and a plus would be to do this ONLY if the result of the next cron-run
> is the same, ie, don't sms me if the problem has been fixed within an
> hour.
> I just don';t know what to use to "make connection" and "get result of
> connection"
> 
> Thanks.
> 
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to