summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/pages
diff options
context:
space:
mode:
authorSimon Rettberg2021-09-21 16:52:06 +0200
committerSimon Rettberg2022-03-09 15:06:54 +0100
commit67e6b6c9981207d7d658f2ad2bf1c39b75c099c7 (patch)
treed2f54c424dd983a1500acf0d3d0bc3bbfee6e9cd /modules-available/statistics/pages
parent[statistics] Support new json-format of hardware info from client (diff)
downloadslx-admin-67e6b6c9981207d7d658f2ad2bf1c39b75c099c7.tar.gz
slx-admin-67e6b6c9981207d7d658f2ad2bf1c39b75c099c7.tar.xz
slx-admin-67e6b6c9981207d7d658f2ad2bf1c39b75c099c7.zip
[passthrough] New module for managing hardware passthrough for QEMU
Diffstat (limited to 'modules-available/statistics/pages')
-rw-r--r--modules-available/statistics/pages/hints.inc.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/modules-available/statistics/pages/hints.inc.php b/modules-available/statistics/pages/hints.inc.php
new file mode 100644
index 00000000..5c6acfbb
--- /dev/null
+++ b/modules-available/statistics/pages/hints.inc.php
@@ -0,0 +1,77 @@
+<?php
+
+class SubPage
+{
+
+ public static function doPreprocess()
+ {
+
+ }
+
+ public static function doRender()
+ {
+ self::showMemoryUpgrade();
+ self::showMemorySlow();
+ self::showUnusedSpace();
+ }
+
+ private static function showMemoryUpgrade()
+ {
+ $q = new HardwareQuery(HardwareInfo::MAINBOARD);
+ $q->addLocalColumn('Memory Slot Occupied');
+ $q->addGlobalColumn('Memory Slot Count');
+ $q->addGlobalColumn('Memory Maximum Capacity');
+ $q->addMachineColumn('clientip');
+ $q->addMachineColumn('hostname');
+ $q->addWhere(false, 'Memory Installed Capacity', '<', 8 * 1024 * 1024 * 1024);
+ $list = [];
+ foreach ($q->query() as $row) {
+ if (HardwareParser::convertSize($row['Memory Installed Capacity'], 'M', false)
+ >= HardwareParser::convertSize($row['Memory Maximum Capacity'], 'M', false)) {
+ $row['size_class'] = 'danger';
+ $list[] = $row;
+ } elseif ($row['Memory Slot Occupied'] < $row['Memory Slot Count']) {
+ $row['count_class'] = 'success';
+ array_unshift($list, $row);
+ } else {
+ $list[] = $row;
+ }
+ }
+ Render::addTemplate('hints-ram-upgrade', ['list' => $list]);
+ }
+
+ private static function showMemorySlow()
+ {
+ $q = new HardwareQuery(HardwareInfo::RAM_MODULE);
+ $q->addLocalColumn('Locator');
+ $q->addLocalColumn('Bank Locator');
+ $q->addGlobalColumn('Form Factor');
+ $q->addGlobalColumn('Type');
+ $q->addGlobalColumn('Size');
+ $q->addGlobalColumn('Manufacturer');
+ $q->addLocalColumn('Serial Number');
+ $q->addMachineColumn('clientip');
+ $q->addMachineColumn('hostname');
+ $q->addCompare(true, 'Speed', '>', false, 'Configured Memory Speed');
+ $list = $q->query()->fetchAll();
+ Render::addTemplate('hints-ram-underclocked', ['list' => $list]);
+ }
+
+ private static function showUnusedSpace()
+ {
+ $q = new HardwareQuery(HardwareInfo::HDD);
+ $q->addWhere(false, 'unused', '>', 2000000000); // 2 GB
+ $q->addMachineWhere('id44mb', '<', 20000); // 20 GB
+ $id44 = $q->query()->fetchAll();
+ $q = new HardwareQuery(HardwareInfo::HDD);
+ $q->addWhere(false, 'unused', '>', 25000000000); // 25 GB
+ $q->addMachineWhere('id44mb', '>', 20000); // 20 GB
+ $q->addMachineWhere('id45mb', '<', 20000); // 20 GB
+ $id45 = $q->query()->fetchAll();
+ Render::addTemplate('hints-hdd-grow', [
+ 'id44' => $id44,
+ 'id45' => $id45,
+ ]);
+ }
+
+} \ No newline at end of file