Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ad063f4
Ping: Use consistent error value
QuentinCG Jan 27, 2016
dfdc2d6
Ping: Add success and error ping colors
QuentinCG Jan 27, 2016
2866dfb
Last login: Show more relevant information
QuentinCG Jan 27, 2016
da5c941
Config: Make sure config is personal
QuentinCG Sep 17, 2016
ec32099
Merge branch 'quentincg'
Asenar Dec 19, 2016
8270626
display error (I have to remove that commit later)
Asenar Aug 27, 2015
c6bc120
Add: try/catch when config is invalid
Asenar Aug 27, 2015
8b825ea
Add: show last_cron in index.php
Asenar Aug 28, 2015
4319855
add libs/last_sftp_login
Asenar Oct 6, 2015
5abe960
esm.js for last_sftp_login
Asenar Jul 25, 2016
c632143
Config constructor is now private (use instance() instead)
Asenar Jul 25, 2016
cd8aff9
replace $Config = new Config; by $config = Config::instance()
Asenar Jul 25, 2016
0f1d697
LogicException will have newline for better readability
Asenar Jul 25, 2016
7fc7414
Add methods in Util/Misc (exec/shellexec/cache/ago)
Asenar Dec 19, 2016
0d34b00
replacing exec/shellexec by Misc::exec/Misc::shellexec
Asenar Dec 19, 2016
fa29d91
replacing exec/shellexec by Misc::exec/Misc::shellexec in libs/*.php
Asenar Dec 19, 2016
823b817
Improve config.php
Asenar Dec 19, 2016
41bf615
put command in conf/esm.config.json
Asenar Dec 19, 2016
7f45f88
Add lastCron information
Asenar Dec 19, 2016
f001d79
Add: suppress output when --quiet
Asenar Dec 19, 2016
0e636f6
Add cron script
Asenar Dec 19, 2016
71f1533
cache file can have a prefix
Asenar Dec 19, 2016
46ed84c
html fixes
Asenar Dec 19, 2016
c024497
set version to 2.6
Asenar Dec 19, 2016
f2a9621
Merge branch 'cron-version'
Asenar Dec 19, 2016
a3a9f74
Add: chmod+x for cron/cron-monitoring
Asenar Dec 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/web/css/.sass-cache
.htpasswd
.htaccess
/conf/esm.config.json
6 changes: 5 additions & 1 deletion autoload.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php
define('ROOTPATH', __DIR__);

function eSMAutoload($class)
{
include __DIR__.'/libs/Utils/'.$class.'.php';
}

spl_autoload_register('eSMAutoload');
spl_autoload_register('eSMAutoload');
// for debug purpose
// error_reporting(E_ALL);
// ini_set('display_errors', 'On');
1 change: 1 addition & 0 deletions cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
69 changes: 0 additions & 69 deletions conf/esm.config.json

This file was deleted.

104 changes: 104 additions & 0 deletions conf/esm.config.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"esm": {
"version": "2.6",
"website": "http://www.ezservermonitor.com",
"check_updates": true,
"auto_refresh": 0,
"theme": "blue",
"custom_title": "",
"mode" : "cron",
"cron_output_path" : "cache",
"cron_output_prefix" : "ezservermonitor-",
"salt": "something random used to build the tmp files"
},
"system" : {
"cmdKernel" : "/bin/uname -r",
"cmdUptime" : "/usr/bin/cut -d. -f1 /proc/uptime",
"cmdLastBoot" : "cat /proc/uptime",
"cmdCurrentUser" : "who -u | awk '{ print $1 }' | wc -l",
"cmdServerDate" : "/bin/date"
},
"load_average":{
"cmd" : "cat /proc/loadavg | awk '{print $1','$2','$3}'"
},
"cpu": {
"cmdinfo" : "cat /proc/cpuinfo",
"cmdMaxFreq" : "cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq",
"cmdThermal" : "cat /sys/class/thermal/thermal_zone0/temp",
"cmdTemperature": "/usr/bin/sensors | grep -E '^(CPU Temp|Core 0)' | cut -d '+' -f2 | cut -d '.' -f1",
"enable_temperature": true
},
"disk": {
"cmd" : "/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}'",
"show_tmpfs": false,
"show_filesystem": true
},
"ping": {
"hosts": [
"facebook.com",
"google.com",
"yahoo.com"
]
},
"last_login": {
"cmd" : "/usr/bin/lastlog --time 365 | /usr/bin/awk -F' ' '{ print $1\" (\"$3\");\"$5, $4, $8, $6}'",
"enable": "1",
"max": "10"
},
"last_sftp_login": {
"enable": "1",
"max": "100"
},
"memory": {
"cmdMeminfo" : "cat /proc/meminfo",
"cmdMemFree" : "grep MemFree /proc/meminfo | awk '{print $2}'",
"cmdBuffers" : "grep Buffers /proc/meminfo | awk '{print $2}'",
"cmdCached" : "grep Cached /proc/meminfo | awk '{print $2}'",
"cmdMemTotal" : "grep MemTotal /proc/meminfo | awk '{print $2}'"
},
"swap" : {
"cmdSwapFree" : "grep SwapFree /proc/meminfo | awk '{print $2}'",
"cmdSwapTotal" : "grep SwapTotal /proc/meminfo | awk '{print $2}'"
},
"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"
}
]
}
}
19 changes: 19 additions & 0 deletions cron/cron-monitoring
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# usage: execute this script in a cron. you can create a file in /etc/cron.d/monitoring with the following content:

# [email protected]
#
# */5 * * * * root [ -x /var/www/path/to/monitoring/cron/cron-monitoring ] && /var/www/path/to/monitoring/cron/cron-monitoring || echo "monitoring cron fail"


