From 91bc3bf479074d2889b3b83842121ae078d952dd Mon Sep 17 00:00:00 2001 From: AdamB Date: Fri, 6 Oct 2023 01:53:38 +0100 Subject: [PATCH] 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 --- app/Observers/DeviceObserver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Observers/DeviceObserver.php b/app/Observers/DeviceObserver.php index 2fd33a305e..8c748188f4 100644 --- a/app/Observers/DeviceObserver.php +++ b/app/Observers/DeviceObserver.php @@ -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