mirror of
https://github.com/lucaspalomodevelop/opnsense-core.git
synced 2026-03-13 00:07:27 +00:00
system: add logging to state kills and polish comments #8548
This commit is contained in:
parent
927bda891f
commit
045dec233a
@ -37,19 +37,21 @@ $affected_gateways = !empty($argv[1]) ? explode(',', $argv[1]) : [];
|
||||
|
||||
$metered_found_prios = ['inet' => 256, 'inet6' => 256];
|
||||
$metered_gws = ['inet' => [], 'inet6' => []];
|
||||
|
||||
foreach (return_gateways_status() as $status) {
|
||||
if ($status['status'] == 'down') {
|
||||
/* try to recover monitors stuck in down state ignoring "force_down" */
|
||||
/* recover monitors stuck in down state ignoring "force_down" */
|
||||
$gwnames[] = $status['name'];
|
||||
if (!empty($status['monitor_killstates']) && in_array($status['name'], $affected_gateways)) {
|
||||
configdp_run('filter kill gateway_states', [$status['gateway']], true);
|
||||
$uuid = trim(configdp_run('filter kill gateway_states', [$status['gateway']], true));
|
||||
log_msg("ROUTING: killing states for unreachable gateway {$status['name']} [$uuid]", LOG_NOTICE);
|
||||
}
|
||||
} elseif ($status['status'] != 'force_down') {
|
||||
/* collect "metered" gateways which should be killed depending priority */
|
||||
/* collect "metered" gateways for all non-down status reports */
|
||||
if (!empty($status['monitor_killstates_priority'])) {
|
||||
$metered_gws[$status['ipprotocol']][] = $status;
|
||||
/* only consider currently affected gateways as priority candidates */
|
||||
} elseif (in_array($status['name'], $affected_gateways)) {
|
||||
/* only trigger on "up" events to calculate highest prio */
|
||||
$metered_found_prios[$status['ipprotocol']] = min($status['priority'], $metered_found_prios[$status['ipprotocol']]);
|
||||
}
|
||||
}
|
||||
@ -59,7 +61,8 @@ foreach ($metered_found_prios as $ipproto => $metered_found_prio) {
|
||||
/* kill states for "metered" gateways */
|
||||
foreach ($metered_gws[$ipproto] as $status) {
|
||||
if ($status['priority'] > $metered_found_prio) {
|
||||
configdp_run('filter kill gateway_states', [$status['gateway']], true);
|
||||
$uuid = trim(configdp_run('filter kill gateway_states', [$status['gateway']], true));
|
||||
log_msg("ROUTING: killing states for deferred gateway {$status['name']} [$uuid]", LOG_NOTICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user