summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-06-15 13:45:58 +0200
committerSimon Rettberg2022-06-15 13:45:58 +0200
commit496ac9b9680acae777dbd207858c874a7fcec252 (patch)
treeb766cd236318cf3355e581aa4b0def3c753e88de
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
-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
-rw-r--r--modules-available/statistics/lang/de/template-tags.json5
-rw-r--r--modules-available/statistics/lang/en/template-tags.json5
-rw-r--r--modules-available/statistics/pages/hints.inc.php45
-rw-r--r--modules-available/statistics/templates/hints-nic-speed.html31
-rw-r--r--modules-available/statistics/templates/hints-ram-underclocked.html80
8 files changed, 135 insertions, 54 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)
{
diff --git a/modules-available/statistics/lang/de/template-tags.json b/modules-available/statistics/lang/de/template-tags.json
index 444fc6e5..37635f1e 100644
--- a/modules-available/statistics/lang/de/template-tags.json
+++ b/modules-available/statistics/lang/de/template-tags.json
@@ -1,5 +1,6 @@
{
"lang_64bitSupport": "64\u2009Bit Gast-Support",
+ "lang_MbitPerSecond": "MBit\/s",
"lang_address": "Adresse",
"lang_apply": "Anwenden",
"lang_baseSystem": "Grundsystem",
@@ -71,6 +72,10 @@
"lang_moduleHeading": "Client-Statistiken",
"lang_more": "Mehr",
"lang_newMachines": "Neue Ger\u00e4te",
+ "lang_nicDuplex": "Duplex",
+ "lang_nicSlowSpeed": "Langsame Netzwerkkarte",
+ "lang_nicSlowSpeedText": "Diese Rechner sind mit weniger als Gigabit Ethernet mit dem Netzwerk verbunden. Bootvorg\u00e4nge und VM-Starts k\u00f6nnen sp\u00fcrbar verlangsamt sein. Wenn sich die Anbindung dieser Rechner nicht verbessern l\u00e4sst, versuchen Sie, eine ID45-Partition auf diesen Rechnern einzurichten, und lokales Caching in den Konfigurationsvariablen zu aktivieren, um die Performance von konsekutiven Bootvorg\u00e4ngen und VM-Starts zu verbessern.",
+ "lang_nicSpeed": "Geschwindigkeit",
"lang_noEdid": "Kein EDID",
"lang_noProjectorsDefined": "Keine Beamer-Overrides definiert",
"lang_notes": "Anmerkungen",
diff --git a/modules-available/statistics/lang/en/template-tags.json b/modules-available/statistics/lang/en/template-tags.json
index 542b3b40..a6e9d229 100644
--- a/modules-available/statistics/lang/en/template-tags.json
+++ b/modules-available/statistics/lang/en/template-tags.json
@@ -1,5 +1,6 @@
{
"lang_64bitSupport": "64\u2009Bit guest support",
+ "lang_MbitPerSecond": "MBit\/s",
"lang_address": "Address",
"lang_apply": "Apply",
"lang_baseSystem": "Base system",
@@ -71,6 +72,10 @@
"lang_moduleHeading": "Client Statistics",
"lang_more": "More",
"lang_newMachines": "New machines",
+ "lang_nicDuplex": "Duplex",
+ "lang_nicSlowSpeed": "Slow network link",
+ "lang_nicSlowSpeedText": "These machines are not connected via Gigabit ethernet. Bootup and VM startup can be notably slower. If you cannot improve the connectivity, try adding an ID45 partition to these clients, and enable local caching under \"config variables\".",
+ "lang_nicSpeed": "Speed",
"lang_noEdid": "No EDID",
"lang_noProjectorsDefined": "No projector overrides defined",
"lang_notes": "Notes",
diff --git a/modules-available/statistics/pages/hints.inc.php b/modules-available/statistics/pages/hints.inc.php
index 6ef2490e..5092157c 100644
--- a/modules-available/statistics/pages/hints.inc.php
+++ b/modules-available/statistics/pages/hints.inc.php
@@ -15,8 +15,9 @@ class SubPage
$locs = [];
}
self::showMemoryUpgrade($locs);
- self::showMemorySlow($locs);
+ self::showSlowNics($locs);
self::showUnusedSpace($locs);
+ self::showMemorySlow($locs);
}
/**
@@ -34,8 +35,7 @@ class SubPage
$q->addGlobalColumn('Memory Maximum Capacity');
$q->addMachineColumn('clientip');
$q->addMachineColumn('hostname');
- $col = $q->addLocalColumn('Memory Installed Capacity');
- $col->addCondition('<', 8 * 1024 * 1024 * 1024);
+ $q->addLocalColumn('Memory Installed Capacity')->addCondition('<', 8 * 1024 * 1024 * 1024);
$list = [];
foreach ($q->query() as $row) {
if (HardwareParser::convertSize($row['Memory Installed Capacity'], 'M', false)
@@ -49,6 +49,8 @@ class SubPage
$list[] = $row;
}
}
+ if (empty($list))
+ return;
Render::addTemplate('hints-ram-upgrade', ['list' => $list]);
}
@@ -62,8 +64,8 @@ class SubPage
if (!empty($locs)) {
$q->addMachineWhere('locationid', 'IN', $locs);
}
- $q->addLocalColumn('Locator');
- $q->addLocalColumn('Bank Locator');
+ //$q->addLocalColumn('Locator');
+ //$q->addLocalColumn('Bank Locator');
$q->addGlobalColumn('Form Factor');
$q->addGlobalColumn('Type');
$q->addGlobalColumn('Size');
@@ -73,7 +75,9 @@ class SubPage
$q->addMachineColumn('hostname');
$col = $q->addGlobalColumn('Speed');
$col->addCondition('>', $q->addLocalColumn('Configured Memory Speed'));
- $list = $q->query()->fetchAll();
+ $list = $q->query(['machineuuid', 'Size', 'Manufacturer', 'Speed', 'Configured Memory Speed'])->fetchAll();
+ if (empty($list))
+ return;
Render::addTemplate('hints-ram-underclocked', ['list' => $list]);
}
@@ -93,7 +97,7 @@ class SubPage
$q->addMachineColumn('hostname');
$q->addLocalColumn('unused')->addCondition('>', 2000000000); // 2 GB
$q->addMachineWhere('id44mb', '<', 20000); // 20 GB
- foreach ($q->query()->fetchAll() as $row) {
+ foreach ($q->query() as $row) {
$row['unused_s'] = Util::readableFileSize($row['unused']);
$row['id44mb_s'] = Util::readableFileSize($row['id44mb'], -1, 2);
$id44[] = $row;
@@ -110,16 +114,41 @@ class SubPage
$q->addMachineWhere('id45mb', '<', 20000); // 20 GB
// Only suggest SSD based systems, caching on spinning rust is usually slower than GBit
$q->addGlobalColumn('rotation_rate')->addCondition('=', 0);
- foreach ($q->query()->fetchAll() as $row) {
+ foreach ($q->query() as $row) {
$row['unused_s'] = Util::readableFileSize($row['unused']);
$row['id44mb_s'] = Util::readableFileSize($row['id44mb'], -1, 2);
$row['id45mb_s'] = Util::readableFileSize($row['id45mb'], -1, 2);
$id45[] = $row;
}
+ if (empty($id44) && empty($id45))
+ return;
Render::addTemplate('hints-hdd-grow', [
'id44' => $id44,
'id45' => $id45,
]);
}
+ private static function showSlowNics(array $locs)
+ {
+ $list = [];
+ $q = new HardwareQuery(HardwareInfo::MAINBOARD);
+ if (!empty($locs)) {
+ $q->addMachineWhere('locationid', 'IN', $locs);
+ }
+ $q->addMachineColumn('clientip');
+ $q->addMachineColumn('hostname');
+ $q->addLocalColumn('nic-speed')->addCondition('<', 1000);
+ $q->addLocalColumn('nic-duplex');
+ foreach ($q->query() as $row) {
+ if ($row['nic-speed'] == 0) {
+ $row['nic-speed'] = '???';
+ }
+ $list[] = $row;
+ }
+ if (empty($list))
+ return;
+ ArrayUtil::sortByColumn($list, 'nic-speed', SORT_ASC | SORT_NUMERIC);
+ Render::addTemplate('hints-nic-speed', ['list' => $list]);
+ }
+
} \ No newline at end of file
diff --git a/modules-available/statistics/templates/hints-nic-speed.html b/modules-available/statistics/templates/hints-nic-speed.html
new file mode 100644
index 00000000..c26364e6
--- /dev/null
+++ b/modules-available/statistics/templates/hints-nic-speed.html
@@ -0,0 +1,31 @@
+<h2>{{lang_nicSlowSpeed}}</h2>
+
+<p>{{lang_nicSlowSpeedText}}</p>
+
+<table class="table">
+ <thead>
+ <tr>
+ <th>{{lang_machine}}</th>
+ <th>{{lang_nicSpeed}}</th>
+ <th>{{lang_nicDuplex}}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#list}}
+ <tr>
+ <td>
+ <a class="slx-bold" href="?do=statistics&amp;uuid={{machineuuid}}">
+ {{hostname}}{{^hostname}}{{clientip}}{{/hostname}}
+ </a>
+ <div class="small">{{machineuuid}}</div>
+ </td>
+ <td class="text-nowrap">
+ {{nic-speed}}&thinsp;{{lang_MbitPerSecond}}
+ </td>
+ <td>
+ {{nic-duplex}}
+ </td>
+ </tr>
+ {{/list}}
+ </tbody>
+</table> \ No newline at end of file
diff --git a/modules-available/statistics/templates/hints-ram-underclocked.html b/modules-available/statistics/templates/hints-ram-underclocked.html
index 3722f109..a46f02d9 100644
--- a/modules-available/statistics/templates/hints-ram-underclocked.html
+++ b/modules-available/statistics/templates/hints-ram-underclocked.html
@@ -3,42 +3,46 @@
<p>{{lang_ramUnderclockedText}}</p>
<table class="table">
- <thead>
- <tr>
- <th>{{lang_machine}}</th>
- <th>{{lang_type}}</th>
- <th>{{lang_speedCurrent}}</th>
- <th>{{lang_speedDesign}}</th>
- <th>{{lang_manufacturer}}</th>
- <th>{{lang_serialNo}}</th>
- </tr>
- </thead>
- <tbody>
- {{#list}}
- <tr>
- <td>
- <a class="slx-bold" href="?do=statistics&amp;uuid={{machineuuid}}">
- {{hostname}}{{^hostname}}{{clientip}}{{/hostname}}
- </a>
- <div class="small">{{machineuuid}}</div>
- </td>
- <td>
- {{Type}} {{Form Factor}}
- <div>{{Size}}</div>
- </td>
- <td>
- {{Configured Memory Speed}}
- </td>
- <td>
- {{Speed}}
- </td>
- <td>
- {{Manufacturer}}
- </td>
- <td>
- {{Serial Number}}
- </td>
- </tr>
- {{/list}}
- </tbody>
+ <thead>
+ <tr>
+ <th>{{lang_machine}}</th>
+ <th>{{lang_type}}</th>
+ <th>{{lang_speedCurrent}}</th>
+ <th>{{lang_speedDesign}}</th>
+ <th>{{lang_manufacturer}}</th>
+ <th>{{lang_serialNo}}</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#list}}
+ <tr>
+ <td>
+ <a class="slx-bold" href="?do=statistics&amp;uuid={{machineuuid}}">
+ {{hostname}}{{^hostname}}{{clientip}}{{/hostname}}
+ </a>
+ <div class="small">{{machineuuid}}</div>
+ </td>
+ <td class="text-nowrap">
+ {{Type}} {{Form Factor}}
+ <div>{{Size}}</div>
+ </td>
+ <td class="text-nowrap">
+ {{Configured Memory Speed}}
+ </td>
+ <td class="text-nowrap">
+ {{Speed}}
+ </td>
+ <td class="text-nowrap">
+ {{Manufacturer}}
+ </td>
+ <td>
+ {{Serial Number}}
+ </td>
+ <td class="text-right">
+ <span class="badge">{{group_count}}</span>
+ </td>
+ </tr>
+ {{/list}}
+ </tbody>
</table>