diff options
author | Simon Rettberg | 2023-01-20 15:36:11 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-01-20 15:36:11 +0100 |
commit | 1861c25a106ac76f33818b8f5c3042b7e5a29aac (patch) | |
tree | ce0ceb876548a25193da672efba29c905ea007f1 /modules-available | |
parent | [eventlog] Sort dropdown, fix sample data display (diff) | |
download | slx-admin-1861c25a106ac76f33818b8f5c3042b7e5a29aac.tar.gz slx-admin-1861c25a106ac76f33818b8f5c3042b7e5a29aac.tar.xz slx-admin-1861c25a106ac76f33818b8f5c3042b7e5a29aac.zip |
[statistics] Expose proper id44/45 values in ~poweron event filtering
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/statistics/api.inc.php | 7 | ||||
-rw-r--r-- | modules-available/statistics/inc/hardwareparser.inc.php | 16 |
2 files changed, 15 insertions, 8 deletions
diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 0a5ba54c..bcc55944 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -168,7 +168,12 @@ if ($type[0] === '~') { } if ($json !== false) { - HardwareParser::parseMachine($uuid, $json); + $ret = HardwareParser::parseMachine($uuid, $json); + if ($ret !== null) { + // This data is more accurate and ends up in the DB anyways, so use it for event filtering too + $new['id44mb'] = $ret['id44mb']; + $new['id45mb'] = $ret['id45mb']; + } } // Check for suspicious hardware changes diff --git a/modules-available/statistics/inc/hardwareparser.inc.php b/modules-available/statistics/inc/hardwareparser.inc.php index 0840d3d3..f7a6545b 100644 --- a/modules-available/statistics/inc/hardwareparser.inc.php +++ b/modules-available/statistics/inc/hardwareparser.inc.php @@ -289,14 +289,14 @@ class HardwareParser * Process hardware info for given client. * @param string $uuid System-UUID of client * @param array $data Hardware info, deserialized assoc array. - * @return void + * @return ?array id44mb and id45mb as calculated from given HDD data */ public static function parseMachine(string $uuid, array $data) { $version = $data['version'] ?? 0; if ($version != 2) { error_log("Received unsupported hw json v$version"); - return; + return null; } // determine misc stuff first $globalMainboardExtra = []; @@ -601,12 +601,14 @@ class HardwareParser self::markDisconnected($uuid, HardwareInfo::HDD, $excludedHddHwIds); // // Mark parse date - Database::exec("UPDATE machine SET dataparsetime = UNIX_TIMESTAMP(), id44mb = :id44, id45mb = :id45 - WHERE machineuuid = :uuid", [ + $params = [ 'uuid' => $uuid, - 'id44' => round($id44 / (1024 * 1024)), - 'id45' => round($id45 / (1024 * 1024)), - ]); + 'id44mb' => round($id44 / (1024 * 1024)), + 'id45mb' => round($id45 / (1024 * 1024)), + ]; + Database::exec("UPDATE machine SET dataparsetime = UNIX_TIMESTAMP(), id44mb = :id44mb, id45mb = :id45mb + WHERE machineuuid = :uuid", $params); + return $params; } /** |