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/api.inc.php | 5 +++++ .../statistics/lang/de/template-tags.json | 2 ++ .../statistics/lang/en/template-tags.json | 2 ++ modules-available/statistics/pages/machine.inc.php | 21 +++++++++++++++++++++ .../statistics/templates/machine-main.html | 12 +++++++++++- 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 2d70153b..aa441b06 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -396,6 +396,11 @@ if ($type[0] === '~') { 'type' => HardwareInfo::SCREEN, )); } + + // Benchmarking + Database::exec("INSERT INTO statistic (dateline, typeid, clientip, machineuuid, username, `data`) + VALUES (UNIX_TIMESTAMP(), :type, :ip, :uuid, '', '')", + ['type' => 'graphical-startup', 'ip' => $ip, 'uuid' => $uuid]); } } else if ($type === '~suspend') { diff --git a/modules-available/statistics/lang/de/template-tags.json b/modules-available/statistics/lang/de/template-tags.json index fd9ac54b..444fc6e5 100644 --- a/modules-available/statistics/lang/de/template-tags.json +++ b/modules-available/statistics/lang/de/template-tags.json @@ -2,12 +2,14 @@ "lang_64bitSupport": "64\u2009Bit Gast-Support", "lang_address": "Adresse", "lang_apply": "Anwenden", + "lang_baseSystem": "Grundsystem", "lang_biosDate": "Ver\u00f6ffentlichungsdatum", "lang_biosFixes": "BIOS-Fehlerkorrekturen", "lang_biosUpdate": "BIOS Update", "lang_biosUpdateLink": "Zur Herstellerseite", "lang_biosVersion": "BIOS-Version", "lang_bootedWithoutAnyRunmode": "Ohne besonderen Betriebsmodus gestartet", + "lang_boottimeTooltip": "Bootzeit, Kernel-Init bis Login-Screen", "lang_clientInDifferentRunmode": "Aktueller Betriebsmodus", "lang_clientList": "Liste ausgew\u00e4hlter Rechner", "lang_configVars": "Konfigurationsvariablen", diff --git a/modules-available/statistics/lang/en/template-tags.json b/modules-available/statistics/lang/en/template-tags.json index 45ae06d1..542b3b40 100644 --- a/modules-available/statistics/lang/en/template-tags.json +++ b/modules-available/statistics/lang/en/template-tags.json @@ -2,12 +2,14 @@ "lang_64bitSupport": "64\u2009Bit guest support", "lang_address": "Address", "lang_apply": "Apply", + "lang_baseSystem": "Base system", "lang_biosDate": "Release date", "lang_biosFixes": "BIOS fixes", "lang_biosUpdate": "BIOS update", "lang_biosUpdateLink": "Go to vendor's site", "lang_biosVersion": "BIOS version", "lang_bootedWithoutAnyRunmode": "Booted without any mode", + "lang_boottimeTooltip": "Startup duration, kernel init to login screen", "lang_clientInDifferentRunmode": "Current mode", "lang_clientList": "List of selected machines", "lang_configVars": "Config Variables", 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(); diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html index ed9fe83a..0a2e2a74 100644 --- a/modules-available/statistics/templates/machine-main.html +++ b/modules-available/statistics/templates/machine-main.html @@ -41,7 +41,17 @@ {{lang_lastBoot}} - {{lastboot_s}} + + {{lastboot_s}} + {{#minilinux}} +
+ {{lang_baseSystem}}: {{minilinux}} + {{#boottime_s}} + ({{boottime_s}}) + {{/boottime_s}} +
+ {{/minilinux}} + {{lang_lastSeen}} -- cgit v1.2.3-55-g7522