KLanding/ss_bootstrap_servers.php

102 lines
2.5 KiB
PHP
Raw Normal View History

2015-07-02 19:33:06 +01:00
<?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 "ss_configs_servers.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'>Server</font></th><th style='text-align: left;'><font color='white'>Status</font></th></tr>";
2015-07-03 09:22:01 +01:00
# Process all services1 montiored.
foreach( $configs['services1'] as $serviceName => $servicePort )
2015-07-02 19:33:06 +01:00
{
# 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'>{$serviceName}</td><td BGCOLOR='#FFFFFF'>{$statusText}</td></tr>";
}
2015-07-03 09:22:01 +01:00
# Process all services1 montiored.
foreach( $configs['services2'] as $serviceName => $servicePort )
2015-07-02 19:33:06 +01:00
{
# 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'>{$serviceName}</td><td BGCOLOR='#FFFFFF'>{$statusText}</td></tr>";
}
2015-07-03 09:22:01 +01:00
# Process all services1 montiored.
foreach( $configs['services3'] as $serviceName => $servicePort )
2015-07-02 19:33:06 +01:00
{
# 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'>{$serviceName}</td><td BGCOLOR='#FFFFFF'>{$statusText}</td></tr>";
}
2015-07-03 09:22:01 +01:00
# Process all services1 montiored.
foreach( $configs['services4'] as $serviceName => $servicePort )
2015-07-02 19:33:06 +01:00
{
# Determine Port Status.
$status = @fsockopen($configs['server_ip4'], $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'>{$serviceName}</td><td BGCOLOR='#FFFFFF'>{$statusText}</td></tr>";
}
# Finish service status table.
$serverStatus .= "</table>";
# File Complete.
?>