Project

General

Profile

« Previous | Next » 

Revision ae9618af

Added by Ermal LUÇI about 15 years ago

Return the gateway status only for gateways apinger knows about instead of assuming that all gateways are down, which might give consecuences. Also prepend 'filter_' to the function used to kill states for down gateways in filter.inc to be consistent.

View differences:

etc/inc/filter.inc
140 140
	touch($g['tmp_path'] . "/filter_dirty");
141 141
}
142 142

  
143
function delete_states_for_down_gateways() {
143
function filter_delete_states_for_down_gateways() {
144 144
	global $config;
145

  
145 146
	$a_gateways = return_gateways_status();
146 147
	foreach ($a_gateways as $gateway) {
147 148
		if ($gateway['status'] == "down") {
......
369 370
		echo ".";
370 371

  
371 372
	update_filter_reload_status("Processing down interface states");
372
	delete_states_for_down_gateways();
373
	filter_delete_states_for_down_gateways();
373 374

  
374 375
	update_filter_reload_status("Running plugins");
375 376

  
etc/inc/gwlb.inc
243 243

  
244 244
/* return the status of the apinger targets as a array */
245 245
function return_gateways_status() {
246
	global $config;
247
	global $g;
248
	$gateways_arr = return_gateways_array();
246
	global $config, $g;
249 247

  
250 248
	$apingerstatus = array();
251 249
	if (file_exists("{$g['tmp_path']}/apinger.status")) {
......
253 251
	}
254 252

  
255 253
	$status = array();
256
	$i = 2;
257
	/* assign a dummy IP address for dynamic interfaces in case we need it */
258
	$monitor = array();
259
	foreach($gateways_arr as $name => $gateway) {
260
		if($gateway['monitor'] == "dynamic") {
261
			$gateway['monitor'] = "127.0.0.{$i}";
262
			$i++;
263
		}
264
		$status[$gateway['monitor']]['monitor'] = $gateway['monitor'];
265
		$status[$gateway['monitor']]['interface'] = $gateway['interface'];
266
		$status[$gateway['monitor']]['gateway'] = $gateway['gateway'];
267
		$status[$gateway['monitor']]['name'] = $gateway['name'];
268
		$status[$gateway['monitor']]['status'] = "down";
269

  
270
	}
271 254
	foreach($apingerstatus as $line) {
272 255
		$info = explode("|", $line);
273 256
		$target = $info[0];

Also available in: Unified diff