Click to See Complete Forum and Search --> : website ping script


hammerslane
11-25-2003, 05:00 AM
howdy.
i work for a company which is in charge of about 30 websites with 30 different domains. we have frequent downtime problems.

i was wondering if there was a website ping command or something... the closest i've found is mysql ping (http://uk.php.net/manual/en/function.mysql-ping.php), but it doesn't seem to do what i want.
we basically want to know when a website goes offline.. and i want the script to run every 20 minutes to check.. or something.

if the ping responds, then no action needs to be taken, if the response is false, then i will run a mail function.

regards

DaiWelsh
11-25-2003, 05:23 AM
If your server is configured to allow it (or is it only include(url) which can be configured off pyro?), you should be able to fopen() the url of the website to retrieve the content of the page and check it that way. This has the added advantage that you can see if it is actually responding with a valid page, as opposed to responding to a ping which it may do even if the web server or site is down and may not do even if it is up.

diamonds
11-26-2003, 03:04 PM
try somthing like this:

<?php
$sites = array();
$sites[] = array(
'site' => 'http://www.php.net/',
'emails' => array(
'email@email.email'
)
);
$sites[] = array(
'site' => 'http://www.php.net/',
'emails' => array(
'email@email.email',
'email@email.email'
)
);

foreach($sites as $value){
if(!is_file($value['site'])){
echo "file not available, mailing webmaster and/or administrator";

foreach($value['email'] as $email){
mail($email);//modify this, please, with the message and options
}

}else{
echo "site '".$value['site']."' checked okay!";
}

}
?>

Please note that this script may not come out-of-the-box.
I havent checked it in any way, and typed it up from scratch right on this forum.

pyro
11-26-2003, 04:00 PM
Originally posted by DaiWelsh
(or is it only include(url) which can be configured off pyro?)No, you were right - they both can. php.net is down right now, so I can't get a link but if the allow_url_fopen directive in the php.ini file is set to off, it will not allow you to open such urls. It is enabled as a default, and I'd doubt many servers would disable it.

diamonds
11-27-2003, 10:38 AM
php.net is down? Funny!
Originally posted by diamonds
try somthing like this:

...

'site' => 'http://www.php.net/',

...