diff options
-rw-r--r-- | etc/inc/gwlb.inc | 63 | ||||
-rwxr-xr-x | usr/local/www/system_gateway_groups.php | 1 | ||||
-rwxr-xr-x | usr/local/www/system_gateways.php | 1 | ||||
-rwxr-xr-x | usr/local/www/system_gateways_edit.php | 129 | ||||
-rwxr-xr-x | usr/local/www/system_gateways_settings.php | 187 | ||||
-rwxr-xr-x | usr/local/www/system_routes.php | 1 |
6 files changed, 165 insertions, 217 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index 15c119f..f9dd0c1 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -42,14 +42,11 @@ function setup_gateways_monitor() { $a_gateway_item = &$config['gateways']['gateway_item']; - if (is_array($config['gateways']['settings'])) { - $a_settings = &$config['gateways']['settings']; - } else { - $a_settings['latencylow'] = "200"; - $a_settings['latencyhigh'] = "500"; - $a_settings['losslow'] = "10"; - $a_settings['losshigh'] = "20"; - } + $a_settings = array(); + $a_settings['latencylow'] = "200"; + $a_settings['latencyhigh'] = "500"; + $a_settings['losslow'] = "10"; + $a_settings['losshigh'] = "20"; /* kill apinger process */ if(is_process_running("apinger")) @@ -149,9 +146,10 @@ EOD; if(is_array($gateways_arr)) { $i = 2; foreach($gateways_arr as $name => $gateway) { + $gwref = $a_gateway_item[$gateway['attribute']]; /* for dynamic gateways without an IP address we subtitute a local one */ - if((is_numeric($gateway['attribute'])) && is_ipaddr($a_gateway_item[$gateway['attribute']]['monitor'])) { - $gateway['monitor'] = $a_gateway_item[$gateway['attribute']]['monitor']; + if((is_numeric($gateway['attribute'])) && is_ipaddr($gwref['monitor'])) { + $gateway['monitor'] = $gwref['monitor']; } else { if(($gateway['gateway'] == "dynamic") && ($gateway['monitor'])) { $gateway['monitor'] = "127.0.0.{$i}"; @@ -161,11 +159,44 @@ EOD; $gateway['monitor'] = $gateway['gateway']; } } - $apingerconfig .= "target \"{$gateway['monitor']}\" {\n"; - $apingerconfig .= " description \"{$gateway['name']}\"\n"; - $apingerconfig .= " rrd file \"{$g['vardb_path']}/rrd/{$gateway['name']}-quality.rrd\"\n"; - $apingerconfig .= "}\n"; - $apingerconfig .= "\n"; + + $apingercfg .= "target \"{$gateway['monitor']}\" {\n"; + $apingercfg .= " description \"{$gateway['name']}\"\n"; + $alarms = ""; + $override = false; + if (!empty($gwref['lowloss'])) { + $alarmscfg .= "alarm loss \"{$gateway['name']}loss\" {\n"; + $alarmscfg .= "\tpercent_low {$gwref['losslow']}\n"; + $alarmscfg .= "\tpercent_high {$gwref['losshigh']}\n"; + $alarmscfg .= "}\n"; + $alarms .= "\"{$gateway['name']}loss\""; + $override = true; + } + if (!empty($gwref['latencylow'])) { + $alarmscfg .= "alarm delay \"{$gateway['name']}delay\" {\n"; + $alarmscfg .= "\tdelay_low {$gwref['latencylow']}ms\n"; + $alarmscfg .= "\tdelay_high {$gwref['latencyhigh']}ms\n"; + $alarmscfg .= "}\n"; + if ($override == true) + $alarms .= ","; + $alarms .= "\"{$gateway['name']}delay\""; + $override = true; + } + if (!empty($gwref['down'])) { + $alarmscfg .= "alarm down \"{$gateway['name']}down\" {\n"; + $alarmscfg .= "\ttime {$gwref['down']}s\n"; + $alarmscfg .= "}\n"; + if ($override == true) + $alarms .= ","; + $alarms .= "\"{$gateway['name']}down\""; + $override = true; + } + if ($override == true) + $apingercfg .= "\talarms override {$alarms};\n"; + + $apingercfg .= " rrd file \"{$g['vardb_path']}/rrd/{$gateway['name']}-quality.rrd\"\n"; + $apingercfg .= "}\n"; + $apingercfg .= "\n"; if($gateway['monitor'] == $gateway['gateway']) { /* if the gateway is the same as the monitor we do not add a * route as this will break the routing table */ @@ -179,6 +210,8 @@ EOD; } } } + $apingerconfig .= $alarmscfg; + $apingerconfig .= $apingercfg; } fwrite($fd, $apingerconfig); fclose($fd); diff --git a/usr/local/www/system_gateway_groups.php b/usr/local/www/system_gateway_groups.php index 1c4a95e..d79627f 100755 --- a/usr/local/www/system_gateway_groups.php +++ b/usr/local/www/system_gateway_groups.php @@ -106,7 +106,6 @@ include("head.inc"); $tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php"); $tab_array[1] = array(gettext("Routes"), false, "system_routes.php"); $tab_array[2] = array(gettext("Groups"), true, "system_gateway_groups.php"); - $tab_array[3] = array(gettext("Settings"), false, "system_gateways_settings.php"); display_top_tabs($tab_array); ?> </td></tr> diff --git a/usr/local/www/system_gateways.php b/usr/local/www/system_gateways.php index f064023..6f38012 100755 --- a/usr/local/www/system_gateways.php +++ b/usr/local/www/system_gateways.php @@ -139,7 +139,6 @@ include("head.inc"); $tab_array[0] = array(gettext("Gateways"), true, "system_gateways.php"); $tab_array[1] = array(gettext("Routes"), false, "system_routes.php"); $tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php"); - $tab_array[3] = array(gettext("Settings"), false, "system_gateways_settings.php"); display_top_tabs($tab_array); ?> </td></tr> diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php index 1209704..5c14f17 100755 --- a/usr/local/www/system_gateways_edit.php +++ b/usr/local/www/system_gateways_edit.php @@ -69,6 +69,11 @@ if (isset($id) && $a_gateways[$id]) { $pconfig['friendlyiface'] = $a_gateways[$id]['friendlyiface']; $pconfig['gateway'] = $a_gateways[$id]['gateway']; $pconfig['defaultgw'] = isset($a_gateways[$id]['defaultgw']); + $pconfig['latencylow'] = $a_gateway_item[$id]['latencylow']; + $pconfig['latencyhigh'] = $a_gateway_item[$id]['latencyhigh']; + $pconfig['losslow'] = $a_gateway_item[$id]['losslow']; + $pconfig['losshigh'] = $a_gateway_item[$id]['losshigh']; + $pconfig['down'] = $a_gateway_item[$id]['down']; if (isset($a_gateways[$id]['dynamic'])) $pconfig['dynamic'] = true; if($a_gateways[$id]['monitor'] <> "") { @@ -146,6 +151,46 @@ if ($_POST) { } } + /* input validation */ + if($_POST['latencylow']) { + if (! is_numeric($_POST['latencylow'])) { + $input_errors[] = gettext("The low latency watermark needs to be a numeric value."); + } + } + + if($_POST['latencyhigh']) { + if (! is_numeric($_POST['latencyhigh'])) { + $input_errors[] = gettext("The high latency watermark needs to be a numeric value."); + } + } + if($_POST['losslow']) { + if (! is_numeric($_POST['losslow'])) { + $input_errors[] = gettext("The low loss watermark needs to be a numeric value."); + } + } + if($_POST['losshigh']) { + if (! is_numeric($_POST['losshigh'])) { + $input_errors[] = gettext("The high loss watermark needs to be a numeric value."); + } + } + + if(($_POST['latencylow']) && ($_POST['latencyhigh'])){ + if(($_POST['latencylow'] > $_POST['latencyhigh'])) { + $input_errors[] = gettext("The High latency watermark needs to be higher then the low latency watermark"); + } + } + + if(($_POST['losslow']) && ($_POST['losshigh'])){ + if($_POST['losslow'] > $_POST['losshigh']) { + $input_errors[] = gettext("The High packet loss watermark needs to be higher then the low packet loss watermark"); + } + } + if($_POST['down']) { + if (! is_numeric($_POST['down']) || $_POST['down'] < 1) { + $input_errors[] = gettext("The low latency watermark needs to be a numeric value."); + } + } + if (!$input_errors) { $reloadif = false; /* if we are processing a system gateway only save the monitorip */ @@ -194,6 +239,17 @@ if ($_POST) { unset($gateway['defaultgw']); } + if ($_POST['latencylow']) + $gateway['latencylow'] = $_POST['latencylow']; + if ($_POST['latencyhigh']) + $gateway['latencyhigh'] = $_POST['latencyhigh']; + if ($_POST['losslow']) + $gateway['losslow'] = $_POST['losslow']; + if ($_POST['losshigh']) + $gateway['losshigh'] = $_POST['losshigh']; + if ($_POST['down']) + $gateway['down'] = $_POST['down']; + /* when saving the manual gateway we use the attribute which has the corresponding id */ if (isset($id) && $a_gateway_item[$id]) { $a_gateway_item[$id] = $gateway; @@ -239,6 +295,11 @@ function enable_change(obj) { } } +function show_advanced_gateway() { + document.getElementById("showadvgatewaybox").innerHTML=''; + aodiv = document.getElementById('showgatewayadv'); + aodiv.style.display = "block"; +} </script> <?php if ($input_errors) print_input_errors($input_errors); ?> <form action="system_gateways_edit.php" method="post" name="iform" id="iform"> @@ -315,19 +376,63 @@ function enable_change(obj) { </td> </tr> <tr> - <td width="22%" valign="top" class="vncell"><?=gettext("Weight");?></td> + <td width="22%" valign="top" class="vncell"><?=gettext("Advanced");?></td> <td width="78%" class="vtable"> - <select name='weight' class='formfldselect' id='weight'> - <?php - for ($i = 1; $i < 6; $i++) { - $selected = ""; - if ($pconfig['weight'] == $i) - $selected = "selected"; - echo "<option value='{$i}' {$selected} >{$i}</option>"; - } - ?> - </select> - <strong><?=gettext("Weight for this gateway when used in a Gateway Group.");?></strong> <br /> + <div id="showadvgatewaybox" <? if (!empty($pconfig['latencylow']) || !empty($pconfig['latencyhigh']) || !empty($pconfig['losslow']) || !empty($pconfig['losshigh']) || (isset($pconfig['weight']) && $pconfig['weight'] > 1)) echo "style='display:none'"; ?>> + <input type="button" onClick="show_advanced_gateway()" value="Advanced"></input> - Show advanced option</a> + </div> + <div id="showgatewayadv" <? if (empty($pconfig['latencylow']) && empty($pconfig['latencyhigh']) && empty($pconfig['losslow']) && empty($pconfig['losshigh']) && (empty($pconfig['weight']) || $pconfig['weight'] == 1)) echo "style='display:none'"; ?>> + <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6"> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Weight");?></td> + <td width="78%" class="vtable"> + <select name='weight' class='formfldselect' id='weight'> + <?php + for ($i = 1; $i < 6; $i++) { + $selected = ""; + if ($pconfig['weight'] == $i) + $selected = "selected"; + echo "<option value='{$i}' {$selected} >{$i}</option>"; + } + ?> + </select> + <br /><?=gettext("Weight for this gateway when used in a Gateway Group.");?> <br /> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Latency thresholds");?></td> + <td width="78%" class="vtable"> + <?=gettext("From");?> + <input name="latencylow" type="text" class="formfld unknown" id="latencylow" size="2" + value="<?=htmlspecialchars($pconfig['latencylow']);?>"> + <?=gettext("To");?> + <input name="latencyhigh" type="text" class="formfld unknown" id="latencyhigh" size="2" + value="<?=htmlspecialchars($pconfig['latencyhigh']);?>"> + <br> <span class="vexpl"><?=gettext("These define the low and high water marks for latency in milliseconds.");?></span></td> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Packet Loss thresholds");?></td> + <td width="78%" class="vtable"> + <?=gettext("From");?> + <input name="losslow" type="text" class="formfld unknown" id="losslow" size="2" + value="<?=htmlspecialchars($pconfig['losslow']);?>"> + <?=gettext("To");?> + <input name="losshigh" type="text" class="formfld unknown" id="losshigh" size="2" + value="<?=htmlspecialchars($pconfig['losshigh']);?>"> + <br> <span class="vexpl"><?=gettext("These define the low and high water marks for packet loss in %.");?></span></td> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncellreq"><?=gettext("Down");?></td> + <td width="78%" class="vtable"> + <input name="down" type="text" class="formfld unknown" id="down" size="2" + value="<?=htmlspecialchars($pconfig['down']);?>"> + <br> <span class="vexpl"><?=gettext("This defines the down time for the alarm to fire, in seconds.");?></span></td> + </td> + </tr> + </table> + </div> </td> </tr> <tr> diff --git a/usr/local/www/system_gateways_settings.php b/usr/local/www/system_gateways_settings.php deleted file mode 100755 index 65640b0..0000000 --- a/usr/local/www/system_gateways_settings.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php -/* $Id$ */ -/* - status_rrd_graph.php - Part of pfSense - Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl> - 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. -*/ -/* - pfSense_MODULE: routing -*/ - -##|+PRIV -##|*IDENT=page-status-rrdgraphs -##|*NAME=Status: RRD Graphs page -##|*DESCR=Allow access to the 'Status: RRD Graphs' page. -##|*MATCH=status_rrd_graph_settings.php* -##|-PRIV - -require("guiconfig.inc"); - -if (!is_array($config['gateways']['settings'])) - $config['gateways']['settings'] = array(); - -$a_settings = &$config['gateways']['settings']; - -$changedesc = gettext("Gateways") . ": "; -$input_errors = array(); - -if (empty($a_settings)) { - $pconfig['latencylow'] = "100"; - $pconfig['latencyhigh'] = "500"; - $pconfig['losslow'] = "10"; - $pconfig['losshigh'] = "20"; -} else { - $pconfig['latencylow'] = $a_settings['latencylow']; - $pconfig['latencyhigh'] = $a_settings['latencyhigh']; - $pconfig['losslow'] = $a_settings['losslow']; - $pconfig['losshigh'] = $a_settings['losshigh']; -} - -if ($_POST) { - - unset($input_errors); - $pconfig = $_POST; - - /* input validation */ - if($_POST['latencylow']) { - if (! is_numeric($_POST['latencylow'])) { - $input_errors[] = gettext("The low latency watermark needs to be a numeric value."); - } - } - - if($_POST['latencyhigh']) { - if (! is_numeric($_POST['latencyhigh'])) { - $input_errors[] = gettext("The high latency watermark needs to be a numeric value."); - } - } - if($_POST['losslow']) { - if (! is_numeric($_POST['losslow'])) { - $input_errors[] = gettext("The low loss watermark needs to be a numeric value."); - } - } - if($_POST['losshigh']) { - if (! is_numeric($_POST['losshigh'])) { - $input_errors[] = gettext("The high loss watermark needs to be a numeric value."); - } - } - - if(($_POST['latencylow']) && ($_POST['latencyhigh'])){ - if(($_POST['latencylow'] > $_POST['latencyhigh'])) { - $input_errors[] = gettext("The High latency watermark needs to be higher then the low latency watermark"); - } - } - - if(($_POST['losslow']) && ($_POST['losshigh'])){ - if($_POST['losslow'] > $_POST['losshigh']) { - $input_errors[] = gettext("The High packet loss watermark needs to be higher then the low packet loss watermark"); - } - } - - - - if (!$input_errors) { - $a_settings['latencylow'] = $_POST['latencylow']; - $a_settings['latencyhigh'] = $_POST['latencyhigh']; - $a_settings['losslow'] = $_POST['losslow']; - $a_settings['losshigh'] = $_POST['losshigh']; - - - $config['gateways']['settings'] = $a_settings; - - $retval = 0; - $retval = setup_gateways_monitor(); - write_config(); - - $savemsg = get_std_save_message($retval); - } -} - -$pgtitle = array(gettext("Gateways"),gettext("Settings")); -include("head.inc"); - -?> -<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> -<?php include("fbegin.inc"); ?> -<?php if ($input_errors) print_input_errors($input_errors); ?> -<?php if ($savemsg) print_info_box($savemsg); ?> -<form action="system_gateways_settings.php" method="post" name="iform" id="iform"> -<table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td> - <?php - $tab_array = array(); - $tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php"); - $tab_array[1] = array(gettext("Routes"), false, "system_routes.php"); - $tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php"); - $tab_array[3] = array(gettext("Settings"), true, "system_gateways_settings.php"); - display_top_tabs($tab_array); - ?> - </td> - </tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6"> - <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Latency thresholds");?></td> - <td width="78%" class="vtable"> - <?=gettext("From");?> - <input name="latencylow" type="text" class="formfld unknown" id="latencylow" size="2" - value="<?=htmlspecialchars($pconfig['latencylow']);?>"> - <?=gettext("To");?> - <input name="latencyhigh" type="text" class="formfld unknown" id="latencyhigh" size="2" - value="<?=htmlspecialchars($pconfig['latencyhigh']);?>"> - <br> <span class="vexpl"><?=gettext("These define the low and high water marks for latency in milliseconds.");?></span></td> - </td> - </tr> - <tr> - <td width="22%" valign="top" class="vncellreq"><?=gettext("Packet Loss thresholds");?></td> - <td width="78%" class="vtable"> - <?=gettext("From");?> - <input name="losslow" type="text" class="formfld unknown" id="losslow" size="2" - value="<?=htmlspecialchars($pconfig['losslow']);?>"> - <?=gettext("To");?> - <input name="losshigh" type="text" class="formfld unknown" id="losshigh" size="2" - value="<?=htmlspecialchars($pconfig['losshigh']);?>"> - <br> <span class="vexpl"><?=gettext("These define the low and high water marks for packet loss in %.");?></span></td> - </td> - </tr> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" onclick="enable_change(true)"> - </td> - </tr> - </table> - </div> - </td> - </tr> -</table> - -</form> -<?php include("fend.inc"); ?> -</body> -</html> diff --git a/usr/local/www/system_routes.php b/usr/local/www/system_routes.php index f6c55e6..df80023 100755 --- a/usr/local/www/system_routes.php +++ b/usr/local/www/system_routes.php @@ -129,7 +129,6 @@ include("head.inc"); $tab_array[0] = array(gettext("Gateways"), false, "system_gateways.php"); $tab_array[1] = array(gettext("Routes"), true, "system_routes.php"); $tab_array[2] = array(gettext("Groups"), false, "system_gateway_groups.php"); - $tab_array[3] = array(gettext("Settings"), false, "system_gateways_settings.php"); display_top_tabs($tab_array); ?> </td></tr> |