From 3a455dcb2069e3442dca7d27cfce2787f640582a Mon Sep 17 00:00:00 2001 From: David Okon Date: Mon, 4 May 2026 12:02:51 +0200 Subject: [PATCH 1/2] Customer addition to Module // Customer uses dynamic automount of /home which leads to division by zero - Customer suggested changes in VmDiskUsageTable.php and SimpleUsageBar.php tried to fix indention fixed typo fixed typo fixed indention fixed indention --- library/Vspheredb/Web/Table/VmDiskUsageTable.php | 4 +++- library/Vspheredb/Web/Widget/SimpleUsageBar.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/library/Vspheredb/Web/Table/VmDiskUsageTable.php b/library/Vspheredb/Web/Table/VmDiskUsageTable.php index 993a24d2..7936545d 100644 --- a/library/Vspheredb/Web/Table/VmDiskUsageTable.php +++ b/library/Vspheredb/Web/Table/VmDiskUsageTable.php @@ -77,7 +77,9 @@ public function renderRow($row) } $free = Format::bytes($row->free_space) - . sprintf(' (%0.3f%%)', ($row->free_space / $row->capacity) * 100); + . ($row->capacity > 0 + ? sprintf(' (%0.3f%%)', ($row->free_space / $row->capacity) * 100) + : ' (n/a)'); $tr = $this::tr([ $this::td($caption, [ diff --git a/library/Vspheredb/Web/Widget/SimpleUsageBar.php b/library/Vspheredb/Web/Widget/SimpleUsageBar.php index eb6e46ce..942c0689 100644 --- a/library/Vspheredb/Web/Widget/SimpleUsageBar.php +++ b/library/Vspheredb/Web/Widget/SimpleUsageBar.php @@ -33,7 +33,9 @@ public function __construct($used, $total, $title) protected function assemble() { - $usedPercent = $this->used / $this->total; + $usedPercent = ($this->total > 0) + ? $this->used / $this->total + : 0; $bar = Html::tag('span', [ 'href' => '#', From 67a2a8b2151fc58a398e899777ceee75fd4b70d5 Mon Sep 17 00:00:00 2001 From: David Okon Date: Mon, 4 May 2026 16:52:04 +0200 Subject: [PATCH 2/2] Added Customer suggestion when DiskCheck returns Unknown when disk Size is 0 --- .../Monitoring/Rule/Definition/DiskUsageRuleDefinition.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/Vspheredb/Monitoring/Rule/Definition/DiskUsageRuleDefinition.php b/library/Vspheredb/Monitoring/Rule/Definition/DiskUsageRuleDefinition.php index 77e9ad22..1c5530f3 100644 --- a/library/Vspheredb/Monitoring/Rule/Definition/DiskUsageRuleDefinition.php +++ b/library/Vspheredb/Monitoring/Rule/Definition/DiskUsageRuleDefinition.php @@ -37,6 +37,9 @@ public function getInternalDefaults(): array protected function checkDisk($disk, Settings $settings): ?SingleCheckResult { + if ((int) $disk->capacity === 0) { + return null; + } if ($filter = $settings->get('disk_path_filter')) { if (!$this->filterMatchesPath($filter, $disk->disk_path)) { return null;