diff options
author | Phil Davis <phil.davis@world.inf.org> | 2012-07-25 21:50:49 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@world.inf.org> | 2012-07-25 21:50:49 +0545 |
commit | 14661668d3c73542ba9cff44ac0d9cc8c8b8669e (patch) | |
tree | f3ba882be6ad178d8bef6270d04289cec546c280 /etc/inc/gwlb.inc | |
parent | be27f33714ed7ade8296bb2d1678e10bee8429fa (diff) | |
download | pfsense-14661668d3c73542ba9cff44ac0d9cc8c8b8669e.zip pfsense-14661668d3c73542ba9cff44ac0d9cc8c8b8669e.tar.gz |
Put apinger default values into a function
The default advanced apinger parameter values are now returned by function return_apinger_defaults. So they can easily be obtained by any code that cares.
Diffstat (limited to 'etc/inc/gwlb.inc')
-rw-r--r-- | etc/inc/gwlb.inc | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index f064010..9023451 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -31,9 +31,20 @@ */ require_once("config.inc"); +/* Returns an array of default values used for apinger.conf */ +function return_apinger_defaults() { + return array( + "latencylow" => "200", + "latencyhigh" => "500", + "losslow" => "10", + "losshigh" => "20", + "interval" => "1", + "down" => "10"); + } + /* * Creates monitoring configuration file and - * adds apropriate static routes. + * adds appropriate static routes. */ function setup_gateways_monitor() { global $config, $g; @@ -46,13 +57,7 @@ function setup_gateways_monitor() { return; } - /* Default settings. Probably should move to globals.inc? */ - $a_settings = array(); - $a_settings['latencylow'] = "200"; - $a_settings['latencyhigh'] = "500"; - $a_settings['losslow'] = "10"; - $a_settings['losshigh'] = "20"; - + $apinger_default = return_apinger_defaults(); $fd = fopen("{$g['varetc_path']}/apinger.conf", "w"); $apingerconfig = <<<EOD @@ -72,7 +77,7 @@ pid_file "{$g['varrun_path']}/apinger.pid" #timestamp_format "%Y%m%d%H%M%S" status { - ## File where the status information whould be written to + ## File where the status information should be written to file "{$g['tmp_path']}/apinger.status" ## Interval between file updates ## when 0 or not set, file is written only when SIGUSR1 is received @@ -84,7 +89,7 @@ status { # Interval between RRD updates rrd interval 60s; -## These parameters can be overriden in a specific alarm configuration +## These parameters can be overridden in a specific alarm configuration alarm default { command on "/usr/local/sbin/pfSctl -c 'service reload dyndnsall' -c 'service reload ipsecdns' -c 'filter reload' -c 'service reload openvpn'" command off "/usr/local/sbin/pfSctl -c 'service reload dyndnsall' -c 'service reload ipsecdns' -c 'filter reload' -c 'service reload openvpn'" @@ -94,28 +99,28 @@ alarm default { ## "Down" alarm definition. ## This alarm will be fired when target doesn't respond for 30 seconds. alarm down "down" { - time 10s + time {$apinger_default['down']}s } ## "Delay" alarm definition. ## This alarm will be fired when responses are delayed more than 200ms ## it will be canceled, when the delay drops below 100ms alarm delay "delay" { - delay_low {$a_settings['latencylow']}ms - delay_high {$a_settings['latencyhigh']}ms + delay_low {$apinger_default['latencylow']}ms + delay_high {$apinger_default['latencyhigh']}ms } ## "Loss" alarm definition. ## This alarm will be fired when packet loss goes over 20% ## it will be canceled, when the loss drops below 10% alarm loss "loss" { - percent_low {$a_settings['losslow']} - percent_high {$a_settings['losshigh']} + percent_low {$apinger_default['losslow']} + percent_high {$apinger_default['losshigh']} } target default { ## How often the probe should be sent - interval 1s + interval {$apinger_default['interval']}s ## How many replies should be used to compute average delay ## for controlling "delay" alarms @@ -971,4 +976,4 @@ function validate_address_family($ipaddr, $gwname) { } -?> +?>
\ No newline at end of file |