From 10378f0dadfd69b9eda66d76c5bf382ddbd60a3a Mon Sep 17 00:00:00 2001 From: Nathan Lam Date: Wed, 26 Aug 2020 12:55:01 -0700 Subject: [PATCH] Use overwrite_ip when set on devices for ping checks (#12022) * Use overwrite_ip when set on devices for ping checks * style changes * fix issue with overwriting tier 1 devices by moving the overwrite_ip check further upstream * style fixes * use poller target instead of custom function * style fixes --- app/Jobs/PingCheck.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Jobs/PingCheck.php b/app/Jobs/PingCheck.php index ea33843f4e..97317a75b0 100644 --- a/app/Jobs/PingCheck.php +++ b/app/Jobs/PingCheck.php @@ -156,14 +156,16 @@ class PingCheck implements ShouldQueue /** @var Builder $query */ $query = Device::canPing() - ->select(['devices.device_id', 'hostname', 'status', 'status_reason', 'last_ping', 'last_ping_timetaken', 'max_depth']) + ->select(['devices.device_id', 'hostname', 'overwrite_ip', 'status', 'status_reason', 'last_ping', 'last_ping_timetaken', 'max_depth']) ->orderBy('max_depth'); if ($this->groups) { $query->whereIn('poller_group', $this->groups); } - $this->devices = $query->get()->keyBy('hostname'); + $this->devices = $query->get()->keyBy(function ($device) { + return Device::pollerTarget(json_decode(json_encode($device), true)); + }); // working collections $this->tiered = $this->devices->groupBy('max_depth', true);