mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
system: minor consolidation on previous
This commit is contained in:
parent
b61f21ae6b
commit
32c9ad3a4a
@ -37,6 +37,7 @@ exit_on_bootup();
|
||||
|
||||
/* when called with an argument we are in gateway switch mode */
|
||||
$monitor_hook = !empty($argv[1]);
|
||||
$monitor_gws = $argv[2] ?? '';
|
||||
|
||||
/* drop deleted routes */
|
||||
foreach (glob("/tmp/delete_route_*.todo") as $filename) {
|
||||
@ -50,11 +51,7 @@ foreach (glob("/tmp/delete_route_*.todo") as $filename) {
|
||||
system_routing_configure(true, null, !$monitor_hook);
|
||||
|
||||
if ($monitor_hook) {
|
||||
$cmd = ['/usr/local/etc/rc.syshook monitor'];
|
||||
for ($i = 2; $i < count($argv); $i++) {
|
||||
$cmd[] = escapeshellcmd($argv[$i]);
|
||||
}
|
||||
passthru(implode(' ', $cmd));
|
||||
passthru(exec_safe('/usr/local/etc/rc.syshook monitor %s', $monitor_gws));
|
||||
}
|
||||
|
||||
filter_configure_sync(true, false);
|
||||
|
||||
@ -64,7 +64,7 @@ while (1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$alarm = false;
|
||||
$alarm_gateways = [];
|
||||
|
||||
/* clear known gateways in first step to flush unknown in second step */
|
||||
$cleanup = $mode;
|
||||
@ -76,7 +76,6 @@ while (1) {
|
||||
}
|
||||
|
||||
/* run main watcher pass */
|
||||
$alarm_gateways = [];
|
||||
foreach ($status as $report) {
|
||||
$ralarm = false;
|
||||
|
||||
@ -118,9 +117,10 @@ while (1) {
|
||||
}
|
||||
|
||||
if ($ralarm) {
|
||||
$alarm = true;
|
||||
$alarm_gateways[] = $report['name'];
|
||||
}
|
||||
|
||||
/* diagnostics block as we may have no $ralarm but still want to log the transition */
|
||||
if ($mode[$report['name']] != $report['status']) {
|
||||
syslog(LOG_NOTICE, sprintf(
|
||||
"%s: %s (Addr: %s Alarm: %s RTT: %s RTTd: %s Loss: %s)",
|
||||
@ -132,14 +132,13 @@ while (1) {
|
||||
$report['stddev'],
|
||||
$report['loss']
|
||||
));
|
||||
$alarm_gateways[] = $report['name'];
|
||||
|
||||
/* update cached state now */
|
||||
$mode[$report['name']] = $report['status'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($alarm && $action != null) {
|
||||
if (count($alarm_gateways) && $action != null) {
|
||||
configdp_run($action, [implode(',', $alarm_gateways)]);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user