By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

Monitor Web & MySQL Services ??

P: n/a
Hi
Is it possible to use a PHP script to detect if a web site is up and
available ?

and detect if a certain string of words is visible ??

ie: if 'welcome to my site' is shown then the site is ok.. BUT if
'Connection Error' is shown on the web page then the site is down.

Also is it possible to detect if MySQL is working ?

If either the http, or the 'connection error' string or MySQL errors
are detected can I be emailed ??

Any Ideas ?

Thanks :)

May 8 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
je***********@yahoo.com wrote:
Hi
Is it possible to use a PHP script to detect if a web site is up and
available ?

and detect if a certain string of words is visible ??

ie: if 'welcome to my site' is shown then the site is ok.. BUT if
'Connection Error' is shown on the web page then the site is down.

Also is it possible to detect if MySQL is working ?

If either the http, or the 'connection error' string or MySQL errors
are detected can I be emailed ??

Any Ideas ?

Thanks :)
Yes, use file functions (or, better, CURL) to obtain page content, then
check it against a list of regular expressions.

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
May 8 '07 #2

P: n/a
Many Thanks for the replies.

I'm new to this so am not sure how to proceed.

Any help you give is gratefully received.

Thanks

May 8 '07 #3

P: n/a
je***********@yahoo.com wrote:
Many Thanks for the replies.

I'm new to this so am not sure how to proceed.

Any help you give is gratefully received.

Thanks
Well, something along the lines of

$content = @file_get_contents('http://blah.com');
if($content === false)
$error = 'address not found or dns error';

if(preg_match('/connection error/', $content))
$error = 'connection error';

if($error)
mail('me@blah', 'alarm!', $error);

look for file_get_contents, preg_match, mail in php manual

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
May 8 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.