summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/hooks
diff options
context:
space:
mode:
authorSimon Rettberg2019-01-28 13:48:35 +0100
committerSimon Rettberg2019-01-28 13:48:35 +0100
commit3b1df888c963d906005ff139892df06a0d1ae2b4 (patch)
treee083400a996893fec66ed3c7e03cc234ca50a1af /modules-available/statistics/hooks
parent[inc/Util] readableFileSize: support input in KB/MB/... (diff)
downloadslx-admin-3b1df888c963d906005ff139892df06a0d1ae2b4.tar.gz
slx-admin-3b1df888c963d906005ff139892df06a0d1ae2b4.tar.xz
slx-admin-3b1df888c963d906005ff139892df06a0d1ae2b4.zip
[statistics] Track and display memory/tmp usage of clients
Diffstat (limited to 'modules-available/statistics/hooks')
-rw-r--r--modules-available/statistics/hooks/cron.inc.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php
index 0b8e740e..f22d0475 100644
--- a/modules-available/statistics/hooks/cron.inc.php
+++ b/modules-available/statistics/hooks/cron.inc.php
@@ -24,14 +24,17 @@ function state_cleanup()
$standby = time() - 86400 * 4; // Reset standby machines after four days
$on = time() - 610; // Reset others after ~10 minutes
// Query for logging
- $res = Database::simpleQuery("SELECT machineuuid, clientip, state, logintime, lastseen FROM machine
- WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'");
+ $res = Database::simpleQuery("SELECT machineuuid, clientip, state, logintime, lastseen, live_memfree, live_swapfree, live_tmpfree
+ FROM machine WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'");
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra)
VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array(
'type' => 'machine-mismatch-cron',
'client' => $row['clientip'],
- 'description' => 'Client timed out, last known state is ' . $row['state'],
+ 'description' => 'Client timed out, last known state is ' . $row['state']
+ . '. RAM: ' . Util::readableFileSize($row['live_memfree'], -1, 2)
+ . ', Swap: ' . Util::readableFileSize($row['live_swapfree'], -1, 2)
+ . ', ID44: ' . Util::readableFileSize($row['live_memfree'], -1, 2),
'longdesc' => '',
'uuid' => $row['machineuuid'],
));