From 496ac9b9680acae777dbd207858c874a7fcec252 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 15 Jun 2022 13:45:58 +0200 Subject: [statistics] Show clients with < gigabit ethernet in hints --- modules-available/statistics/pages/hints.inc.php | 45 +++++++++++++++++++----- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'modules-available/statistics/pages') 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 -- cgit v1.2.3-55-g7522