83 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /*
 | |
| * Script: Server Status
 | |
| * Author: Martin Dixon
 | |
| * From: Tutorial-Resource.com
 | |
| * URL: www.tutorial-resource.com
 | |
| * Version: 1.0
 | |
| * License: Free
 | |
| */
 | |
| 
 | |
| # Load the configurations.
 | |
| require "configs_services.php";
 | |
| 
 | |
| # Start a variable to contain Service Status.
 | |
| $serverStatus = "<table border='0' cellspacing='0' cellpadding='1'><tr BGCOLOR='#0066FF'><th style='text-align: left;'><font color='white'>Service</font></th><th style='text-align: left;'><font color='white'>Status</font></th></tr>";
 | |
| 
 | |
| # Process all services montiored.
 | |
| foreach( $configs['servicesKloud'] as $serviceName => $servicePort )
 | |
| {
 | |
| 	# Determine Port Status.
 | |
| 	$status = @fsockopen($configs['server_ip2'], $servicePort, $errno, $errstr, 5);
 | |
| 	
 | |
| # What is the result.
 | |
| 	if( !$status )
 | |
| 	{
 | |
| 		$statusText = "<font color='red'>Down</font>";
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 		$statusText = "<font color='green'>Up</font>";
 | |
| 	}
 | |
| 	
 | |
| 	# Set the status Row.
 | |
| 	$serverStatus .= "<td BGCOLOR='#FFFFFF'><font color='#0066FF'>{$serviceName}</font></td><td BGCOLOR='#FFFFFF'><font color='white'>{$statusText}</font></td></tr>";
 | |
| }
 | |
| 
 | |
| # Process all services montiored.
 | |
| foreach( $configs['servicesSpot'] as $serviceName => $servicePort )
 | |
| {
 | |
| 	# Determine Port Status.
 | |
| 	$status = @fsockopen($configs['server_ip3'], $servicePort, $errno, $errstr, 5);
 | |
| 	
 | |
| 	# What is the result.
 | |
| 	if( !$status )
 | |
| 	{
 | |
| 		$statusText = "<font color='red'>Down</font>";
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 		$statusText = "<font color='green'>Up</font>";
 | |
| 	}
 | |
| 	
 | |
| 	# Set the status Row.
 | |
| 	$serverStatus .= "<td BGCOLOR='#FFFFFF'><font color='#0066FF'>{$serviceName}</font></td><td BGCOLOR='#FFFFFF'><font color='white'>{$statusText}</font></td></tr>";
 | |
| }
 | |
| 
 | |
| # Process all services montiored.
 | |
| foreach( $configs['services'] as $serviceName => $servicePort )
 | |
| {
 | |
| 	# Determine Port Status.
 | |
| 	$status = @fsockopen($configs['server_ip'], $servicePort, $errno, $errstr, 5);
 | |
| 	
 | |
| 	# What is the result.
 | |
| 	if( !$status )
 | |
| 	{
 | |
| 		$statusText = "<font color='red'>Down</font>";
 | |
| 	}
 | |
| 	else
 | |
| 	{
 | |
| 		$statusText = "<font color='green'>Up</font>";
 | |
| 	}
 | |
| 	
 | |
| 	# Set the status Row.
 | |
| 	$serverStatus .= "<td BGCOLOR='#FFFFFF'><font color='#0066FF'>{$serviceName}</font></td><td BGCOLOR='#FFFFFF'><font color='white'>{$statusText}</font></td></tr>";
 | |
| }
 | |
| 
 | |
| 
 | |
| # Finish service status table.
 | |
| $serverStatus .= "</table>";
 | |
| 
 | |
| # File Complete.
 | |
| 
 | |
| ?>
 |