summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
diff options
context:
space:
mode:
authorSimon Rettberg2022-04-06 16:54:27 +0200
committerSimon Rettberg2022-04-06 16:54:27 +0200
commitd378b3806dd55bcd5c99110fd5569eb456f94d7e (patch)
tree1f95710e1270cdd71b81360d49a97013d01c2507 /modules-available/statistics
parent[systemstatus] Add distro and kernel version (diff)
downloadslx-admin-hardware-stats.tar.gz
slx-admin-hardware-stats.tar.xz
slx-admin-hardware-stats.zip
[statistics] client details: show which pci devices are passed throughhardware-stats
Diffstat (limited to 'modules-available/statistics')
-rw-r--r--modules-available/statistics/pages/machine.inc.php37
-rw-r--r--modules-available/statistics/templates/machine-main.html2
2 files changed, 35 insertions, 4 deletions
diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php
index 6ea0ce28..4e8f9f34 100644
--- a/modules-available/statistics/pages/machine.inc.php
+++ b/modules-available/statistics/pages/machine.inc.php
@@ -61,8 +61,12 @@ class SubPage
Message::addError('unknown-machine', $uuid);
return;
}
- if (Module::isAvailable('locations') && !Location::isLeaf($client['locationid'])) {
- $client['hasroomplan'] = false;
+ $locations = [];
+ if ($client['locationid'] > 0 && Module::isAvailable('locations')) {
+ if (!Location::isLeaf($client['locationid'])) {
+ $client['hasroomplan'] = false;
+ }
+ $locations = Location::getLocationRootChain($client['locationid']);
}
User::assertPermission('machine.view-details', (int)$client['locationid']);
// Hack: Get raw collected data
@@ -89,18 +93,43 @@ class SubPage
}
}
unset($item);
+ // PCI
+ // 1) get passthrough groups
+ $passthroughTypes = [];
+ if (!empty($locations)) {
+ $hw = new HardwareQuery(HardwareInfo::PCI_DEVICE, $uuid, true);
+ // TODO: Get list of enabled pass through groups for this client's location
+ $hw->addForeignJoin(true, '@PASSTHROUGH', 'passthrough_group_x_location', 'groupid',
+ 'locationid', $locations);
+ $hw->addGlobalColumn('vendor');
+ $hw->addGlobalColumn('device');
+ $res = $hw->query();
+ foreach ($res as $row) {
+ $devId = $row['vendor'] . ':' . $row['device'];
+ if (!isset($passthroughTypes[$devId])) {
+ $passthroughTypes[$devId] = [];
+ }
+ $passthroughTypes[$devId][] = $row['@PASSTHROUGH'];
+ }
+ }
+ // 2) Sort and mangle list
$client['lspci1'] = $client['lspci2'] = [];
foreach ($client['lspci'] as $item) {
+ $devId = $item['vendor'] . ':' . $item['device'];
$item['vendor_s'] = PciId::getPciId(PciId::VENDOR, $item['vendor']);
$item['device_s'] = PciId::getPciId(PciId::DEVICE, $item['vendor'] . $item['device']);
if ($item['vendor_s'] === false) {
$pciLookup[$item['vendor']] = true;
}
if ($item['device_s'] === false) {
- $pciLookup[$item['vendor'] . ':' . $item['device']] = true;
+ $pciLookup[$devId] = true;
+ }
+ // Passthrough enabled?
+ if (isset($passthroughTypes[$devId])) {
+ $item['pt'] = implode(', ', $passthroughTypes[$devId]);
}
$class = $item['class'];
- if ($class === '0300' || $class === '0200' || $class === '0403') {
+ if ($class === '0300' || $class === '0200' || $class === '0403' || !empty($item['pt'])) {
$dst =& $client['lspci1'];
} else {
$dst =& $client['lspci2'];
diff --git a/modules-available/statistics/templates/machine-main.html b/modules-available/statistics/templates/machine-main.html
index 9ec19820..aa80d5c3 100644
--- a/modules-available/statistics/templates/machine-main.html
+++ b/modules-available/statistics/templates/machine-main.html
@@ -396,6 +396,7 @@
{{#entries}}
<div class="small">
&emsp;└
+ <span class="badge">{{pt}}</span>
<span{{^vendor_s}} class="query-{{vendor}}"{{/vendor_s}}>{{vendor_s}}</span>
<span{{^device_s}} class="query-{{vendor}}-{{device}}"{{/device_s}}>{{device_s}}</span>
<a href="?do=passthrough&amp;show=hwlist#{{vendor}}-{{device}}">[{{vendor}}:{{device}}]</a>
@@ -408,6 +409,7 @@
{{#entries}}
<div class="small">
&emsp;└
+ <span class="badge">{{pt}}</span>
<span{{^vendor_s}} class="query-{{vendor}}"{{/vendor_s}}>{{vendor_s}}</span>
<span{{^device_s}} class="query-{{vendor}}-{{device}}"{{/device_s}}>{{device_s}}</span>
<span>[{{vendor}}:{{device}}]</span>