Revision 14661668
Added by Phil Davis almost 13 years ago
etc/inc/gwlb.inc | ||
---|---|---|
31 | 31 |
*/ |
32 | 32 |
require_once("config.inc"); |
33 | 33 |
|
34 |
/* Returns an array of default values used for apinger.conf */ |
|
35 |
function return_apinger_defaults() { |
|
36 |
return array( |
|
37 |
"latencylow" => "200", |
|
38 |
"latencyhigh" => "500", |
|
39 |
"losslow" => "10", |
|
40 |
"losshigh" => "20", |
|
41 |
"interval" => "1", |
|
42 |
"down" => "10"); |
|
43 |
} |
|
44 |
|
|
34 | 45 |
/* |
35 | 46 |
* Creates monitoring configuration file and |
36 |
* adds apropriate static routes. |
|
47 |
* adds appropriate static routes.
|
|
37 | 48 |
*/ |
38 | 49 |
function setup_gateways_monitor() { |
39 | 50 |
global $config, $g; |
... | ... | |
46 | 57 |
return; |
47 | 58 |
} |
48 | 59 |
|
49 |
/* Default settings. Probably should move to globals.inc? */ |
|
50 |
$a_settings = array(); |
|
51 |
$a_settings['latencylow'] = "200"; |
|
52 |
$a_settings['latencyhigh'] = "500"; |
|
53 |
$a_settings['losslow'] = "10"; |
|
54 |
$a_settings['losshigh'] = "20"; |
|
55 |
|
|
60 |
$apinger_default = return_apinger_defaults(); |
|
56 | 61 |
$fd = fopen("{$g['varetc_path']}/apinger.conf", "w"); |
57 | 62 |
$apingerconfig = <<<EOD |
58 | 63 |
|
... | ... | |
72 | 77 |
#timestamp_format "%Y%m%d%H%M%S" |
73 | 78 |
|
74 | 79 |
status { |
75 |
## File where the status information whould be written to
|
|
80 |
## File where the status information should be written to
|
|
76 | 81 |
file "{$g['tmp_path']}/apinger.status" |
77 | 82 |
## Interval between file updates |
78 | 83 |
## when 0 or not set, file is written only when SIGUSR1 is received |
... | ... | |
84 | 89 |
# Interval between RRD updates |
85 | 90 |
rrd interval 60s; |
86 | 91 |
|
87 |
## These parameters can be overriden in a specific alarm configuration |
|
92 |
## These parameters can be overridden in a specific alarm configuration
|
|
88 | 93 |
alarm default { |
89 | 94 |
command on "/usr/local/sbin/pfSctl -c 'service reload dyndnsall' -c 'service reload ipsecdns' -c 'filter reload' -c 'service reload openvpn'" |
90 | 95 |
command off "/usr/local/sbin/pfSctl -c 'service reload dyndnsall' -c 'service reload ipsecdns' -c 'filter reload' -c 'service reload openvpn'" |
... | ... | |
94 | 99 |
## "Down" alarm definition. |
95 | 100 |
## This alarm will be fired when target doesn't respond for 30 seconds. |
96 | 101 |
alarm down "down" { |
97 |
time 10s
|
|
102 |
time {$apinger_default['down']}s
|
|
98 | 103 |
} |
99 | 104 |
|
100 | 105 |
## "Delay" alarm definition. |
101 | 106 |
## This alarm will be fired when responses are delayed more than 200ms |
102 | 107 |
## it will be canceled, when the delay drops below 100ms |
103 | 108 |
alarm delay "delay" { |
104 |
delay_low {$a_settings['latencylow']}ms
|
|
105 |
delay_high {$a_settings['latencyhigh']}ms
|
|
109 |
delay_low {$apinger_default['latencylow']}ms
|
|
110 |
delay_high {$apinger_default['latencyhigh']}ms
|
|
106 | 111 |
} |
107 | 112 |
|
108 | 113 |
## "Loss" alarm definition. |
109 | 114 |
## This alarm will be fired when packet loss goes over 20% |
110 | 115 |
## it will be canceled, when the loss drops below 10% |
111 | 116 |
alarm loss "loss" { |
112 |
percent_low {$a_settings['losslow']}
|
|
113 |
percent_high {$a_settings['losshigh']}
|
|
117 |
percent_low {$apinger_default['losslow']}
|
|
118 |
percent_high {$apinger_default['losshigh']}
|
|
114 | 119 |
} |
115 | 120 |
|
116 | 121 |
target default { |
117 | 122 |
## How often the probe should be sent |
118 |
interval 1s
|
|
123 |
interval {$apinger_default['interval']}s
|
|
119 | 124 |
|
120 | 125 |
## How many replies should be used to compute average delay |
121 | 126 |
## for controlling "delay" alarms |
... | ... | |
971 | 976 |
} |
972 | 977 |
|
973 | 978 |
|
974 |
?> |
|
979 |
?> |
Also available in: Unified diff
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.