summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/inc
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics/inc')
-rw-r--r--modules-available/statistics/inc/hardwareinfo.inc.php10
-rw-r--r--modules-available/statistics/inc/hardwareparser.inc.php17
-rw-r--r--modules-available/statistics/inc/hardwarequery.inc.php10
3 files changed, 27 insertions, 10 deletions
diff --git a/modules-available/statistics/inc/hardwareinfo.inc.php b/modules-available/statistics/inc/hardwareinfo.inc.php
index 5f1a4372..6a6c74cd 100644
--- a/modules-available/statistics/inc/hardwareinfo.inc.php
+++ b/modules-available/statistics/inc/hardwareinfo.inc.php
@@ -42,9 +42,9 @@ class HardwareInfo
$hw = new HardwareQuery(self::PCI_DEVICE, $best['machineuuid'], true);
// TODO: Get list of enabled pass through groups for this client's location
$hw->addWhere(true, '@PASSTHROUGH', 'IN', ['GPU', 'GVT']);
- $hw->addColumn(true, 'vendor');
- $hw->addColumn(true, 'device');
- $hw->addColumn(false, 'slot');
+ $hw->addGlobalColumn('vendor');
+ $hw->addGlobalColumn('device');
+ $hw->addLocalColumn('slot');
$res = $hw->query();
$passthrough = [];
$slots = [];
@@ -67,8 +67,8 @@ class HardwareInfo
error_log('Querying slot ' . $slot);
$hw = new HardwareQuery(self::PCI_DEVICE, $best['machineuuid'], true);
$hw->addWhere(false, 'slot', 'LIKE', $slot . '.%');
- $hw->addColumn(true, 'vendor');
- $hw->addColumn(true, 'device');
+ $hw->addGlobalColumn('vendor');
+ $hw->addGlobalColumn('device');
foreach ($hw->query() as $row) {
$passthrough[$row['vendor'] . ':' . $row['device']] = 1;
error_log('Extra PT: ' . $row['vendor'] . ':' . $row['device']);
diff --git a/modules-available/statistics/inc/hardwareparser.inc.php b/modules-available/statistics/inc/hardwareparser.inc.php
index 5ba1e3dd..55ebbbcc 100644
--- a/modules-available/statistics/inc/hardwareparser.inc.php
+++ b/modules-available/statistics/inc/hardwareparser.inc.php
@@ -630,10 +630,12 @@ class HardwareParser
$globalMainboardExtra['Memory Slot Count'] += $mem['Number Of Devices'];
}
if (isset($mem['Maximum Capacity'])) {
- $globalMainboardExtra['Memory Maximum Capacity'] += self::convertSize($mem['Maximum Capacity'], 'M', false);
+ $globalMainboardExtra['Memory Maximum Capacity']
+ += self::convertSize($mem['Maximum Capacity'], 'M', false);
}
}
- $globalMainboardExtra['Memory Maximum Capacity'] = self::convertSize($globalMainboardExtra['Memory Maximum Capacity'] . ' MB');
+ $globalMainboardExtra['Memory Maximum Capacity']
+ = self::convertSize($globalMainboardExtra['Memory Maximum Capacity'] . ' MB', 'G');
// BIOS section - need to cross-match this with mainboard or system model, as it doesn't have a meaningful
// identifier on its own
$bios = self::prepareDmiProperties(self::getDmiHandles($data, 0)[0]);
@@ -651,8 +653,14 @@ class HardwareParser
}
}
// Using the general helper function
- $ramModCount = self::updateHwTypeFromDmi($uuid, $data, 17, HardwareInfo::RAM_MODULE, function (array $flat): bool {
- return self::convertSize(($flat['Size'] ?? 0), '', false) > 65 * 1024 * 1024;
+ $capa = 0;
+ $ramModCount = self::updateHwTypeFromDmi($uuid, $data, 17, HardwareInfo::RAM_MODULE, function (array $flat) use (&$capa): bool {
+ $size = self::convertSize(($flat['Size'] ?? 0), '', false);
+ if ($size > 65 * 1024 * 1024) {
+ $capa += $size;
+ return true;
+ }
+ return false;
},
['Locator'],
['Data Width',
@@ -669,6 +677,7 @@ class HardwareParser
);
// Fake RAM slots used/total into this
$localMainboardExtra['Memory Slot Occupied'] = $ramModCount;
+ $localMainboardExtra['Memory Installed Capacity'] = self::convertSize($capa, 'G', true);
self::updateHwTypeFromDmi($uuid, $data, 2, HardwareInfo::MAINBOARD, ['Manufacturer', 'Product Name'],
[],
['Manufacturer', 'Product Name', 'Type', 'Version'],
diff --git a/modules-available/statistics/inc/hardwarequery.inc.php b/modules-available/statistics/inc/hardwarequery.inc.php
index c7ecb35e..f0a73d27 100644
--- a/modules-available/statistics/inc/hardwarequery.inc.php
+++ b/modules-available/statistics/inc/hardwarequery.inc.php
@@ -13,7 +13,7 @@ class HardwareQuery
* @param string $type type form HardwareInfo
* @param ?string $uuid
*/
- public function __construct($type, $uuid = null, $connectedOnly = true)
+ public function __construct(string $type, $uuid = null, $connectedOnly = true)
{
if ($connectedOnly) {
$this->joins['mxhw_join'] = "INNER JOIN machine_x_hw mxhw ON (mxhw.hwid = shw.hwid AND mxhw.disconnecttime = 0)";
@@ -120,6 +120,14 @@ class HardwareQuery
$this->columns[$prop] = "$tid.`value` AS `$prop`";
}
+ public function addMachineColumn(string $column)
+ {
+ if (isset($this->columns[$column]))
+ return;
+ $this->joins['machine'] = 'INNER JOIN machine m USING (machineuuid)';
+ $this->columns[$column] = "m.$column";
+ }
+
/**
* @return false|PDOStatement
*/