summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/esm.config.json57
-rw-r--r--index.php151
-rw-r--r--libs/Utils/Misc.php11
-rw-r--r--libs/disk.php2
-rw-r--r--libs/load_average.php2
-rw-r--r--libs/memory.php12
-rw-r--r--libs/system.php24
7 files changed, 111 insertions, 148 deletions
diff --git a/conf/esm.config.json b/conf/esm.config.json
index bf65386..91f21d0 100644
--- a/conf/esm.config.json
+++ b/conf/esm.config.json
@@ -7,63 +7,8 @@
"theme": "blue",
"custom_title": ""
},
- "cpu": {
- "enable_temperature": true
- },
"disk": {
- "show_tmpfs": false,
+ "show_tmpfs": true,
"show_filesystem": true
- },
- "ping": {
- "hosts": [
- "facebook.com",
- "google.com",
- "yahoo.com"
- ]
- },
- "last_login": {
- "enable": true,
- "max": 5
- },
- "services": {
- "show_port": true,
- "list": [
- {
- "name": "Web Server",
- "host": "localhost",
- "port": 80,
- "protocol": "tcp"
- },
- {
- "name": "Email Server (incoming)",
- "host": "localhost",
- "port": 993,
- "protocol": "tcp"
- },
- {
- "name": "Email Server (outgoing)",
- "host": "localhost",
- "port": 587,
- "protocol": "tcp"
- },
- {
- "name": "FTP Server",
- "host": "localhost",
- "port": 21,
- "protocol": "tcp"
- },
- {
- "name": "Database Server",
- "host": "localhost",
- "port": 3306,
- "protocol": "tcp"
- },
- {
- "name": "SSH",
- "host": "localhost",
- "port": 22,
- "protocol": "tcp"
- }
- ]
}
}
diff --git a/index.php b/index.php
index fbf0c09..9a5c3d2 100644
--- a/index.php
+++ b/index.php
@@ -110,12 +110,87 @@ $update = $Config->checkUpdate();
<td>Server date & time</td>
<td id="system-server_date"></td>
</tr>
+ <tr>
+ <td>Load average</td>
+ <td id="system-load_avg"></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+ <div class="box column-right" id="esm-memory">
+ <div class="box-header">
+ <h1>Memory</h1>
+ <ul>
+ <li><a href="#" class="reload" onclick="esm.reloadBlock('memory');"><span class="icon-cycle"></span></a></li>
+ </ul>
+ </div>
+
+ <div class="box-content">
+ <table class="firstBold">
+ <tbody>
+ <tr>
+ <td class="w20p">Used %</td>
+ <td><div class="progressbar-wrap"><div class="progressbar" style="width: 0%;">0%</div></div></td>
+ </tr>
+ <tr>
+ <td class="w20p">Used</td>
+ <td id="memory-used"></td>
+ </tr>
+ <tr>
+ <td class="w20p">Buffers/Cache</td>
+ <td id="memory-cached"></td>
+ </tr>
+ <tr>
+ <td class="w20p">Free</td>
+ <td id="memory-free"></td>
+ </tr>
+ <tr>
+ <td class="w20p">Total</td>
+ <td id="memory-total"></td>
+ </tr>
</tbody>
</table>
</div>
</div>
- <div class="box column-right" id="esm-load_average">
+
+ <div class="box column-right" id="esm-swap">
+ <div class="box-header">
+ <h1>Swap</h1>
+ <ul>
+ <li><a href="#" class="reload" onclick="esm.reloadBlock('swap');"><span class="icon-cycle"></span></a></li>
+ </ul>
+ </div>
+
+ <div class="box-content">
+ <table class="firstBold">
+ <tbody>
+ <tr>
+ <td class="w20p">Used %</td>
+ <td><div class="progressbar-wrap"><div class="progressbar" style="width: 0%;">0%</div></div></td>
+ </tr>
+ <tr>
+ <td class="w20p">Used</td>
+ <td id="swap-used"></td>
+ </tr>
+ <tr>
+ <td class="w20p">Free</td>
+ <td id="swap-free"></td>
+ </tr>
+ <tr>
+ <td class="w20p">Total</td>
+ <td id="swap-total"></td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+
+
+<!--
+ <div class="box column-left" id="esm-load_average">
<div class="box-header">
<h1>Load Average</h1>
<ul>
@@ -140,9 +215,10 @@ $update = $Config->checkUpdate();
</div>
</div>
</div>
+-->
-
+<!--
<div class="box column-right" id="esm-cpu">
<div class="box-header">
<h1>CPU</h1>
@@ -184,9 +260,11 @@ $update = $Config->checkUpdate();
</table>
</div>
</div>
+-->
+<!--
<div class="box column-left" id="esm-network">
<div class="box-header">
<h1>Network usage</h1>
@@ -209,6 +287,7 @@ $update = $Config->checkUpdate();
</table>
</div>
</div>
+-->
<div class="cls"></div>
@@ -246,72 +325,7 @@ $update = $Config->checkUpdate();
-
- <div class="box column-left" id="esm-memory">
- <div class="box-header">
- <h1>Memory</h1>
- <ul>
- <li><a href="#" class="reload" onclick="esm.reloadBlock('memory');"><span class="icon-cycle"></span></a></li>
- </ul>
- </div>
-
- <div class="box-content">
- <table class="firstBold">
- <tbody>
- <tr>
- <td class="w20p">Used %</td>
- <td><div class="progressbar-wrap"><div class="progressbar" style="width: 0%;">0%</div></div></td>
- </tr>
- <tr>
- <td class="w20p">Used</td>
- <td id="memory-used"></td>
- </tr>
- <tr>
- <td class="w20p">Free</td>
- <td id="memory-free"></td>
- </tr>
- <tr>
- <td class="w20p">Total</td>
- <td id="memory-total"></td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
-
- <div class="box column-right" id="esm-swap">
- <div class="box-header">
- <h1>Swap</h1>
- <ul>
- <li><a href="#" class="reload" onclick="esm.reloadBlock('swap');"><span class="icon-cycle"></span></a></li>
- </ul>
- </div>
-
- <div class="box-content">
- <table class="firstBold">
- <tbody>
- <tr>
- <td class="w20p">Used %</td>
- <td><div class="progressbar-wrap"><div class="progressbar" style="width: 0%;">0%</div></div></td>
- </tr>
- <tr>
- <td class="w20p">Used</td>
- <td id="swap-used"></td>
- </tr>
- <tr>
- <td class="w20p">Free</td>
- <td id="swap-free"></td>
- </tr>
- <tr>
- <td class="w20p">Total</td>
- <td id="swap-total"></td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
-
-
+<!--
<div class="cls"></div>
@@ -377,6 +391,7 @@ $update = $Config->checkUpdate();
<div class="cls"></div>
</div>
+-->
diff --git a/libs/Utils/Misc.php b/libs/Utils/Misc.php
index 7aab276..37e578b 100644
--- a/libs/Utils/Misc.php
+++ b/libs/Utils/Misc.php
@@ -171,15 +171,10 @@ class Misc
{
$handle = @fsockopen($host, $port, $errno, $errstr, $timeout);
- if (!$handle)
- {
- return false;
- }
- else
- {
- fclose($handle);
+ if ($handle)
return true;
- }
+ else
+ return false;
}
elseif ($protocol == 'udp')
{
diff --git a/libs/disk.php b/libs/disk.php
index 8760816..f2b21cb 100644
--- a/libs/disk.php
+++ b/libs/disk.php
@@ -4,7 +4,7 @@ $Config = new Config();
$datas = array();
-if (!(exec('/bin/df -T -P | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df)))
+if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df)))
{
$datas[] = array(
'total' => 'N.A',
diff --git a/libs/load_average.php b/libs/load_average.php
index 09a2f3c..e736814 100644
--- a/libs/load_average.php
+++ b/libs/load_average.php
@@ -27,4 +27,4 @@ else
$datas = $load;
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);
diff --git a/libs/memory.php b/libs/memory.php
index a4eda7b..d2826f2 100644
--- a/libs/memory.php
+++ b/libs/memory.php
@@ -2,14 +2,13 @@
require '../autoload.php';
$free = 0;
+$cached = 0;
if (shell_exec('cat /proc/meminfo'))
{
$free = shell_exec('grep MemFree /proc/meminfo | awk \'{print $2}\'');
$buffers = shell_exec('grep Buffers /proc/meminfo | awk \'{print $2}\'');
- $cached = shell_exec('grep Cached /proc/meminfo | awk \'{print $2}\'');
-
- $free = (int)$free + (int)$buffers + (int)$cached;
+ $cached = $buffers + shell_exec('grep Cached /proc/meminfo | awk \'{print $2}\'');
}
// Total
@@ -19,19 +18,20 @@ if (!($total = shell_exec('grep MemTotal /proc/meminfo | awk \'{print $2}\'')))
}
// Used
-$used = $total - $free;
+$used = $total - $free - $cached;
// Percent used
$percent_used = 0;
if ($total > 0)
- $percent_used = 100 - (round($free / $total * 100));
+ $percent_used = round($used / $total * 100);
$datas = array(
'used' => Misc::getSize($used * 1024),
'free' => Misc::getSize($free * 1024),
+ 'cached ' => Misc::getSize($cached * 1024),
'total' => Misc::getSize($total * 1024),
'percent_used' => $percent_used,
);
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);
diff --git a/libs/system.php b/libs/system.php
index 702ef3b..17ed5a4 100644
--- a/libs/system.php
+++ b/libs/system.php
@@ -1,6 +1,5 @@
<?php
require '../autoload.php';
-date_default_timezone_set(@date_default_timezone_get());
// Hostname
$hostname = php_uname('n');
@@ -8,14 +7,11 @@ $hostname = php_uname('n');
// OS
if (!($os = shell_exec('/usr/bin/lsb_release -ds | cut -d= -f2 | tr -d \'"\'')))
{
- if (!($os = shell_exec('cat /etc/system-release | cut -d= -f2 | tr -d \'"\'')))
+ if(!($os = shell_exec('cat /etc/system-release | cut -d= -f2 | tr -d \'"\'')))
{
- if (!($os = shell_exec('cat /etc/os-release | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
+ if (!($os = shell_exec('find /etc/*-release -type f -exec cat {} \; | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
{
- if (!($os = shell_exec('find /etc/*-release -type f -exec cat {} \; | grep PRETTY_NAME | tail -n 1 | cut -d= -f2 | tr -d \'"\'')))
- {
- $os = 'N.A';
- }
+ $os = 'N.A';
}
}
}
@@ -61,6 +57,17 @@ if (!($server_date = shell_exec('/bin/date')))
$server_date = date('Y-m-d H:i:s');
}
+// Load average
+if (!($load_tmp = shell_exec('cat /proc/loadavg | awk \'{print $1","$2","$3}\'')))
+{
+ $load_array = array(0, 0, 0);
+}
+else
+{
+ $load_array = explode(',', $load_tmp);
+}
+
+$load_avg = implode(", ", $load_array);
$datas = array(
'hostname' => $hostname,
@@ -70,6 +77,7 @@ $datas = array(
'last_boot' => $last_boot,
'current_users' => $current_users,
'server_date' => $server_date,
+ 'load_avg' => $load_avg,
);
-echo json_encode($datas); \ No newline at end of file
+echo json_encode($datas);