From 5db4480e30bbdaba680dfde36b2fdc258b17844c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 15 Nov 2022 17:21:05 +0100 Subject: [statistics] Add NIC Speed to client list, switch to Dictionary::number() --- modules-available/statistics/pages/list.inc.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'modules-available/statistics/pages') diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index ce686d56..db5f262a 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -54,6 +54,13 @@ class SubPage AND mxx.disconnecttime = 0 AND mxx.machineuuid IN (:ids)) GROUP BY mxx.machineuuid", ['type' => HardwareInfo::HDD, 'ids' => $uuids]); + $machineNicSpeed = Database::queryKeyValueList("SELECT mxx.machineuuid, Max(mxhp.`numeric`) AS num + FROM statistic_hw s + INNER JOIN machine_x_hw AS mxx ON (s.hwid = mxx.hwid AND s.hwtype = :type + AND mxx.disconnecttime = 0 AND mxx.machineuuid IN (:ids)) + INNER JOIN machine_x_hw_prop mxhp ON (mxx.machinehwid = mxhp.machinehwid AND mxhp.prop = :prop) + GROUP BY mxx.machineuuid", + ['type' => HardwareInfo::MAINBOARD, 'prop' => 'nic-speed', 'ids' => $uuids]); $machineWithConfigOverrides = Database::queryKeyValueList("SELECT machineuuid, Count(machineuuid) AS num FROM setting_machine WHERE machineuuid IN (:ids) GROUP BY machineuuid", ['ids' => $uuids]); // TODO: Cannot disable checkbox for those where user has no permission, since we got multiple actions now @@ -76,9 +83,9 @@ class SubPage $row['lastseen_int'] = $row['lastseen']; $row['lastseen'] = Util::prettyTime($row['lastseen']); //$row['lastboot'] = Util::prettyTime($row['lastboot']); - $row['gbram'] = round(ceil($row['mbram'] / 512) / 2, 1); // Trial and error until we got "expected" rounding.. - $row['gbtmp'] = round($row['id44mb'] / 1024); - $row['gbpersist'] = round($row['id45mb'] / 1024); + $row['gbram'] = Dictionary::number(ceil($row['mbram'] / 512) / 2, 1); // Trial and error until we got "expected" rounding.. + $row['gbtmp'] = Dictionary::number($row['id44mb'] / 1024); + $row['gbpersist'] = Dictionary::number($row['id45mb'] / 1024); $octets = explode('.', $row['clientip']); if (count($octets) === 4) { $row['subnet'] = "$octets[0].$octets[1].$octets[2]"; @@ -100,6 +107,13 @@ class SubPage // If we have ID44 space in our main table, we most likely got an HDD, so fake a count of 1 $row['hddcount'] = 1; } + if (!isset($machineNicSpeed[$row['machineuuid']])) { + $row['nic-speed'] = 0; + $row['nic-speed_s'] = '???'; + } else { + $row['nic-speed'] = $machineNicSpeed[$row['machineuuid']]; + $row['nic-speed_s'] = Dictionary::number($machineNicSpeed[$row['machineuuid']]); + } if (isset($row['data']) && !$row['data']) { $row['nohdd'] = true; } -- cgit v1.2.3-55-g7522