mirror of
https://github.com/ShaYmez/ezservermonitor-web.git
synced 2024-11-21 23:55:15 -05:00
- System : fix to get the distro name
- Services : fix on service names with accent - Services : ability to specify a host for each service - Network usage : fix to retrieve the name of the network interfaces - Memory : the cached and buffers memory are added to free memory now - Load Average : taking into account the number of cores - Disk usage : new option to hide tmpfs mountpoints - General : remove all PHP short tags
This commit is contained in:
parent
20705a550d
commit
3f6a49bae3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/web/css/.sass-cache
|
@ -1,8 +1,11 @@
|
||||
{
|
||||
"esm": {
|
||||
"version": "2.0",
|
||||
"version": "2.1",
|
||||
"website": "http://www.ezservermonitor.com"
|
||||
},
|
||||
"disk": {
|
||||
"show_tmpfs": false
|
||||
},
|
||||
"ping": {
|
||||
"hosts": [
|
||||
"free.fr",
|
||||
@ -16,18 +19,22 @@
|
||||
"services": [
|
||||
{
|
||||
"name": "Web Server (Apache)",
|
||||
"host": "localhost",
|
||||
"port": 80
|
||||
},
|
||||
{
|
||||
"name": "FTP Server (ProFTPd)",
|
||||
"host": "localhost",
|
||||
"port": 21
|
||||
},
|
||||
{
|
||||
"name": "Databases (MySQL)",
|
||||
"host": "localhost",
|
||||
"port": 3306
|
||||
},
|
||||
{
|
||||
"name": "SSH",
|
||||
"host": "localhost",
|
||||
"port": 22
|
||||
}
|
||||
]
|
||||
|
@ -8,7 +8,7 @@ $update = $Config->checkUpdate();
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>eZ Server Monitor - <?= Misc::getHostname(); ?></title>
|
||||
<title>eZ Server Monitor - <?php echo Misc::getHostname(); ?></title>
|
||||
<link rel="stylesheet" href="web/css/utilities.css" type="text/css">
|
||||
<link rel="stylesheet" href="web/css/frontend.css" type="text/css">
|
||||
<!--[if IE]>
|
||||
@ -40,16 +40,16 @@ $update = $Config->checkUpdate();
|
||||
<nav role="main">
|
||||
<div id="appname">
|
||||
<a href="index.php"><span class="icon-gauge"></span>eSM</a>
|
||||
<a href="<?= $Config->get('esm:website'); ?>"><span class="subtitle">eZ Server Monitor - v<?= $Config->get('esm:version'); ?></span></a>
|
||||
<a href="<?php echo $Config->get('esm:website'); ?>"><span class="subtitle">eZ Server Monitor - v<?php echo $Config->get('esm:version'); ?></span></a>
|
||||
</div>
|
||||
|
||||
<div id="hostname">
|
||||
<?= Misc::getHostname(); ?> - <?= Misc::getLanIP(); ?>
|
||||
<?php echo Misc::getHostname(); ?> - <?php echo Misc::getLanIP(); ?>
|
||||
</div>
|
||||
|
||||
<?php if (!is_null($update)): ?>
|
||||
<div id="update">
|
||||
<a href="<?= $update['fullpath']; ?>">New version available (<?= $update['availableVersion']; ?>) ! Click here to download</a>
|
||||
<a href="<?php echo $update['fullpath']; ?>">New version available (<?php echo $update['availableVersion']; ?>) ! Click here to download</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
@ -7,7 +7,7 @@ class Config
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->file = $_SERVER['DOCUMENT_ROOT'].'/esm.config.json';
|
||||
$this->file = __DIR__.'/../../esm.config.json';
|
||||
|
||||
if (file_exists($this->file))
|
||||
$this->_readFile();
|
||||
@ -16,7 +16,7 @@ class Config
|
||||
private function _readFile()
|
||||
{
|
||||
$content = file_get_contents($this->file);
|
||||
$this->config = json_decode($content, true);
|
||||
$this->config = json_decode(utf8_encode($content), true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
require 'Utils/Misc.class.php';
|
||||
require 'Utils/Config.class.php';
|
||||
$Config = new Config();
|
||||
|
||||
$datas = array();
|
||||
|
||||
if (!(exec('/bin/df | awk \'{print $2","$3","$4","$5","$6}\'', $df)))
|
||||
if (!(exec('/bin/df -T | tail -n +2 | awk \'{print $2","$3","$4","$5","$6","$7}\'', $df)))
|
||||
{
|
||||
$datas[] = array(
|
||||
'total' => 'N.A',
|
||||
@ -15,19 +17,14 @@ if (!(exec('/bin/df | awk \'{print $2","$3","$4","$5","$6}\'', $df)))
|
||||
}
|
||||
else
|
||||
{
|
||||
$first_line = false;
|
||||
|
||||
$mounted_points = array();
|
||||
|
||||
foreach ($df as $mounted)
|
||||
{
|
||||
if ($first_line === false)
|
||||
{
|
||||
$first_line = true;
|
||||
continue;
|
||||
}
|
||||
list($type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
|
||||
|
||||
list($total, $used, $free, $percent, $mount) = explode(',', $mounted);
|
||||
if (strpos($type, 'tmpfs') !== false && $Config->get('disk:show_tmpfs') === false)
|
||||
continue;
|
||||
|
||||
if (!in_array($mount, $mounted_points))
|
||||
{
|
||||
|
@ -1,21 +1,25 @@
|
||||
<?php
|
||||
|
||||
if (!($load_tmp = shell_exec('/bin/cat /proc/loadavg | /usr/bin/awk \'{print $1","$2","$3}\'')))
|
||||
if (!($load_tmp = shell_exec('cat /proc/loadavg | awk \'{print $1","$2","$3}\'')))
|
||||
{
|
||||
$load = array(0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Number of cores
|
||||
$cores = (int)shell_exec('grep -c ^processor /proc/cpuinfo');
|
||||
|
||||
$load_exp = explode(',', $load_tmp);
|
||||
|
||||
$load = array_map(
|
||||
function ($value) {
|
||||
$v = (int)($value * 100);
|
||||
function ($value, $cores) {
|
||||
$v = (int)($value * 100 / $cores);
|
||||
if ($v > 100)
|
||||
$v = 100;
|
||||
return $v;
|
||||
},
|
||||
$load_exp
|
||||
$load_exp,
|
||||
array_fill(0, 3, $cores)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,13 @@
|
||||
require 'Utils/Misc.class.php';
|
||||
|
||||
// Free
|
||||
if (!($free = shell_exec('grep MemFree /proc/meminfo | awk \'{print $2}\'')))
|
||||
if (!($free = shell_exec('/usr/bin/free -to | grep Mem: | awk \'{print $4+$6+$7}\'')))
|
||||
{
|
||||
$free = 0;
|
||||
}
|
||||
|
||||
// Total
|
||||
if (!($total = shell_exec('grep MemTotal /proc/meminfo | awk \'{print $2}\'')))
|
||||
if (!($total = shell_exec('/usr/bin/free -to | grep Mem: | awk \'{print $2}\'')))
|
||||
{
|
||||
$total = 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ require 'Utils/Misc.class.php';
|
||||
|
||||
$datas = array();
|
||||
|
||||
if (!(exec('/sbin/ifconfig | awk -F " " \'{print $1}\' | sed -e \'/^$/d\'', $getInterfaces)))
|
||||
if (!(exec('/sbin/ifconfig |awk -F \'[/ |: ]\' \'{print $1}\' |sed -e \'/^$/d\'', $getInterfaces)))
|
||||
{
|
||||
$datas[] = array('interface' => 'N.A', 'ip' => 'N.A');
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ if (count($Config->get('services')) > 0)
|
||||
{
|
||||
foreach ($Config->get('services') as $service)
|
||||
{
|
||||
$ip = 'localhost';
|
||||
$sock = @fsockopen($ip, $service['port'], $num, $error, 5);
|
||||
$host = $service['host'];
|
||||
$sock = @fsockopen($host, $service['port'], $num, $error, 5);
|
||||
|
||||
if ($sock)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
require 'Utils/Misc.class.php';
|
||||
|
||||
|
||||
// Free
|
||||
if (!($free = shell_exec('grep SwapFree /proc/meminfo | awk \'{print $2}\'')))
|
||||
{
|
||||
|
@ -7,7 +7,22 @@ $hostname = php_uname('n');
|
||||
// OS
|
||||
if (!($os = shell_exec('/usr/bin/lsb_release -ds')))
|
||||
{
|
||||
$os = 'N.A';
|
||||
if (!($os = shell_exec('cat /etc/fedora-release')))
|
||||
{
|
||||
if (!($os = shell_exec('cat /etc/redhat-release')))
|
||||
{
|
||||
if (!($os = shell_exec('cat /etc/mandriva-release')))
|
||||
{
|
||||
if (!($os = shell_exec('cat /etc/SuSE-release')))
|
||||
{
|
||||
if (!($os = shell_exec('cat /etc/centos-release')))
|
||||
{
|
||||
$os = 'N.A';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Kernel
|
||||
|
Loading…
Reference in New Issue
Block a user