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; 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' => '#',