Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a501b50
Ping: Use consistent error value
QuentinCG Jan 27, 2016
b631cd9
Ping: Add success and error ping colors
QuentinCG Jan 27, 2016
712ad21
Config: Make sure config is personal
QuentinCG Sep 17, 2016
c312975
display error (I have to remove that commit later)
Asenar Aug 27, 2015
f208dfb
Add: try/catch when config is invalid
Asenar Aug 27, 2015
187377e
Add: show last_cron in index.php
Asenar Aug 28, 2015
f0ef985
add libs/last_sftp_login
Asenar Oct 6, 2015
12701a4
esm.js for last_sftp_login
Asenar Jul 25, 2016
b542faf
Config constructor is now private (use instance() instead)
Asenar Jul 25, 2016
55a4d6f
replace $Config = new Config; by $config = Config::instance()
Asenar Jul 25, 2016
b550511
LogicException will have newline for better readability
Asenar Jul 25, 2016
75e5432
Add methods in Util/Misc (exec/shellexec/cache/ago)
Asenar Dec 19, 2016
74bf68e
replacing exec/shellexec by Misc::exec/Misc::shellexec
Asenar Dec 19, 2016
2dd31af
replacing exec/shellexec by Misc::exec/Misc::shellexec in libs/*.php
Asenar Dec 19, 2016
6cc0cf7
Improve config.php
Asenar Dec 19, 2016
0c80826
put command in conf/esm.config.json
Asenar Dec 19, 2016
087e75f
Add lastCron information
Asenar Dec 19, 2016
adf705e
Add: suppress output when --quiet
Asenar Dec 19, 2016
6da1cec
Add cron script
Asenar Dec 19, 2016
2e65e88
cache file can have a prefix
Asenar Dec 19, 2016
aa38a98
html fixes
Asenar Dec 19, 2016
f9601ec
set version to 2.6
Asenar Dec 19, 2016
a5db890
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 | tail -n +2 | awk \'{ if (NF > 7) { for (i=1; i<NF-6; i++) { printf("%s ", $i); } for (i=NF-6; i<NF; i++) { printf("%s,", $i); } print $NF; } else { 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 | awk '{ printf $1\";\"; for (i=4; i<NF; i++) printf $i\" \"; print $NF; }'"
"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