From cae5ec3f69dfdfcd4119c1c3f69c6a61c534e410 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sat, 10 Nov 2018 23:42:17 +0100 Subject: [PATCH] system: remove apinger, dpinger takes over --- Makefile | 1 - src/etc/inc/gwlb.inc | 332 ++---------------- src/etc/inc/plugins.inc.d/core.inc | 58 ++- src/etc/inc/rrd.inc | 62 ++-- src/etc/inc/services.inc | 29 -- src/etc/inc/system.inc | 2 +- src/etc/rc.monitor | 4 +- .../scripts/interfaces/dhclient-script | 3 +- src/www/diag_logs_gateways.php | 2 +- src/www/system_advanced_firewall.php | 81 ++--- src/www/system_gateway_groups.php | 2 +- src/www/system_gateway_groups_edit.php | 2 +- src/www/system_gateways.php | 8 +- src/www/system_gateways_edit.php | 277 ++++----------- src/www/widgets/widgets/gateways.widget.php | 16 - 15 files changed, 188 insertions(+), 691 deletions(-) diff --git a/Makefile b/Makefile index e386df530..086e99086 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,6 @@ CORE_DEPENDS_amd64?= beep bsdinstaller CORE_DEPENDS_i386?= ${CORE_DEPENDS_amd64} CORE_DEPENDS?= ${CORE_DEPENDS_${CORE_ARCH}} \ - apinger \ ca_root_nss \ choparp \ cpustats \ diff --git a/src/etc/inc/gwlb.inc b/src/etc/inc/gwlb.inc index 8e2a9500f..3838198b6 100644 --- a/src/etc/inc/gwlb.inc +++ b/src/etc/inc/gwlb.inc @@ -30,34 +30,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -function return_apinger_defaults() -{ - return array( - 'avg_delay_samples' => '10', - 'avg_loss_delay_samples' => '20', - 'avg_loss_samples' => '50', - 'down' => '10', - 'interval' => '1', - 'latencyhigh' => '500', - 'latencylow' => '200', - 'losshigh' => '20', - 'losslow' => '10', - ); -} - function return_dpinger_defaults() { return array( - 'alert_interval' => '1', - 'data_payload' => '0', - 'down' => '10', /* unused, only for validation */ + 'alert_interval' => '1', /* XXX not implemented in GUI */ + 'data_payload' => '0', /* XXX not implemented in GUI */ 'interval' => '1', 'latencyhigh' => '500', 'latencylow' => '200', - 'loss_interval' => '2', + 'loss_interval' => '2', /* XXX not implemented in GUI */ 'losshigh' => '20', 'losslow' => '10', - 'time_period' => '60', + 'time_period' => '60', /* XXX not implemented in GUI */ ); } @@ -70,9 +54,6 @@ function setup_gateways_monitor($verbose = false, $gwname = null) flush(); } - killbypid('/var/run/apinger.pid', 'TERM', true); - @unlink('/var/run/apinger.status'); - $running_processes = running_dpinger_processes(); foreach ($running_processes as $running_gwname => $process) { if (!empty($gwname) && $running_gwname != $gwname) { @@ -90,92 +71,8 @@ function setup_gateways_monitor($verbose = false, $gwname = null) $monitor_ips = array(); $dpinger_default = return_dpinger_defaults(); - $apinger_default = return_apinger_defaults(); - $apingerconfig = << $gateway) { - if (isset($config['system']['prefer_dpinger']) && !empty($gwname) && $gwname != $name) { + if (!empty($gwname) && $gwname != $name) { continue; } @@ -194,12 +91,13 @@ EOD; } /* - * Interface IP is needed since apinger will bind a socket to it. + * Interface IP is needed since dpinger will bind a socket to it. * However the config GUI should already have checked this and when - * PPoE is used the IP address is set to "dynamic". So using is_ipaddrv4 - * or is_ipaddrv6 to identify packet type would be wrong, especially as - * further checks (that can cope with the "dynamic" case) are present inside - * the if block. So using $gateway['ipprotocol'] is the better option. + * PPPoE is used the IP address is set to "dynamic". So using + * is_ipaddrv4 * or is_ipaddrv6 to identify packet type would be + * wrong, especially as further checks (that can cope with the + * "dynamic" case) are present inside the if block. So using + * $gateway['ipprotocol'] is the better option. */ if ($gateway['ipprotocol'] == "inet") { // This is an IPv4 gateway... $gwifip = find_interface_ip($gateway['interface']); @@ -283,136 +181,11 @@ EOD; $monitor_ips[] = $gateway['monitor']; - $apingercfg = "target \"{$gateway['monitor']}\" {\n"; - $apingercfg .= " description \"{$name}\"\n"; - $apingercfg .= " srcip \"{$gwifip}\"\n"; - - ## How often the probe should be sent - if (!empty($gateway['interval']) && is_numeric($gateway['interval'])) { - $interval = intval($gateway['interval']); # Restrict to Integer - if ($interval < 1) { - $interval = 1; # Minimum - } - if ($interval != $apinger_default['interval']) { - $apingercfg .= " interval " . $interval . "s\n"; # If not default value - } - } - - ## How many replies should be used to compute average delay - ## for controlling "delay" alarms - if (!empty($gateway['avg_delay_samples']) && is_numeric($gateway['avg_delay_samples'])) { - $avg_delay_samples = intval($gateway['avg_delay_samples']); # Restrict to Integer - if ($avg_delay_samples < 1) { - $avg_delay_samples = 1; # Minimum - } - if ($avg_delay_samples != $apinger_default['avg_delay_samples']) { - # If not default value - $apingercfg .= " avg_delay_samples " . $avg_delay_samples . "\n"; - } - } - - ## How many probes should be used to compute average loss - if (!empty($gateway['avg_loss_samples']) && is_numeric($gateway['avg_loss_samples'])) { - $avg_loss_samples = intval($gateway['avg_loss_samples']); # Restrict to Integer - if ($avg_loss_samples < 1) { - $avg_loss_samples = 1; # Minimum - } - if ($avg_loss_samples != $apinger_default['avg_loss_samples']) { - # If not default value - $apingercfg .= " avg_loss_samples " . $avg_loss_samples . "\n"; - } - } - - ## The delay (in samples) after which loss is computed - ## without this delays larger than interval would be treated as loss - if (!empty($gateway['avg_loss_delay_samples']) && is_numeric($gateway['avg_loss_delay_samples'])) { - $avg_loss_delay_samples = intval($gateway['avg_loss_delay_samples']); # Restrict to Integer - if ($avg_loss_delay_samples < 1) { - $avg_loss_delay_samples = 1; # Minimum - } - if ($avg_loss_delay_samples != $apinger_default['avg_loss_delay_samples']) { - # If not default value - $apingercfg .= " avg_loss_delay_samples " . $avg_loss_delay_samples . "\n"; - } - } - - $alarms = ""; - $alarmscfg = ""; - $override = false; - if (!empty($gateway['losslow'])) { - $alarmscfg .= "alarm loss \"{$name}loss\" {\n"; - $alarmscfg .= "\tpercent_low {$gateway['losslow']}\n"; - $alarmscfg .= "\tpercent_high {$gateway['losshigh']}\n"; - $alarmscfg .= "}\n"; - $alarms .= "\"{$name}loss\""; - $override = true; - } else { - if ($override == true) { - $alarms .= ","; - } - $alarms .= "\"loss\""; - $override = true; - } - if (!empty($gateway['latencylow'])) { - $alarmscfg .= "alarm delay \"{$name}delay\" {\n"; - $alarmscfg .= "\tdelay_low {$gateway['latencylow']}ms\n"; - $alarmscfg .= "\tdelay_high {$gateway['latencyhigh']}ms\n"; - $alarmscfg .= "}\n"; - if ($override == true) { - $alarms .= ","; - } - $alarms .= "\"{$name}delay\""; - $override = true; - } else { - if ($override == true) { - $alarms .= ","; - } - $alarms .= "\"delay\""; - $override = true; - } - if (!empty($gateway['down'])) { - $alarmscfg .= "alarm down \"{$name}down\" {\n"; - $alarmscfg .= "\ttime {$gateway['down']}s\n"; - $alarmscfg .= "}\n"; - if ($override == true) { - $alarms .= ","; - } - $alarms .= "\"{$name}down\""; - $override = true; - } else { - if ($override == true) { - $alarms .= ","; - } - $alarms .= "\"down\""; - $override = true; - } - if ($override == true) { - $apingercfg .= "\talarms override {$alarms};\n"; - } - - if (isset($gateway['force_down'])) { - $apingercfg .= "\tforce_down on\n"; - } - - $apingercfg .= " rrd file \"/var/db/rrd/{$gateway['name']}-quality.rrd\"\n"; - $apingercfg .= "}\n"; - $apingercfg .= "\n"; - - $apingerconfig .= $alarmscfg; - $apingerconfig .= $apingercfg; - /* * Create custom RRD graph with suitable settings that * may differ from the daemon's standards. */ - rrd_create_gateway_quality( - "/var/db/rrd/{$gateway['name']}-quality.rrd", - isset($config['system']['prefer_dpinger']) - ); - - if (!isset($config['system']['prefer_dpinger'])) { - continue; - } + rrd_create_gateway_quality("/var/db/rrd/{$gateway['name']}-quality.rrd"); /* log warnings via syslog */ $params = '-S '; @@ -483,80 +256,39 @@ EOD; mwexec_bg("/usr/local/bin/dpinger -f {$params}"); } - if (!isset($config['system']['prefer_dpinger'])) { - $gateways_arr = return_gateways_array(); - if (!is_array($gateways_arr)) { - log_error("No gateways to monitor. Apinger will not be run."); - } else { - file_put_contents('/var/etc/apinger.conf', $apingerconfig); - mwexec_bg('/usr/local/sbin/apinger -c /var/etc/apinger.conf'); - } - } - if ($verbose) { echo "done.\n"; } } -/* return the status of the apinger targets as a array */ function return_gateways_status($byname = false) { - global $config; - $status = array(); - if (isvalidpid('/var/run/apinger.pid')) { - /* always get the latest status from apinger */ - killbypid('/var/run/apinger.pid', 'USR1'); + $dpinger_gws = running_dpinger_processes(); + $status = array(); - /* we may read the wrong file here as it's async: */ - if (file_exists('/var/run/apinger.status')) { - $apingerstatus = file('/var/run/apinger.status'); - - foreach ($apingerstatus as $line) { - $info = explode('|', $line); - if ($byname == false) { - $target = $info[0]; - } else { - $target = $info[2]; - } - - $status[$target] = array(); - $status[$target]['monitorip'] = $info[0]; - $status[$target]['srcip'] = $info[1]; - $status[$target]['name'] = $info[2]; - $status[$target]['delay'] = sprintf('%0.1f ms', empty($info[6]) ? 0.0 : round($info[6], 1)); - $status[$target]['stddev'] = gettext('N/A'); - $status[$target]['loss'] = sprintf('%0.1f %%', empty($info[7]) ? 0.0 : round($info[7], 1)); - $status[$target]['status'] = trim($info[8]); - } + $gateways_arr = return_gateways_array(); + foreach ($dpinger_gws as $gwname => $gwdata) { + $dpinger_status = get_dpinger_status($gwname); + if ($dpinger_status === false) { + continue; } - } elseif (isset($config['system']['prefer_dpinger'])) { - $dpinger_gws = running_dpinger_processes(); - $status = array(); - $gateways_arr = return_gateways_array(); - foreach ($dpinger_gws as $gwname => $gwdata) { - $dpinger_status = get_dpinger_status($gwname); - if ($dpinger_status === false) { - continue; - } - - if ($byname == false) { - $target = $dpinger_status['monitorip']; - } else { - $target = $gwname; - } - - $status[$target] = array(); - $status[$target]['monitorip'] = $dpinger_status['monitorip']; - $status[$target]['srcip'] = $dpinger_status['srcip']; - $status[$target]['name'] = $gwname; - $status[$target]['delay'] = sprintf('%0.1f ms', empty($dpinger_status['latency_avg']) ? 0.0 : round($dpinger_status['latency_avg'], 1)); - $status[$target]['stddev'] = sprintf('%0.1f ms', empty($dpinger_status['latency_stddev']) ? 0.0 : round($dpinger_status['latency_stddev'], 1)); - $status[$target]['loss'] = sprintf('%0.1f %%', empty($dpinger_status['loss']) ? 0.0 : round($dpinger_status['loss'], 1)); - $status[$target]['status'] = $dpinger_status['status']; + if ($byname == false) { + $target = $dpinger_status['monitorip']; + } else { + $target = $gwname; } + + $status[$target] = array(); + $status[$target]['monitorip'] = $dpinger_status['monitorip']; + $status[$target]['srcip'] = $dpinger_status['srcip']; + $status[$target]['name'] = $gwname; + $status[$target]['delay'] = sprintf('%0.1f ms', empty($dpinger_status['latency_avg']) ? 0.0 : round($dpinger_status['latency_avg'], 1)); + $status[$target]['stddev'] = sprintf('%0.1f ms', empty($dpinger_status['latency_stddev']) ? 0.0 : round($dpinger_status['latency_stddev'], 1)); + $status[$target]['loss'] = sprintf('%0.1f %%', empty($dpinger_status['loss']) ? 0.0 : round($dpinger_status['loss'], 1)); + $status[$target]['status'] = $dpinger_status['status']; } /* tack on any gateways that have monitoring disabled diff --git a/src/etc/inc/plugins.inc.d/core.inc b/src/etc/inc/plugins.inc.d/core.inc index 2a38df40d..8e835bd44 100644 --- a/src/etc/inc/plugins.inc.d/core.inc +++ b/src/etc/inc/plugins.inc.d/core.inc @@ -1,30 +1,30 @@ - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2010 Seth Mos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ function rrd_create($rrdcreatecmd) { @@ -525,9 +525,8 @@ function rrd_configure($verbose = false) $rrdupdatesh .= "$rrdtool update $rrddbpath$ifname$cputemp N:\${CPUTEMP}\n"; /* end CPU Temp gathering */ - if (isset($config['system']['prefer_dpinger'])) { - /* Start gateway quality */ - $rrdupdatesh .= << $gateway) { - if (!isset($gateway['monitor_disable']) || $gateway['monitor_disable'] == '0') { - $gwcount += 1; - } - } - } - - if ($gwcount == 0) { - return false; - } - - return is_array(return_gateways_array()); -} - function is_dpinger_enabled() { global $config; - if (!isset($config['system']['prefer_dpinger'])) { - return false; - } - $gwcount = 0; if (isset($config['gateways']['gateway_item'])) { diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index dd1d594c3..a9f1ce075 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -688,7 +688,7 @@ function system_syslogd_start($verbose = false, $restart = false) $syslogconfs['configd'] = array('facility' => array('configd.py')); $syslogconfs['dhcpd'] = array('facility' => array('dhcpd', 'dhcrelay', 'dhclient', 'dhcp6c'), 'local' => '/var/dhcpd/var/run/log', 'remote' => 'dhcp'); $syslogconfs['filter'] = array('facility' => array('filterlog'), 'remote' => 'filter'); - $syslogconfs['gateways'] = array('facility' => array('apinger', 'dpinger'), 'remote' => 'apinger'); + $syslogconfs['gateways'] = array('facility' => array('dpinger'), 'remote' => 'apinger'); $syslogconfs['lighttpd'] = array('facility' => array('lighttpd')); $syslogconfs['pkg'] = array('facility' => array('pkg', 'pkg-static')); $syslogconfs['portalauth'] = array('facility' => array('captiveportal'), 'remote' => 'portalauth'); diff --git a/src/etc/rc.monitor b/src/etc/rc.monitor index 72633dfb6..e31a40113 100755 --- a/src/etc/rc.monitor +++ b/src/etc/rc.monitor @@ -32,9 +32,7 @@ if [ -z "${GATEWAY}" ]; then exit 1 fi -if [ ${#} -gt 1 ]; then - /usr/bin/logger -t dpinger "GATEWAY ALARM: ${GATEWAY} (Addr: ${2} Alarm: ${3} RTT: ${4}ms RTTd: ${5}ms Loss: ${6}%)" -fi +/usr/bin/logger -t dpinger "GATEWAY ALARM: ${GATEWAY} (Addr: ${2} Alarm: ${3} RTT: ${4}ms RTTd: ${5}ms Loss: ${6}%)" /usr/local/opnsense/service/configd_ctl.py -m \ "filter reload" \ diff --git a/src/opnsense/scripts/interfaces/dhclient-script b/src/opnsense/scripts/interfaces/dhclient-script index 59f0162c0..5477211fe 100755 --- a/src/opnsense/scripts/interfaces/dhclient-script +++ b/src/opnsense/scripts/interfaces/dhclient-script @@ -100,7 +100,8 @@ add_new_address() { $LOGGER "New Broadcast Address ($interface): $new_broadcast_address" $LOGGER "New Routers ($interface): $new_routers" - # This is necessary otherwise apinger will try to ping all 1s address + # This is necessary otherwise dpinger will try to ping all 1s address + # XXX still true?! if [ -n "$new_routers" ] && [ "$new_routers" != "255.255.255.255" ]; then echo $new_routers > /tmp/${interface}_router fi diff --git a/src/www/diag_logs_gateways.php b/src/www/diag_logs_gateways.php index 85398bb39..1e121cef7 100644 --- a/src/www/diag_logs_gateways.php +++ b/src/www/diag_logs_gateways.php @@ -3,6 +3,6 @@ $logfile = '/var/log/gateways.log'; $logclog = true; -$service_hook = 'apinger'; +$service_hook = 'dpinger'; require_once 'diag_logs_template.inc'; diff --git a/src/www/system_advanced_firewall.php b/src/www/system_advanced_firewall.php index fc0a96a3f..83e3dd2eb 100644 --- a/src/www/system_advanced_firewall.php +++ b/src/www/system_advanced_firewall.php @@ -1,33 +1,33 @@ - Copyright (C) 2008 Shrew Soft Inc. - Copyright (C) 2003-2004 Manuel Kasper - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2014-2015 Deciso B.V. + * Copyright (C) 2005-2007 Scott Ullrich + * Copyright (C) 2008 Shrew Soft Inc. + * Copyright (C) 2003-2004 Manuel Kasper + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ require_once("guiconfig.inc"); require_once("filter.inc"); @@ -64,7 +64,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig['enablebinatreflection'] = !empty($config['system']['enablebinatreflection']); $pconfig['enablenatreflectionhelper'] = isset($config['system']['enablenatreflectionhelper']) ? $config['system']['enablenatreflectionhelper'] : null; $pconfig['bypassstaticroutes'] = isset($config['filter']['bypassstaticroutes']); - $pconfig['prefer_dpinger'] = isset($config['system']['prefer_dpinger']); $pconfig['ip_change_kill_states'] = isset($config['system']['ip_change_kill_states']); } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $pconfig = $_POST; @@ -224,14 +223,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { unset($config['system']['gw_switch_default']); } - $old_pinger = isset($config['system']['prefer_dpinger']); - - if (!empty($pconfig['prefer_dpinger'])) { - $config['system']['prefer_dpinger'] = true; - } elseif (isset($config['system']['prefer_dpinger'])) { - unset($config['system']['prefer_dpinger']); - } - if (!empty($pconfig['ip_change_kill_states'])) { $config['system']['ip_change_kill_states'] = true; } elseif (isset($config['system']['ip_change_kill_states'])) { @@ -244,12 +235,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { system_cron_configure(); filter_configure(); - - if ($old_pinger != isset($config['system']['prefer_dpinger'])) { - mwexec('rm /var/db/rrd/*-quality.rrd'); - setup_gateways_monitor(); - rrd_configure(); - } } } @@ -400,18 +385,6 @@ include("head.inc"); - - - - /> - - - -
diff --git a/src/www/system_gateway_groups.php b/src/www/system_gateway_groups.php index a5e1715d4..b71715638 100644 --- a/src/www/system_gateway_groups.php +++ b/src/www/system_gateway_groups.php @@ -76,7 +76,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { legacy_html_escape_form_data($a_gateway_groups); legacy_html_escape_form_data($a_gateways); -$service_hook = 'apinger'; +$service_hook = 'dpinger'; include("head.inc"); diff --git a/src/www/system_gateway_groups_edit.php b/src/www/system_gateway_groups_edit.php index d8ab98265..c749488e3 100644 --- a/src/www/system_gateway_groups_edit.php +++ b/src/www/system_gateway_groups_edit.php @@ -140,7 +140,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { legacy_html_escape_form_data($a_gateways); legacy_html_escape_form_data($pconfig); -$service_hook = 'apinger'; +$service_hook = 'dpinger'; include("head.inc"); diff --git a/src/www/system_gateways.php b/src/www/system_gateways.php index 158e2c857..d07666201 100644 --- a/src/www/system_gateways.php +++ b/src/www/system_gateways.php @@ -196,7 +196,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { legacy_html_escape_form_data($a_gateways); -$service_hook = 'apinger'; +$service_hook = 'dpinger'; include("head.inc"); @@ -297,9 +297,7 @@ $( document ).ready(function() { - - @@ -352,11 +350,9 @@ $( document ).ready(function() { - - @@ -425,9 +421,7 @@ $( document ).ready(function() { - - diff --git a/src/www/system_gateways_edit.php b/src/www/system_gateways_edit.php index 41f0f7cf3..cdce8eb02 100644 --- a/src/www/system_gateways_edit.php +++ b/src/www/system_gateways_edit.php @@ -1,31 +1,31 @@ - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2014-2015 Deciso B.V. + * Copyright (C) 2010 Seth Mos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ require_once("guiconfig.inc"); require_once("services.inc"); @@ -37,11 +37,7 @@ foreach ($a_gateways as $gw) { $a_gateways_arr[] = $gw; } $a_gateways = $a_gateways_arr; -$apinger_default = return_apinger_defaults(); - -if (isset($config['system']['prefer_dpinger'])) { - $apinger_default = return_dpinger_defaults(); -} +$dpinger_default = return_dpinger_defaults(); // form processing if ($_SERVER['REQUEST_METHOD'] === 'POST') { @@ -201,7 +197,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } - /* input validation of apinger advanced parameters */ if (!empty($pconfig['latencylow'])) { if (!is_numeric($pconfig['latencylow'])) { $input_errors[] = gettext("The low latency threshold needs to be a numeric value."); @@ -245,12 +240,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors[] = gettext("The high latency threshold needs to be higher than the low latency threshold"); } } elseif (!empty($pconfig['latencylow'])) { - if (is_numeric($pconfig['latencylow']) && $pconfig['latencylow'] > $apinger_default['latencyhigh']) { - $input_errors[] = sprintf(gettext('The low latency threshold needs to be less than the default high latency threshold (%d)'), $apinger_default['latencyhigh']); + if (is_numeric($pconfig['latencylow']) && $pconfig['latencylow'] > $dpinger_default['latencyhigh']) { + $input_errors[] = sprintf(gettext('The low latency threshold needs to be less than the default high latency threshold (%d)'), $dpinger_default['latencyhigh']); } } elseif (!empty($pconfig['latencyhigh'])) { - if (is_numeric($pconfig['latencyhigh']) && $pconfig['latencyhigh'] < $apinger_default['latencylow']) { - $input_errors[] = sprintf(gettext('The high latency threshold needs to be higher than the default low latency threshold (%d)'), $apinger_default['latencylow']); + if (is_numeric($pconfig['latencyhigh']) && $pconfig['latencyhigh'] < $dpinger_default['latencylow']) { + $input_errors[] = sprintf(gettext('The high latency threshold needs to be higher than the default low latency threshold (%d)'), $dpinger_default['latencylow']); } } @@ -259,12 +254,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors[] = gettext("The high Packet Loss threshold needs to be higher than the low Packet Loss threshold"); } } elseif (!empty($pconfig['losslow'])) { - if (is_numeric($pconfig['losslow']) && $pconfig['losslow'] > $apinger_default['losshigh']) { - $input_errors[] = sprintf(gettext('The low Packet Loss threshold needs to be less than the default high Packet Loss threshold (%d)'), $apinger_default['losshigh']); + if (is_numeric($pconfig['losslow']) && $pconfig['losslow'] > $dpinger_default['losshigh']) { + $input_errors[] = sprintf(gettext('The low Packet Loss threshold needs to be less than the default high Packet Loss threshold (%d)'), $dpinger_default['losshigh']); } } elseif (!empty($pconfig['losshigh'])) { - if (is_numeric($pconfig['losshigh']) && $pconfig['losshigh'] < $apinger_default['losslow']) { - $input_errors[] = sprintf(gettext('The high Packet Loss threshold needs to be higher than the default low Packet Loss threshold (%d)'), $apinger_default['losslow']); + if (is_numeric($pconfig['losshigh']) && $pconfig['losshigh'] < $dpinger_default['losslow']) { + $input_errors[] = sprintf(gettext('The high Packet Loss threshold needs to be higher than the default low Packet Loss threshold (%d)'), $dpinger_default['losslow']); } } @@ -276,52 +271,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } - if (!empty($pconfig['down'])) { - if (! is_numeric($pconfig['down'])) { - $input_errors[] = gettext("The down time setting needs to be a numeric value."); - } elseif ($pconfig['down'] < 1) { - $input_errors[] = gettext("The down time setting needs to be positive."); - } - } - - if (!empty($pconfig['interval']) && !empty($pconfig['down'])) { - if ((is_numeric($pconfig['interval'])) && (is_numeric($pconfig['down'])) && $pconfig['interval'] > $pconfig['down']) { - $input_errors[] = gettext("The probe interval needs to be less than the down time setting."); - } - } elseif (!empty($pconfig['interval'])) { - if (is_numeric($pconfig['interval']) && $pconfig['interval'] > $apinger_default['down']) { - $input_errors[] = sprintf(gettext('The probe interval needs to be less than the default down time setting (%d)'), $apinger_default['down']); - } - } elseif (!empty($pconfig['down'])) { - if (is_numeric($pconfig['down']) && $pconfig['down'] < $apinger_default['interval']) { - $input_errors[] = sprintf(gettext('The down time setting needs to be higher than the default probe interval (%d)'), $apinger_default['interval']); - } - } - - if (!empty($pconfig['avg_delay_samples'])) { - if (!is_numeric($pconfig['avg_delay_samples'])) { - $input_errors[] = gettext("The average delay replies qty needs to be a numeric value."); - } elseif ($pconfig['avg_delay_samples'] < 1) { - $input_errors[] = gettext("The average delay replies qty needs to be positive."); - } - } - - if (!empty($pconfig['avg_loss_samples'])) { - if (!is_numeric($pconfig['avg_loss_samples'])) { - $input_errors[] = gettext("The average packet loss probes qty needs to be a numeric value."); - } elseif ($pconfig['avg_loss_samples'] < 1) { - $input_errors[] = gettext("The average packet loss probes qty needs to be positive."); - } - } - - if (!empty($pconfig['avg_loss_delay_samples'])) { - if (!is_numeric($pconfig['avg_loss_delay_samples'])) { - $input_errors[] = gettext("The lost probe delay needs to be a numeric value."); - } elseif ($pconfig['avg_loss_delay_samples'] < 1) { - $input_errors[] = gettext("The lost probe delay needs to be positive."); - } - } - if (count($input_errors) == 0) { // A result of obfuscating the list of gateways is that over here we need to map things back that should // be aligned with the configuration. Not going to fix this now. @@ -348,19 +297,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $gateway['ipprotocol'] = $pconfig['ipprotocol']; $gateway['interval'] = $pconfig['interval']; $gateway['descr'] = $pconfig['descr']; - $gateway['avg_delay_samples'] = $pconfig['avg_delay_samples']; - - if ($pconfig['avg_delay_samples_calculated'] == "yes" || $pconfig['avg_delay_samples_calculated'] == "on") { - $gateway['avg_delay_samples_calculated'] = true; - } - $gateway['avg_loss_samples'] = $pconfig['avg_loss_samples']; - if ($pconfig['avg_loss_samples_calculated'] == "yes" || $pconfig['avg_loss_samples_calculated'] == "on") { - $gateway['avg_loss_samples_calculated'] = true; - } - $gateway['avg_loss_delay_samples'] = $pconfig['avg_loss_delay_samples']; - if ($pconfig['avg_loss_delay_samples_calculated'] == "yes" || $pconfig['avg_loss_delay_samples_calculated'] == "on") { - $gateway['avg_loss_delay_samples_calculated'] = true; - } if ($pconfig['monitor_disable'] == "yes") { $gateway['monitor_disable'] = true; @@ -397,7 +333,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $gateway['defaultgw'] = true; } - foreach (array('latencylow', 'latencyhigh', 'losslow', 'losshigh', 'down') as $fieldname) { + foreach (array('latencylow', 'latencyhigh', 'losslow', 'losshigh') as $fieldname) { if (!empty($pconfig[$fieldname])) { $gateway[$fieldname] = $pconfig[$fieldname]; } @@ -462,10 +398,25 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { // load data from config $copy_fields = array( - 'name', 'weight', 'interval', 'avg_delay_samples', 'avg_loss_samples', 'avg_loss_delay_samples', - 'interface', 'friendlyiface', 'ipprotocol', 'gateway', 'latencylow', 'latencyhigh', 'losslow', 'losshigh', - 'down', 'monitor', 'descr', 'avg_delay_samples_calculated', 'avg_loss_samples_calculated', 'fargw', - 'avg_loss_delay_samples_calculated', 'monitor_disable', 'dynamic', 'defaultgw', 'force_down', 'disabled' + 'defaultgw', + 'descr', + 'disabled', + 'dynamic', + 'fargw', + 'force_down', + 'friendlyiface', + 'gateway', + 'interface', + 'interval', + 'ipprotocol', + 'latencyhigh', + 'latencylow', + 'losshigh', + 'losslow', + 'monitor', + 'monitor_disable', + 'name', + 'weight', ); foreach ($copy_fields as $fieldname) { if (isset($configId) && isset($a_gateways[$configId][$fieldname])) { @@ -482,7 +433,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { legacy_html_escape_form_data($a_gateways); legacy_html_escape_form_data($pconfig); -$service_hook = 'apinger'; +$service_hook = 'dpinger'; include("head.inc"); @@ -492,41 +443,6 @@ include("head.inc"); @@ -620,6 +535,15 @@ $( document ).ready(function() {
+ + + + + + + @@ -726,7 +650,7 @@ $( document ).ready(function() { @@ -752,7 +676,7 @@ $( document ).ready(function() { @@ -761,76 +685,11 @@ $( document ).ready(function() { - - - - - - - - - - - - - onclick="calculated_change()" /> - - - - - - - - - onclick="calculated_change()" /> - - - - - - - - - - onclick="calculated_change()" /> - - - - - - - - - -

-
-
- - - - - - - - - -   diff --git a/src/www/widgets/widgets/gateways.widget.php b/src/www/widgets/widgets/gateways.widget.php index 959c4176b..b1d7f9e3f 100644 --- a/src/www/widgets/widgets/gateways.widget.php +++ b/src/www/widgets/widgets/gateways.widget.php @@ -63,14 +63,9 @@ $gateways = return_gateways_array(); if ($("#"+tr_id).length) { $("#"+tr_id+" > td:eq(0)").html(''+gateway['name']+'
'+gateway['address']+'
'); $("#"+tr_id+" > td:eq(1)").html(gateway['delay']); - $("#"+tr_id+" > td:eq(2)").html(gateway['stddev']); $("#"+tr_id+" > td:eq(3)").html(gateway['loss']); $("#"+tr_id+" > td:eq(4)").html(''+gateway['status_translated']+''); - - $("#"+tr_id+" > td:eq(2)").html(gateway['loss']); - $("#"+tr_id+" > td:eq(3)").html(''+gateway['status_translated']+''); - // set color on status text switch (gateway['status']) { @@ -90,17 +85,10 @@ $gateways = return_gateways_array(); break; } - $("#"+tr_id+" > td:eq(4) > span").removeClass("label-danger label-warning label-success label"); if (status_color != '') { $("#"+tr_id+" > td:eq(4) > span").addClass("label label-" + status_color); } - - $("#"+tr_id+" > td:eq(3) > span").removeClass("label-danger label-warning label-success label"); - if (status_color != '') { - $("#"+tr_id+" > td:eq(3) > span").addClass("label label-" + status_color); - } - } }); } @@ -132,9 +120,7 @@ $gateways = return_gateways_array(); - - @@ -147,9 +133,7 @@ $gateways = return_gateways_array();
~
~ - ~ - ~