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
This commit is contained in:
Nathan Lam
2020-08-26 12:55:01 -07:00
committed by GitHub
parent 6b396d0be7
commit 10378f0dad

View File

@@ -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);