diff options
author | Simon Rettberg | 2019-01-21 14:50:48 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-01-21 14:50:48 +0100 |
commit | 452bd74b291e63bcb0d84b118633e2a26852191c (patch) | |
tree | 92066af66505f29fcc4a49201d23a98663c4f789 /modules-available/statistics/hooks/cron.inc.php | |
parent | [serversetup-bwlp] Fix saving default; add missing lang tag (diff) | |
parent | [statistics] Log if client seems to have crashed (diff) | |
download | slx-admin-452bd74b291e63bcb0d84b118633e2a26852191c.tar.gz slx-admin-452bd74b291e63bcb0d84b118633e2a26852191c.tar.xz slx-admin-452bd74b291e63bcb0d84b118633e2a26852191c.zip |
Merge branch 'master' into ipxe
Diffstat (limited to 'modules-available/statistics/hooks/cron.inc.php')
-rw-r--r-- | modules-available/statistics/hooks/cron.inc.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules-available/statistics/hooks/cron.inc.php b/modules-available/statistics/hooks/cron.inc.php index 4df7b0d4..f05762bc 100644 --- a/modules-available/statistics/hooks/cron.inc.php +++ b/modules-available/statistics/hooks/cron.inc.php @@ -23,6 +23,19 @@ function state_cleanup() // Fix online state of machines that crashed $standby = time() - 86400 * 2; // Reset standby machines after two days $on = time() - 610; // Reset others after ~10 minutes + // Query for logging + $res = Database::simpleQuery("SELECT machineuuid, clientip, state 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'], + 'longdesc' => '', + 'uuid' => $row['machineuuid'], + )); + } + // Update -- yes this is not atomic. Should be sufficient for simple warnings though. Database::exec("UPDATE machine SET state = 'OFFLINE' WHERE lastseen < If(state = 'STANDBY', $standby, $on) AND state <> 'OFFLINE'"); } |