Skip to content

Commit

Permalink
Fix downtime in corner cases (librenms#16040)
Browse files Browse the repository at this point in the history
If somehow device outage wasn't recorded, fall back to last_polled (or now)
This should not happen in normal operation

fixes librenms#15634
  • Loading branch information
murrant committed May 19, 2024
1 parent 8fdf990 commit 6c6bdf2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Models/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ public function getCurrentOutage(): ?DeviceOutage
*/
public function downSince(): Carbon
{
return Carbon::createFromTimestamp((int) $this->getCurrentOutage()?->going_down);
$deviceOutage = $this->getCurrentOutage();

if ($deviceOutage) {
return Carbon::createFromTimestamp((int) $deviceOutage->going_down);
}

return $this->last_polled ?? Carbon::now();
}

/**
Expand Down

0 comments on commit 6c6bdf2

Please sign in to comment.