diff options
author | Simon Rettberg | 2020-12-03 09:53:09 +0100 |
---|---|---|
committer | Simon Rettberg | 2020-12-03 09:53:09 +0100 |
commit | 4e9f2a4f71699ba7922d096b7b2679400560d03d (patch) | |
tree | 83da0c473f2ab3fddfda1c097f832396cd7c157d | |
parent | [webinterface] Include satellite's CA in config.tgz (diff) | |
download | slx-admin-4e9f2a4f71699ba7922d096b7b2679400560d03d.tar.gz slx-admin-4e9f2a4f71699ba7922d096b7b2679400560d03d.tar.xz slx-admin-4e9f2a4f71699ba7922d096b7b2679400560d03d.zip |
[statistics_reporting/statistics] Include system/runmode total counts
References #3781
3 files changed, 36 insertions, 0 deletions
diff --git a/modules-available/statistics/baseconfig/getconfig.inc.php b/modules-available/statistics/baseconfig/getconfig.inc.php index 053827db..e8afeffb 100644 --- a/modules-available/statistics/baseconfig/getconfig.inc.php +++ b/modules-available/statistics/baseconfig/getconfig.inc.php @@ -16,3 +16,21 @@ $res = Database::simpleQuery("SELECT setting, value FROM setting_machine WHERE m while ($row = $res->fetch(PDO::FETCH_ASSOC)) { ConfigHolder::add($row['setting'], $row['value'], 500); } + +// Statistics about booted system +ConfigHolder::addPostHook(function() use ($ip, $uuid) { + $type = Request::get('type', 'default', 'string'); + // System + if ($type !== 'default') { + Database::exec("INSERT INTO statistic (dateline, typeid, clientip, machineuuid, username, data) + VALUES (UNIX_TIMESTAMP(), :type, :ip, :uuid, '', :data)", + ['type' => 'boot-system', 'ip' => $ip, 'uuid' => $uuid, 'data' => $type]); + } + // Runmode + $mode = ConfigHolder::get('SLX_RUNMODE_MODULE'); + if (!empty($mode)) { + Database::exec("INSERT INTO statistic (dateline, typeid, clientip, machineuuid, username, data) + VALUES (UNIX_TIMESTAMP(), :type, :ip, :uuid, '', :data)", + ['type' => 'boot-runmode', 'ip' => $ip, 'uuid' => $uuid, 'data' => $mode]); + } +}); diff --git a/modules-available/statistics_reporting/inc/queries.inc.php b/modules-available/statistics_reporting/inc/queries.inc.php index fc61c68a..128d8e7d 100644 --- a/modules-available/statistics_reporting/inc/queries.inc.php +++ b/modules-available/statistics_reporting/inc/queries.inc.php @@ -437,5 +437,21 @@ class Queries return (int)$res['total']; } + public static function getBaseSystemStats(int $from, int $to) + { + return Database::queryAll("SELECT `data` AS `system`, Count(*) AS `count` + FROM statistic + WHERE (dateline BETWEEN $from AND $to) AND typeid = 'boot-system' + GROUP BY `system`"); + } + + public static function getRunmodeStats(int $from, int $to) + { + return Database::queryAll("SELECT `data` AS `mode`, Count(*) AS `count` + FROM statistic + WHERE (dateline BETWEEN $from AND $to) AND typeid = 'boot-runmode' + GROUP BY `mode`"); + } + } diff --git a/modules-available/statistics_reporting/inc/remotereport.inc.php b/modules-available/statistics_reporting/inc/remotereport.inc.php index 2de49d04..376691dd 100644 --- a/modules-available/statistics_reporting/inc/remotereport.inc.php +++ b/modules-available/statistics_reporting/inc/remotereport.inc.php @@ -90,6 +90,8 @@ class RemoteReport $data['dozmod'] = Queries::getDozmodStats($from, $to); $data['machines'] = Queries::getAggregatedMachineStats($from); $data['exams'] = Queries::getExamStats($from, $to); + $data['baseSystem'] = Queries::getBaseSystemStats($from, $to); + $data['runmode'] = Queries::getRunmodeStats($from, $to); $result['days' . $day] = $data; } $result['server'] = self::getLocalHardware(); |