Jump to content

best way to check the status of another site? looking for ideas


slushpuppie

Recommended Posts

working on a project for a client where we copied a form onto our page which passes over to another domain. they want me to write something on my page though that can check the status of their server, make sure the page is active. and if it's not i'm supposed to hide my form and put up a message basically saying "out of order"...

 

they offered to put something on their page like a meta tag that either says "active" or "inactive" and want me to parse their page for this...

 

does anyone have a better idea? or anything? any input appreciated.

 

thanks!

Damn dude I wrote something like this a whole back to have it check my primary server from a remote host.  If the connection took longer than 20 seconds it would fire off an SMS message to my cell phone.  Haha found it:

$fo = fsockopen('domain.com', 80);

if(!$fo)
{
	mail('[email protected]', 'site down', 'unable to connect on port 80 @ '.$date('H:m:s'));
}

 

I've seen some fancier stuff on phpclasses.org but I wanted something quick and dirty and thats exactly what this is.  You could use something like curl and use its functionality for the exact HTTP code if this is a web server, but anyways there are plenty of ways to skin this one.  Hope that works for you.

Cant you set a low socket timeout?

 

http://us3.php.net/manual/en/function.fsockopen.php

 

resource fsockopen  ( string $hostname  [, int $port  [, int &$errno  [, string &$errstr  [, float $timeout  ]]]] )

Here is what I would do:

Show the form always. Hide and disable it using javascript when the page loads. Check the server status using AJAX. If the server responds then show the form using javascript, otherwise give them the message saying the server is down.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.