KLanding/bootstrap_services.php
2016-04-07 13:25:35 +01:00

59 lines
1.6 KiB
PHP

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js" type="text/javascript"></script>
<style>
.hiddenRow { display: none; }
</style>
<script>
function toggleNextRow(row) {
var nextRow = $(row).next();
nextRow.toggle();
}
function togglebodyServices() {
$('#servicestable tbody').toggle();
}
</script>
</head>
<?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 = "<div class=\"Widgets\"><table id='servicestable' width='190' border='0' cellspacing='0' cellpadding='1'><thead><tr onclick='togglebodyServices()' ><th>Service</font></th><th>Status</font></th></tr></thead>";
# 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'><a href=\"http://$base:{$servicePort}/\"target=\"_blank\">{$serviceName}</a></font></td><td BGCOLOR='#FFFFFF'><font color='white'>{$statusText}</font></td></tr></tbody>";
}
# Finish service status table.
$serverStatus .= "</table>";
# File Complete.
?>