mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add circular loop detection to MaxDepth (#15579)
* Add circular loop detection to MaxDepth * Formatting fixes * Remove controversial bit * Remove the recursion on the observer code updating max depth of child devices * Update the fast ping code to keep track of device dependencies instead of using max_depth * Style fixes * Add circular loop detection to MaxDepth * Formatting fixes * Remove controversial bit * Update the fast ping code to keep track of device dependencies instead of using max_depth * Style fixes * Fix the device list * Remove some more old lines from the ping job * Filter parents to those that have ping enabled to ensure child devices are always trigered for alerts * Formatting fixes * Added code to the ping check to order the hostnames so we try to ping parent devices before children * Formatting fixes * Add some types * Refine host ordering code * Fix output and simplify lnms poller:ping command * a bit more cleanup * Formatting fixes * Fixed up type for waiting on list * Formatting fix --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -371,7 +371,13 @@ if ($options['f'] === 'recalculate_device_dependencies') {
|
||||
// update all root nodes and recurse, chunk so we don't blow up
|
||||
Device::doesntHave('parents')->with('children')->chunkById(100, function (Collection $devices) {
|
||||
// anonymous recursive function
|
||||
$recurse = function (Device $device) use (&$recurse) {
|
||||
$processed = [];
|
||||
$recurse = function (Device $device) use (&$recurse, &$processed) {
|
||||
// Do not process the same device 2 times
|
||||
if (array_key_exists($device->device_id, $processed)) {
|
||||
return;
|
||||
}
|
||||
$processed[$device->device_id] = true;
|
||||
$device->updateMaxDepth();
|
||||
|
||||
$device->children->each($recurse);
|
||||
|
Reference in New Issue
Block a user