From 6c45754d5babe0e5f5aaf9c35698911368ee02e8 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 17 May 2022 13:36:44 +0200 Subject: [statistics] Client details: Display booted system and bootup duration --- modules-available/statistics/pages/machine.inc.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules-available/statistics/pages') 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(); -- cgit v1.2.3-55-g7522