diff --git a/library/Icingadb/ProvidedHook/Reporting/Common/SlaTimeline.php b/library/Icingadb/ProvidedHook/Reporting/Common/SlaTimeline.php index 7f0a2e3de..6466f47e5 100644 --- a/library/Icingadb/ProvidedHook/Reporting/Common/SlaTimeline.php +++ b/library/Icingadb/ProvidedHook/Reporting/Common/SlaTimeline.php @@ -62,9 +62,9 @@ public function setInitialHardState(int $state): self /** * Get the calculated SLA result of this timeline * - * @return float + * @return ?float */ - public function getResult(): float + public function getResult(): ?float { $problemTime = 0; $activeDowntimes = 0; @@ -97,6 +97,10 @@ public function getResult(): float $this->problemTime = $problemTime; $this->totalTime = $totalTime; + if ($totalTime <= 0) { + return null; + } + return 100 * ($totalTime - $problemTime) / $totalTime; }