summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/inc
diff options
context:
space:
mode:
authorSimon Rettberg2022-06-15 13:45:58 +0200
committerSimon Rettberg2022-06-15 13:45:58 +0200
commit496ac9b9680acae777dbd207858c874a7fcec252 (patch)
treeb766cd236318cf3355e581aa4b0def3c753e88de /modules-available/statistics/inc
parent[statistics] Make CPU and system model clickable in machine details (diff)
downloadslx-admin-496ac9b9680acae777dbd207858c874a7fcec252.tar.gz
slx-admin-496ac9b9680acae777dbd207858c874a7fcec252.tar.xz
slx-admin-496ac9b9680acae777dbd207858c874a7fcec252.zip
[statistics] Show clients with < gigabit ethernet in hints
Diffstat (limited to 'modules-available/statistics/inc')
-rw-r--r--modules-available/statistics/inc/hardwareparser.inc.php17
-rw-r--r--modules-available/statistics/inc/hardwarequery.inc.php4
-rw-r--r--modules-available/statistics/inc/hardwarequerycolumn.inc.php2
3 files changed, 15 insertions, 8 deletions
diff --git a/modules-available/statistics/inc/hardwareparser.inc.php b/modules-available/statistics/inc/hardwareparser.inc.php
index b9d1c13b..2a2f1f24 100644
--- a/modules-available/statistics/inc/hardwareparser.inc.php
+++ b/modules-available/statistics/inc/hardwareparser.inc.php
@@ -98,7 +98,7 @@ class HardwareParser
}
// Count, size (unitless)
if (is_numeric($val) && preg_match('/^-?[0-9]+$/', $val)
- && preg_match('/used|occupied|count|number|size|temperature|_start|_value|_thresh|_worst|_time/', $key)) {
+ && preg_match('/used|occupied|count|number|speed|width|size|capacity|temperature|_start|_value|_thresh|_worst|_time/', $key)) {
return (int)$val;
}
// Date
@@ -363,7 +363,7 @@ class HardwareParser
$localMainboardExtra['Memory Slot Occupied'] = $ramModCount;
$localMainboardExtra['Memory Installed Capacity'] = self::convertSize($capa, 'G', true);
// Also add generic socket, core and thread count to mainboard data. This doesn't seem to make too much sense
- //at first since it's not a property of the mainboard. But we can get away with it since we make it a local
+ // at first since it's not a property of the mainboard. But we can get away with it since we make it a local
// property, i.e. specific to a client. This is just aggregated, so it's not super well suited for the CPU
// hardware type, referenced below. In fact, on some systems the dmi/smbios tables don't contain all that much
// information about the CPU at all, so we have at least this.
@@ -372,6 +372,13 @@ class HardwareParser
continue;
$localMainboardExtra['cpu-' . $key] = $data['cpu'][$key];
}
+ // Do the same hack with the primary NIC's speed and duplex. Even if it's not an onboard NIC, we only have one
+ // primary boot interface
+ $bootNic = $data['net']['boot0'] ?? $data['net']['eth0'] ?? null;
+ if ($bootNic !== null) {
+ $localMainboardExtra['nic-speed'] = $bootNic['speed'] ?? 0;
+ $localMainboardExtra['nic-duplex'] = $bootNic['duplex'] ?? 'unknown';
+ }
// Finally handle mainbard data, with all of our gathered extra fields
self::updateHwTypeFromDmi($uuid, $data, 2, HardwareInfo::MAINBOARD, ['Manufacturer', 'Product Name'],
[],
@@ -435,7 +442,7 @@ class HardwareParser
}
self::markDisconnected($uuid, HardwareInfo::PCI_DEVICE, $pciHwIds);
// ---- Disks ------------------------------------
- $hddHwIds = [];
+ $excludedHddHwIds = [];
// Sum of all ID44/45 partitions in bytes
$id44 = $id45 = 0;
foreach (($data['drives'] ?? []) as $dev) {
@@ -568,10 +575,10 @@ class HardwareParser
'id' => $mappingId,
'keep' => array_keys($table),
]);
- $hddHwIds[] = $mappingId;
+ $excludedHddHwIds[] = $mappingId;
unset($smart, $lsblk);
} // End loop over disks
- self::markDisconnected($uuid, HardwareInfo::HDD, $hddHwIds);
+ self::markDisconnected($uuid, HardwareInfo::HDD, $excludedHddHwIds);
//
// Mark parse date
Database::exec("UPDATE machine SET dataparsetime = UNIX_TIMESTAMP(), id44mb = :id44, id45mb = :id45
diff --git a/modules-available/statistics/inc/hardwarequery.inc.php b/modules-available/statistics/inc/hardwarequery.inc.php
index 71530173..e458599d 100644
--- a/modules-available/statistics/inc/hardwarequery.inc.php
+++ b/modules-available/statistics/inc/hardwarequery.inc.php
@@ -127,7 +127,7 @@ class HardwareQuery
/**
* Build query string
- * @param string $groupBy Column to group by
+ * @param string[]|string $groupBy Column to group by
*/
public function buildQuery($groupBy = ''): string
{
@@ -154,7 +154,7 @@ class HardwareQuery
}
if (!empty($groupBy)) {
$columns[] = 'Count(*) AS group_count';
- $groupBy = " GROUP BY " . implode(', ', $groupBy);
+ $groupBy = " GROUP BY `" . implode('`, `', $groupBy) . '`';
} else {
$groupBy = '';
}
diff --git a/modules-available/statistics/inc/hardwarequerycolumn.inc.php b/modules-available/statistics/inc/hardwarequerycolumn.inc.php
index 77d97e8b..07e7ecec 100644
--- a/modules-available/statistics/inc/hardwarequerycolumn.inc.php
+++ b/modules-available/statistics/inc/hardwarequerycolumn.inc.php
@@ -30,7 +30,7 @@ class HardwareQueryColumn
/**
* Add necessary conditions, joins, columns to final SQL arrays. To be called
* from HardwareQuery::buildQuery().
- * @param array if column name is in this array, add as distinct GROUP_CONCAT to column.
+ * @param string[] $groupConcat if column name is NOT in this array, add as distinct GROUP_CONCAT to column.
*/
public function generate(array &$joins, array &$columns, array &$params, array $groupConcat = [], string $globalSrcTableAlias = null)
{