Show which host marked a device as down. (#15209)

* Show which host marked a device as down.
One of my pollers can't reach a device, it'd be nice to know which one is causing the issue.

* Only show the actor in a distributed setup

* Use distributed poller name as its now ensured

* Use node_id

* Change to avoid extra dns lookups

* Update DeviceObserver.php

* Update DeviceObserver.php

---------

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
AdamB 2023-10-06 01:53:38 +01:00 committed by GitHub
parent 087d588102
commit 91bc3bf479
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -7,6 +7,7 @@ use App\ApiClients\Oxidized;
use App\Models\Device;
use App\Models\Eventlog;
use File;
use LibreNMS\Config;
use LibreNMS\Enum\Severity;
use Log;
@ -41,7 +42,9 @@ class DeviceObserver
if ($device->isDirty(['status', 'status_reason'])) {
$type = $device->status ? 'up' : 'down';
$reason = $device->status ? $device->getOriginal('status_reason') : $device->status_reason;
Eventlog::log('Device status changed to ' . ucfirst($type) . " from $reason check.", $device, $type);
$polled_by = Config::get('distributed_poller') ? (' by ' . \config('librenms.node_id')) : '';
Eventlog::log(sprintf('Device status changed to %s from %s check%s.', ucfirst($type), $reason, $polled_by), $device, $type);
}
// key attribute changes