summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
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
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')
-rw-r--r--modules-available/statistics/api.inc.php5
-rw-r--r--modules-available/statistics/lang/de/template-tags.json2
-rw-r--r--modules-available/statistics/lang/en/template-tags.json2
-rw-r--r--modules-available/statistics/pages/machine.inc.php21
-rw-r--r--modules-available/statistics/templates/machine-main.html12
5 files changed, 41 insertions, 1 deletions
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 @@
</tr>
<tr>
<td class="text-nowrap">{{lang_lastBoot}}</td>
- <td>{{lastboot_s}}</td>
+ <td>
+ {{lastboot_s}}
+ {{#minilinux}}
+ <div>
+ {{lang_baseSystem}}: {{minilinux}}
+ {{#boottime_s}}
+ (<span title="{{lang_boottimeTooltip}}">{{boottime_s}}</span>)
+ {{/boottime_s}}
+ </div>
+ {{/minilinux}}
+ </td>
</tr>
<tr>
<td class="text-nowrap">{{lang_lastSeen}}</td>