summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/pages/hints.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2021-09-30 17:44:30 +0200
committerSimon Rettberg2022-03-09 15:06:54 +0100
commitd736e75ade7a4472aefb72af9036f86016adcb42 (patch)
tree39e38d5dd687bc6d25cb1de45ce4b78423aa7984 /modules-available/statistics/pages/hints.inc.php
parent[passthrough] New module for managing hardware passthrough for QEMU (diff)
downloadslx-admin-d736e75ade7a4472aefb72af9036f86016adcb42.tar.gz
slx-admin-d736e75ade7a4472aefb72af9036f86016adcb42.tar.xz
slx-admin-d736e75ade7a4472aefb72af9036f86016adcb42.zip
[statistics] Adapt hw-data parsing to new json format for display
Diffstat (limited to 'modules-available/statistics/pages/hints.inc.php')
-rw-r--r--modules-available/statistics/pages/hints.inc.php50
1 files changed, 41 insertions, 9 deletions
diff --git a/modules-available/statistics/pages/hints.inc.php b/modules-available/statistics/pages/hints.inc.php
index 5c6acfbb..278c0e26 100644
--- a/modules-available/statistics/pages/hints.inc.php
+++ b/modules-available/statistics/pages/hints.inc.php
@@ -5,19 +5,26 @@ class SubPage
public static function doPreprocess()
{
-
+ User::assertPermission('hints');
}
public static function doRender()
{
- self::showMemoryUpgrade();
- self::showMemorySlow();
- self::showUnusedSpace();
+ $locs = User::getAllowedLocations('hints');
+ if (in_array(0, $locs)) {
+ $locs = [];
+ }
+ self::showMemoryUpgrade($locs);
+ self::showMemorySlow($locs);
+ self::showUnusedSpace($locs);
}
- private static function showMemoryUpgrade()
+ private static function showMemoryUpgrade(array $locs)
{
$q = new HardwareQuery(HardwareInfo::MAINBOARD);
+ if (!empty($locs)) {
+ $q->addMachineWhere('locationid', 'IN', $locs);
+ }
$q->addLocalColumn('Memory Slot Occupied');
$q->addGlobalColumn('Memory Slot Count');
$q->addGlobalColumn('Memory Maximum Capacity');
@@ -40,9 +47,12 @@ class SubPage
Render::addTemplate('hints-ram-upgrade', ['list' => $list]);
}
- private static function showMemorySlow()
+ private static function showMemorySlow(array $locs)
{
$q = new HardwareQuery(HardwareInfo::RAM_MODULE);
+ if (!empty($locs)) {
+ $q->addMachineWhere('locationid', 'IN', $locs);
+ }
$q->addLocalColumn('Locator');
$q->addLocalColumn('Bank Locator');
$q->addGlobalColumn('Form Factor');
@@ -57,17 +67,39 @@ class SubPage
Render::addTemplate('hints-ram-underclocked', ['list' => $list]);
}
- private static function showUnusedSpace()
+ private static function showUnusedSpace(array $locs)
{
+ $id44 = $id45 = [];
+ // ID44
$q = new HardwareQuery(HardwareInfo::HDD);
+ if (!empty($locs)) {
+ $q->addMachineWhere('locationid', 'IN', $locs);
+ }
+ $q->addMachineColumn('clientip');
+ $q->addMachineColumn('hostname');
$q->addWhere(false, 'unused', '>', 2000000000); // 2 GB
$q->addMachineWhere('id44mb', '<', 20000); // 20 GB
- $id44 = $q->query()->fetchAll();
+ foreach ($q->query()->fetchAll() as $row) {
+ $row['unused_s'] = Util::readableFileSize($row['unused']);
+ $row['id44mb_s'] = Util::readableFileSize($row['id44mb'], -1, 2);
+ $id44[] = $row;
+ }
+ // ID45
$q = new HardwareQuery(HardwareInfo::HDD);
+ if (!empty($locs)) {
+ $q->addMachineWhere('locationid', 'IN', $locs);
+ }
+ $q->addMachineColumn('clientip');
+ $q->addMachineColumn('hostname');
$q->addWhere(false, 'unused', '>', 25000000000); // 25 GB
$q->addMachineWhere('id44mb', '>', 20000); // 20 GB
$q->addMachineWhere('id45mb', '<', 20000); // 20 GB
- $id45 = $q->query()->fetchAll();
+ foreach ($q->query()->fetchAll() 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;
+ }
Render::addTemplate('hints-hdd-grow', [
'id44' => $id44,
'id45' => $id45,