Fix dynamic group membership rule for devices.status equal 0 (#11699)

* Fix dynamic group membership rule for devices.status equal 0

* Fix dynamic group membership rule for devices.status equal 0 - moved code to right before running alerts
This commit is contained in:
Albert Siersema 2020-05-31 01:23:31 +02:00 committed by GitHub
parent 4b52cab776
commit 4f859cee65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 11 deletions

View File

@ -351,17 +351,7 @@ function poll_device($device, $force_module = false)
echo "Module [ $module ] disabled globally.\n\n";
}
}
// Update device_groups
echo "### Start Device Groups ###\n";
$dg_start = microtime(true);
$group_changes = \App\Models\DeviceGroup::updateGroupsFor($device['device_id']);
d_echo("Groups Added: " . implode(',', $group_changes['attached']) . PHP_EOL);
d_echo("Groups Removed: " . implode(',', $group_changes['detached']) . PHP_EOL);
echo "### End Device Groups, runtime: " . round(microtime(true) - $dg_start, 4) . "s ### \n\n";
if (!$force_module && !empty($graphs)) {
echo "Enabling graphs: ";
$graphs = collect($graphs)->keys();

View File

@ -143,6 +143,14 @@ foreach (dbFetch($query) as $device) {
$unreachable_devices++;
}
// Update device_groups
echo "### Start Device Groups ###\n";
$dg_start = microtime(true);
$group_changes = \App\Models\DeviceGroup::updateGroupsFor($device['device_id']);
d_echo("Groups Added: " . implode(',', $group_changes['attached']) . PHP_EOL);
d_echo("Groups Removed: " . implode(',', $group_changes['detached']) . PHP_EOL);
echo "### End Device Groups, runtime: " . round(microtime(true) - $dg_start, 4) . "s ### \n\n";
echo "#### Start Alerts ####\n";
$rules = new AlertRules();
$rules->runRules($device['device_id']);