summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/pages
diff options
context:
space:
mode:
authorSimon Rettberg2022-05-17 13:36:44 +0200
committerSimon Rettberg2022-05-17 13:36:44 +0200
commit6c45754d5babe0e5f5aaf9c35698911368ee02e8 (patch)
tree230bafc1835cb8d64a2919ab51e0f2c93867030a /modules-available/statistics/pages
parent[inc/Util] Remove leading space in formatDuration() when < 24h (diff)
downloadslx-admin-6c45754d5babe0e5f5aaf9c35698911368ee02e8.tar.gz
slx-admin-6c45754d5babe0e5f5aaf9c35698911368ee02e8.tar.xz
slx-admin-6c45754d5babe0e5f5aaf9c35698911368ee02e8.zip
[statistics] Client details: Display booted system and bootup duration
Diffstat (limited to 'modules-available/statistics/pages')
-rw-r--r--modules-available/statistics/pages/machine.inc.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php
index 93f6d12a..15e2e516 100644
--- a/modules-available/statistics/pages/machine.inc.php
+++ b/modules-available/statistics/pages/machine.inc.php
@@ -240,6 +240,27 @@ class SubPage
$client['bioshtml'] = Render::parse('machine-bios-update', $ret);
}
}
+ // Last booted system. The boot-system entry is created when the client fetches the config, so
+ // early on, *before* we get the ~poweron event. But in the ~poweron event, the client provides the
+ // kernel uptime, which is subtracted from what we write to lastboot, so it is actually *before*
+ // boot-system.
+ $os = Database::queryFirst("SELECT `data` AS `system`, `dateline`
+ FROM statistic
+ WHERE (dateline >= :lastboot) AND typeid = 'boot-system' AND machineuuid = :uuid
+ ORDER BY dateline ASC LIMIT 1",
+ ['lastboot' => $client['lastboot'], 'uuid' => $uuid]);
+ if ($os !== false) {
+ $client['minilinux'] = $os['system'];
+ $graphical = Database::queryFirst("SELECT `dateline`
+ FROM statistic
+ WHERE (dateline >= :lastboot) AND typeid = 'graphical-startup' AND machineuuid = :uuid
+ ORDER BY dateline ASC LIMIT 1",
+ ['lastboot' => $client['lastboot'], 'uuid' => $uuid]);
+ $boottime = $graphical['dateline'] - $client['lastboot'];
+ if ($boottime < 400) { // Sanity-check
+ $client['boottime_s'] = gmdate('i:s', $boottime);
+ }
+ }
// Get locations
if (Module::isAvailable('locations')) {
$locs = Location::getLocationsAssoc();