Quick Search:
 
 PHP Code: Checking Server Status with PHP Jump to:  
Category: >> PHP Code >> Checking Server Status with PHP  

<< lastnext >>

Snippet Name: Checking Server Status with PHP

Description: A small bit of code to check server status and report the results. Easily combined with an emailer to send a text message to a phone for real-time alerting of server issues.

Also see:
» Count the number of checked checkboxes...
» Fix missing $_SERVER SCRIPT_URL variab...
» Checking Server Status with PHP
» Check for duplicates and delete duplic...
» MKDIR with error checking
» Check Constraint: Create
» Check email address
» INSERT WITH CHECK OPTION
» Yahoo Online Status
» Check number of characters in a range
» Check if an image exists (GD)
» Check if a file exists
» Toggle All Checkboxes on or off
» Check if array is associative
» Check syntax of multiple PHP files all...
» Deferring Constraint Checking
» Count checkboxes
» Check or Uncheck all Checkboxes
» Check radio button selection
» Constraint Checks
» Check If Domain Exists

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

<?PHP
 
// Domain name to check
$domainName = "http://www.psoug.org" ;
 
FUNCTION DomainCheck($domain_name){
    $start_time = MICROTIME(TRUE);
    $openDomain = FSOCKOPEN ($domain_name, 80, $errno, $errstr, 10);
    $end_time  = MICROTIME(TRUE);
    $server_status    = 0;
 
    IF (!$openDomain){
		$server_status = -1;  
    }ELSE{
        FCLOSE($openDomain);
        $status = ($end_time - $start_time) * 1000;
        $server_status = FLOOR($server_status);
    }
    RETURN $server_status;
}
 
$server_status = DomainCheck($domain_name);
 
 
IF ($server_status != -1) {
	PRINT "Cannot reach the server." ;
}ELSE{
	PRINT "Server is responding properly." ;
} 
 
?>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org