Adding full screen status page (partly merging from 6176db7084
), and fixing menu highlighting
parent
2b905a4f3f
commit
962236bd42
|
@ -8,6 +8,7 @@
|
|||
- Support for mosms provider by Andreas Ek (https://github.com/EkAndreas/PHP-Server-Monitor-Plus/commit/105c734a02477befc01831e3b9b2b8fefd9b5ca5).
|
||||
- Language files are now automatically detected, instead of a hardcoded list.
|
||||
- Adding Korean language file (thanks to Ik-Jun).
|
||||
- Large status page by Michael Greenhill.
|
||||
|
||||
#########################
|
||||
#
|
||||
|
|
|
@ -162,6 +162,7 @@ The second part is the actual message. There are a few variables you can use in
|
|||
* Korean translation - Ik-Jun
|
||||
* Bootstrap implementation - Luiz Alberto S. Ribeiro
|
||||
* Mosms implementation - Andreas Ek
|
||||
* Status page - Michael Greenhill
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP Server Monitor
|
||||
* Monitor your servers and websites.
|
||||
*
|
||||
* This file is part of PHP Server Monitor.
|
||||
* PHP Server Monitor is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PHP Server Monitor is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package phpservermon
|
||||
* @author Michael Greenhill
|
||||
* @author Pepijn Over <pep@neanderthal-technology.com>
|
||||
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
|
||||
* @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3
|
||||
* @version Release: @package_version@
|
||||
* @link http://phpservermon.neanderthal-technology.com/
|
||||
**/
|
||||
|
||||
/**
|
||||
* Status module
|
||||
*/
|
||||
class modStatus extends modCore {
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// override parent::createHTML()
|
||||
public function createHTML() {
|
||||
$this->createHTMLList();
|
||||
|
||||
return parent::createHTML();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the template to show a list of all servers
|
||||
* @todo move the background colurs to the config
|
||||
*/
|
||||
protected function createHTMLList() {
|
||||
$this->setTemplateId('status', 'status.tpl.html');
|
||||
$this->addFooter(false);
|
||||
|
||||
// get the active servers from database
|
||||
$servers = $this->db->select(
|
||||
SM_DB_PREFIX.'servers',
|
||||
array('active' => 'yes'),
|
||||
array('server_id', 'label', 'status', 'last_online', 'last_check', 'rtime')
|
||||
);
|
||||
|
||||
$offline = array();
|
||||
$online = array();
|
||||
|
||||
$tpl_data = array(
|
||||
'bg' => '#000000',
|
||||
'offline_bg' => '#a00000',
|
||||
'offline_fg' => '#f7cece',
|
||||
'online_bg' => '#53a000',
|
||||
'online_fg' => '#d8f7ce',
|
||||
);
|
||||
$this->tpl->addTemplateData($this->getTemplateId(), $tpl_data);
|
||||
|
||||
foreach ($servers as $server) {
|
||||
$server['last_checked_nice'] = sm_timespan($server['last_check']);
|
||||
$server['last_online_nice'] = sm_timespan($server['last_online']);
|
||||
|
||||
if ($server['status'] == "off") {
|
||||
$offline[$server['server_id']] = $server;
|
||||
} else {
|
||||
$online[$server['server_id']] = $server;
|
||||
}
|
||||
}
|
||||
|
||||
// add servers to template
|
||||
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'servers_offline', $offline);
|
||||
$this->tpl->addTemplateDataRepeat($this->getTemplateId(), 'servers_online', $online);
|
||||
// add refresh (bit overkill perhaps to do it this way..?)
|
||||
$this->tpl->newTemplate('main_auto_refresh', 'main.tpl.html');
|
||||
$this->tpl->addTemplateData('main_auto_refresh', array('seconds' => 30));
|
||||
$this->tpl->addTemplateData('main', array('auto_refresh' => $this->tpl->getTemplate('main_auto_refresh')));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -228,6 +228,38 @@ function sm_curl_get($href) {
|
|||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a "nice" timespan message
|
||||
*
|
||||
* Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966
|
||||
* @param int $time
|
||||
* @return string
|
||||
* @todo add translation to timespan messages
|
||||
*/
|
||||
function sm_timespan($time) {
|
||||
if ($time !== intval($time)) { $time = strtotime($time); }
|
||||
$d = time() - $time;
|
||||
if ($time < strtotime(date('Y-m-d 00:00:00')) - 60*60*24*3) {
|
||||
$format = 'F j';
|
||||
if (date('Y') !== date('Y', $time)) {
|
||||
$format .= ", Y";
|
||||
}
|
||||
return date($format, $time);
|
||||
}
|
||||
if ($d >= 60*60*24) {
|
||||
$day = 'Yesterday';
|
||||
if (date('l', time() - 60*60*24) !== date('l', $time)) { $day = date('l', $time); }
|
||||
return $day . " at " . date('g:ia', $time);
|
||||
}
|
||||
if ($d >= 60*60*2) { return intval($d / (60*60)) . " hours ago"; }
|
||||
if ($d >= 60*60) { return "about an hour ago"; }
|
||||
if ($d >= 60*2) { return intval($d / 60) . " minutes ago"; }
|
||||
if ($d >= 60) { return "about a minute ago"; }
|
||||
if ($d >= 2) { return intval($d) . " seconds ago"; }
|
||||
|
||||
return "a few seconds ago";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an update is available for PHP Server Monitor
|
||||
*
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
**/
|
||||
|
||||
if(!file_exists('config.inc.php')) {
|
||||
die('Failed to locate config file. Please read docs/README for more information on how to setup PHP Server Monitor.');
|
||||
die('Failed to locate config file. Please read README.md for more information on how to setup PHP Server Monitor.');
|
||||
}
|
||||
require_once 'config.inc.php';
|
||||
|
||||
|
@ -38,7 +38,7 @@ if(isset($_GET['action']) && $_GET['action'] == 'check') {
|
|||
}
|
||||
|
||||
$type = (!isset($_GET['type'])) ? 'servers' : $_GET['type'];
|
||||
$allowed_types = array('servers', 'users', 'log', 'config');
|
||||
$allowed_types = array('servers', 'users', 'log', 'config', 'status');
|
||||
|
||||
// make sure user selected a valid type. if so, include the file and add to template
|
||||
if(!in_array($type, $allowed_types)) {
|
||||
|
|
|
@ -124,11 +124,6 @@
|
|||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).bind('ready', function(){
|
||||
$('#nav_option_config').addClass('active');
|
||||
});
|
||||
</script>
|
||||
<!--%%tpl_config-->
|
||||
|
||||
<!--%tpl_config_update-->
|
||||
|
|
|
@ -19,11 +19,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).bind('ready', function(){
|
||||
$('#nav_option_log').addClass('active');
|
||||
});
|
||||
</script>
|
||||
<!--%%tpl_log_list-->
|
||||
|
||||
<!--%tpl_log_entries-->
|
||||
|
|
|
@ -33,17 +33,20 @@
|
|||
<a class="brand" href="index.php">{title}</a>
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li id="nav_option_servers">
|
||||
<a href="index.php?type=servers" class="{active_servers}">{label_servers}</a>
|
||||
<li id="nav_option_servers" class="{active_servers}">
|
||||
<a href="index.php?type=servers">{label_servers}</a>
|
||||
</li>
|
||||
<li id="nav_option_users">
|
||||
<a href="index.php?type=users" class="{active_users}">{label_users}</a>
|
||||
<li id="nav_option_users" class="{active_users}">
|
||||
<a href="index.php?type=users">{label_users}</a>
|
||||
</li>
|
||||
<li id="nav_option_log">
|
||||
<a href="index.php?type=log" class="{active_log}">{label_log}</a>
|
||||
<li id="nav_option_log" class="{active_log}">
|
||||
<a href="index.php?type=log">{label_log}</a>
|
||||
</li>
|
||||
<li id="nav_option_config">
|
||||
<a href="index.php?type=config" class="{active_config}">{label_config}</a>
|
||||
<li id="nav_option_config" class="{active_config}">
|
||||
<a href="index.php?type=config">{label_config}</a>
|
||||
</li>
|
||||
<li id="nav_option_status" class="{active_status}">
|
||||
<a href="index.php?type=status">{label_status}Status</a>
|
||||
</li>
|
||||
<li id="nav_option_update">
|
||||
<a href="index.php?action=check">{label_update}</a>
|
||||
|
@ -72,17 +75,7 @@
|
|||
</div>
|
||||
|
||||
{update_available}
|
||||
|
||||
<footer class="footer">
|
||||
<p class="pull-right"><a href="#">{label_back_to_top}</a></p>
|
||||
<p>
|
||||
Powered by <a href="http://phpservermon.sourceforge.net" target="_blank">PHP Server Monitor</a> and
|
||||
<a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
|
||||
<br/>
|
||||
Copyright © 2008-2014 <a href="mailto:pep@neanderthal-technology.com">Pepijn Over<a/>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
{html_footer}
|
||||
</div>
|
||||
<!-- /container -->
|
||||
|
||||
|
@ -107,3 +100,15 @@
|
|||
<!--%tpl_main_auto_refresh-->
|
||||
<meta http-equiv="refresh" content="{seconds}" />
|
||||
<!--%%tpl_main_auto_refresh-->
|
||||
|
||||
<!--%tpl_main_footer-->
|
||||
<footer class="footer">
|
||||
<p class="pull-right"><a href="#">{label_back_to_top}</a></p>
|
||||
<p>
|
||||
Powered by <a href="http://phpservermon.sourceforge.net" target="_blank">PHP Server Monitor</a> and
|
||||
<a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>
|
||||
<br/>
|
||||
Copyright © 2008-2014 <a href="mailto:pep@neanderthal-technology.com">Pepijn Over</a>
|
||||
</p>
|
||||
</footer>
|
||||
<!--%%tpl_main_footer-->
|
|
@ -61,11 +61,6 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).bind('ready', function(){
|
||||
$('#nav_option_servers').addClass('active');
|
||||
});
|
||||
</script>
|
||||
<!--%%tpl_servers_list-->
|
||||
|
||||
|
||||
|
@ -136,9 +131,4 @@
|
|||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).bind('ready', function(){
|
||||
$('#nav_option_servers').addClass('active');
|
||||
});
|
||||
</script>
|
||||
<!--%%tpl_servers_update-->
|
|
@ -0,0 +1,71 @@
|
|||
<!--%tpl_status-->
|
||||
<style type="text/css">
|
||||
body {
|
||||
background: {bg};
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
h2, p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.entity {
|
||||
padding: 10px;
|
||||
box-shadow: 0px 0px 5px #666;
|
||||
border-radius: 3px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.offline {
|
||||
float: left; width: 300px;
|
||||
}
|
||||
|
||||
.offline .entity {
|
||||
background: {offline_bg};
|
||||
color: {offline_fg};
|
||||
border: 2px solid {offline_fg};
|
||||
}
|
||||
|
||||
.online {
|
||||
margin-left: 320px;
|
||||
}
|
||||
|
||||
.online .entity {
|
||||
background: {online_bg};
|
||||
color: {online_fg};
|
||||
border: 2px solid {online_fg};
|
||||
float: left;
|
||||
margin-right: 20px;
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
<div class="offline">
|
||||
<!--%tpl_repeat_servers_offline-->
|
||||
<div class="entity">
|
||||
<h2>{label}</h2>
|
||||
<p>Last online: {last_online_nice}</p>
|
||||
<p>Last checked: {last_checked_nice}</p>
|
||||
</div>
|
||||
<!--%%tpl_repeat_servers_offline-->
|
||||
{servers_offline}
|
||||
</div>
|
||||
<div class="online">
|
||||
<!--%tpl_repeat_servers_online-->
|
||||
<div class="entity">
|
||||
<h2>{label}</h2>
|
||||
<p>Last checked: {last_checked_nice}</p>
|
||||
<p>Latency: {rtime}s</p>
|
||||
</div>
|
||||
<!--%%tpl_repeat_servers_online-->
|
||||
{servers_online}
|
||||
</div>
|
||||
<!--%%tpl_status-->
|
|
@ -40,11 +40,6 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).bind('ready', function(){
|
||||
$('#nav_option_users').addClass('active');
|
||||
});
|
||||
</script>
|
||||
<!--%%tpl_users_list-->
|
||||
|
||||
<!--%tpl_users_update-->
|
||||
|
@ -93,9 +88,4 @@ $(document).bind('ready', function(){
|
|||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).bind('ready', function(){
|
||||
$('#nav_option_users').addClass('active');
|
||||
});
|
||||
</script>
|
||||
<!--%%tpl_users_update-->
|
Loading…
Reference in New Issue