"" and $vsent['sitedown'] <> "") { /* fallback IP */ $slbdconf .= "\t:sitedown={$vsent['sitedown']}:\\\n"; /* fallback port */ $slbdconf .= "\t:sitedown-port={$vsent['port']}:\\\n"; } for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) { if ($config['load_balancer']['lbpool'][$i]['name'] == $vsent['pool']) { $svrcnt = 0; $svrtxt = ""; $svrtxt = "\t:service-port={$config['load_balancer']['lbpool'][$i]['port']}:\\\n"; foreach ($config['load_balancer']['lbpool'][$i]['servers'] as $lbsvr) { $svrtxt .= "\t:{$svrcnt}={$lbsvr}:\\\n"; $svrcnt++; } $slbdconf .= "\t:method=round-robin:\\\n"; $slbdconf .= "\t:services={$svrcnt}:\\\n"; $slbdconf .= $svrtxt; } } $slbdconf .= "\t:tcppoll:send=:expect=:\n"; $should_start=1; } } /* Gateway Pools */ if(is_array($a_pool)) { foreach ($a_pool as $vspool) { if ($vspool['type'] != "gateway") continue; if ($vspool['desc'] == "") $slbdconf .= "{$vspool['name']}:\\\n"; else $slbdconf .= "{$vspool['name']}|{$vspool['desc']}:\\\n"; /* pool name */ $slbdconf .= "\t:poolname={$vspool['name']}:\\\n"; /* virtual IP */ $slbdconf .= "\t:vip=127.0.0.1:\\\n"; $slbdconf .= "\t:vip-port=666:\\\n"; /* fallback IP */ $slbdconf .= "\t:sitedown=127.0.0.1:\\\n"; /* fallback port */ $slbdconf .= "\t:sitedown-port=666:\\\n"; $svrcnt = 0; $svrtxt = ""; foreach ($vspool['servers'] as $lbsvr) { $lbsvr_split=split("\|", $lbsvr); $svrtxt .= "\t:{$svrcnt}={$lbsvr_split[1]}:\\\n"; $svrcnt++; /* Add static routes to the monitor IPs */ $next_hop = exec_command("/sbin/route -n get {$lbsvr_split[1]} | /usr/bin/grep gateway |/usr/bin/awk '{ print \$2; };'"); if ($next_hop != $lbsvr_split[0]) { mwexec("/sbin/route delete -host {$lbsvr_split[1]} 1>/dev/null 2>&1"); mwexec("/sbin/route add -host {$lbsvr_split[1]} {$lbsvr_split[0]} 1> /dev/null 2>&1"); } } $slbdconf .= "\t:service-port=666:\\\n"; $slbdconf .= "\t:method=round-robin:\\\n"; $slbdconf .= "\t:services={$svrcnt}:\\\n"; $slbdconf .= $svrtxt; $slbdconf .= "\t:ping:\n"; $should_start=1; } } if($should_start == 1) { fwrite($fd, $slbdconf); fclose($fd); mwexec("/usr/bin/killall -9 slbd"); /* startup slbd pointing it's config at /var/etc/slbd.conf with a polling interval of 5 seconds */ mwexec("/usr/local/sbin/slbd -c{$g['varetc_path']}/slbd.conf -r5000"); } else { mwexec("/usr/bin/killall -9 slbd"); fclose($fd); } } ?>