Current location: Hot Scripts Forums » General Community » Script Requests » uptime monitoring php script

uptime monitoring php script

Reply
  #1 (permalink)  
Old 12-28-06, 05:57 AM
Jolin Jolin is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
uptime monitoring php script

Hi,
I am looking for a php script that monitors a site's uptime and downtime. Say, I have a site hosted in Hosting provider A, and I want to monitor the site that is hosted in Hosting Provider B. I would like the script to automatically check site that is hosted in B like every 5 minutes or so. And sends me email when the site is down. Please help. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 12-28-06, 10:12 PM
snaip's Avatar
snaip snaip is online now
iNET Interactive
 
Join Date: Nov 2003
Posts: 975
Thanks: 1
Thanked 3 Times in 3 Posts
I'd recommend using an remotely hosted uptime monitoring service. Try: http://www.pingdom.com/
__________________
Regards,
Ahmad Permessur
Team HotScripts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 12-28-06, 11:41 PM
Keith's Avatar
Keith Keith is offline
Community Liaison
 
Join Date: Feb 2004
Posts: 1,209
Thanks: 1
Thanked 9 Times in 9 Posts
Here's a quick piece of code that will do what you'd like. You'd just need to set a cron to hit the script every 5 minutes.
PHP Code:
<?php

// the URL you want to keep tabs on
$url 'http://www.somewebsite.com';

// if not available, send email
if ( url_exists$url ) === FALSE )
{
    
$to   'my@email.com';
    
$subj $url ' is down!';
    
$msg  $url ' was tested at ' date'Y-m-d H:i:s' ) . ' and was inaccessible.';
    @
mail$to$subj$msg );
}



/**
 * url_exists()
 * Checks for the validity of a given URL
 *
 * @param string The http[s] URL you're checking for
 * @return bool TRUE if online; FALSE if not; NULL if not an http(s):// URL
 */
function url_exists$strURL NULL )
{
    if ( !
preg_match'/^http(s?):\/\//i'$strURL$m ) )
        return 
NULL;
    @
$ch curl_init();
    
curl_setopt$chCURLOPT_URL$strURL );
    
curl_setopt$chCURLOPT_BINARYTRANSFER);
    
curl_setopt$chCURLOPT_HEADERFUNCTION'curlHeaderCallback' );
    
curl_setopt$chCURLOPT_FAILONERROR);
    
curl_setopt$chCURLOPT_TIMEOUT);
    
// https?
    
if ( $m[1] == 's' )
        
curl_setopt$chCURLOPT_SSL_VERIFYPEER);
    @
curl_exec$ch );
    
$intReturnCode curl_getinfo$chCURLINFO_HTTP_CODE );
    
curl_close$ch );
    return ( 
$intReturnCode == 200 OR $intReturnCode == 302 OR $intReturnCode == 304 ) ? TRUE FALSE;
}

?>
__________________
The toxic ZCE
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 12-30-08, 11:30 AM
ctthisi ctthisi is offline
New Member
 
Join Date: Dec 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
I like this script but could you update it show it shows the sites uptime percentage.

I like this script but could you update it show it shows the sites uptime percentage.

chris.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-16-09, 05:11 PM
SpencerB SpencerB is offline
New Member
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Uptime Monitoring

Uptime really is a valuable commodity. I use a company called Observe point. They will call, text, or E-mail me if my site ever goes down so I can fix the problem. The reports they send periodically (ones telling how much uptime or downtime I had) are easy to read too. Web Server-Website monitoring is very important to your business no matter how you do it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-19-10, 03:39 PM
art79 art79 is offline
New Member
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Monitoring not only if server is alive but what is going on

Maybe cacti monitoring ?

PALM v3 - bundle of Php Apache Linux and Memcached Cacti scripts (APC included) | artur.ejsmont.org

This should give you some idea of what kind of graphs can you easily get out of the box.

ps. it will do ping 'is alive' for you as well.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
custom php script needed alley Job Offers & Assistance 5 06-30-10 02:14 AM
Submit button....can it send info to my email w/out the use of php???? lisa33 HTML/XHTML/XML 7 10-17-06 11:46 AM
PHP upload script alej469 Job Offers & Assistance 5 05-18-06 05:01 AM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 07:29 AM
PHP Membership Script sixflagsga Script Requests 1 05-19-05 05:23 PM


All times are GMT -5. The time now is 09:08 AM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.