Skip to content

Commit 7950d89

Browse files
committed
SlaTimeline: Fix division by zero error
1 parent 72bfa88 commit 7950d89

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/Icingadb/ProvidedHook/Reporting/Common/SlaTimeline.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public function setInitialHardState(int $state): self
6262
/**
6363
* Get the calculated SLA result of this timeline
6464
*
65-
* @return float
65+
* @return ?float
6666
*/
67-
public function getResult(): float
67+
public function getResult(): ?float
6868
{
6969
$problemTime = 0;
7070
$activeDowntimes = 0;
@@ -97,6 +97,10 @@ public function getResult(): float
9797
$this->problemTime = $problemTime;
9898
$this->totalTime = $totalTime;
9999

100+
if ($totalTime <= 0) {
101+
return null;
102+
}
103+
100104
return 100 * ($totalTime - $problemTime) / $totalTime;
101105
}
102106

0 commit comments

Comments
 (0)