# for script in $(ls /var/www/path/to/monitoring/libs/*.php);do
path=$(dirname $0);
path=$(realpath "$path/../libs");
for script in cpu disk last_cron last_login last_sftp_login load_average memory network ping services swap system; do
php $path/${script}.php --save --quiet
if [ $? -ne 0 ]; then
echo "ERROR for $script"
#else
# echo "ok for $script"
fi
done
53 changes: 44 additions & 9 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
<?php
require 'autoload.php';
$Config = new Config();
$update = $Config->checkUpdate();
try{
$Config = Config::instance();
$update = $Config->checkUpdate();
}
catch(Exception $e)
{
if ($e instanceof LogicException)
{
echo $e;
die("configuration invalide");
}
}
?>
<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -57,6 +67,17 @@
?>
</div>

<?php if ($Config->get('esm:mode') == 'cron'){ ?>
<div id="lastCron">
<?php
$time = Misc::cache('last_cron');
if ($time)
echo sprintf("Dernière mise à jour par cron: il y a <span class='seconds'>%d</span> secondes", time()-$time);
?>
<a href="#" class="reload" onclick="esm.reloadBlock('lastCron');"><span class="icon-cycle"></span></a>
</div>
<?php } ?>

<?php if (!is_null($update)): ?>
<div id="update">
<a href="<?php echo $update['fullpath']; ?>">New version available (<?php echo $update['availableVersion']; ?>) ! Click here to download</a>
Expand Down Expand Up @@ -316,7 +337,7 @@


<div class="t-center">
<div class="box column-left column-33" id="esm-last_login">
<div class="box column-left " id="esm-last_login">
<div class="box-header">
<h1>Last login</h1>
<ul>
Expand All @@ -335,9 +356,7 @@
</div>
</div>



<div class="box column-right column-33" id="esm-services">
<div class="box column-right " id="esm-services">
<div class="box-header">
<h1>Services status</h1>
<ul>
Expand All @@ -352,10 +371,26 @@
</div>
</div>

<div class="t-center">
<div class="box column-left " id="esm-last_sftp_login">
<div class="box-header">
<h1>Last SSH/SFTP login</h1>
<ul>
<li><a href="#" class="reload" onclick="esm.reloadBlock('last_sftp_login');"><span class="icon-cycle"></span></a></li>
</ul>
</div>
<div class="box-content">
<?php if ($Config->get('last_sftp_login:enable') == true): ?>
<table>
<tbody></tbody>
</table>
<?php else: ?>
<p>Disabled</p>
<?php endif; ?>
</div>
</div>



<div class="box t-center" style="margin: 0 33%;" id="esm-ping">
<div class="box column-right" id="esm-ping">
<div class="box-header">
<h1>Ping</h1>
<ul>
Expand Down
Loading