From 87c4907f7fc19e7b29afd34f67553400fddd8fb4 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Wed, 24 Jan 2007 01:10:09 +0000 Subject: Use monitorip if available. --- packages/tinydns/tinydns.inc | 7 +++++-- packages/tinydns/tinydns_status.php | 32 ++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'packages/tinydns') diff --git a/packages/tinydns/tinydns.inc b/packages/tinydns/tinydns.inc index 18bf5c6c..76152040 100644 --- a/packages/tinydns/tinydns.inc +++ b/packages/tinydns/tinydns.inc @@ -232,13 +232,16 @@ function tinydns_setup_ping_items() { else $row['pingthreshold'] = ""; if($row['monitorip']) - fwrite($fd, $row['monitorip'] . "|" . $row['failoverip'] . "|3|/usr/local/pkg/tinydns_down.php|/usr/local/pkg/tinydns_up.php|{$pingthreshold}\n"); + fwrite($fd, ip . "|" . $row['monitorip'] . "|3|/usr/local/pkg/tinydns_down.php|/usr/local/pkg/tinydns_up.php|{$pingthreshold}\n"); else fwrite($fd, $ip . "|" . $row['failoverip'] . "|3|/usr/local/pkg/tinydns_down.php|/usr/local/pkg/tinydns_up.php|{$pingthreshold}\n"); } } if($domain['monitorip']) - fwrite($fd, $domain['monitorip'] . "|" . $row['failoverip'] . "|3|/usr/local/pkg/tinydns_down.php|/usr/local/pkg/tinydns_up.php|{$pingthreshold}\n"); + fwrite($fd, $ip . "|" . $row['monitorip'] . "|3|/usr/local/pkg/tinydns_down.php|/usr/local/pkg/tinydns_up.php|{$pingthreshold}\n"); + else + fwrite($fd, $ip . "|" . $row['failoverip'] . "|3|/usr/local/pkg/tinydns_down.php|/usr/local/pkg/tinydns_up.php|{$pingthreshold}\n"); + } fclose($fd); conf_mount_ro(); diff --git a/packages/tinydns/tinydns_status.php b/packages/tinydns/tinydns_status.php index 7bc5a441..49f07a10 100644 --- a/packages/tinydns/tinydns_status.php +++ b/packages/tinydns/tinydns_status.php @@ -84,7 +84,11 @@ foreach($config['installedpackages']['tinydnsdomains']['config'] as $ping) { continue; $ipaddress = $ping['ipaddress']; $hostname = $ping['hostname']; - $status = file_get_contents("/var/db/pingstatus/$ipaddress"); + $monitorip = $ping['monitorip']; + if(file_exists("/var/db/pingstatus/$monitorip")) + $status = file_get_contents("/var/db/pingstatus/$monitorip"); + else + $status = "N/A"; if(stristr($tinydns_data, "+{$hostname}:{$ipaddress}")) $inservice = "YES"; else @@ -97,7 +101,7 @@ foreach($config['installedpackages']['tinydnsdomains']['config'] as $ping) { if(stristr($status,"DOWN")) echo "DOWN"; else - echo $status; + echo "UP"; echo ""; echo ""; @@ -105,8 +109,10 @@ foreach($config['installedpackages']['tinydnsdomains']['config'] as $ping) { echo ""; echo ""; - if(file_exists("/var/db/pingmsstatus/$ipaddress")) - $msstatus = file_get_contents("/var/db/pingmsstatus/$ipaddress"); + if(!$monitorip) + $monitorip = $ipaddress; + if(file_exists("/var/db/pingmsstatus/$monitorip")) + $msstatus = file_get_contents("/var/db/pingmsstatus/$monitorip"); else $msstatus = "N/A"; echo $msstatus; @@ -115,13 +121,17 @@ foreach($config['installedpackages']['tinydnsdomains']['config'] as $ping) { foreach($ping['row'] as $row) { $ipaddress = $row['failoverip']; - $status = file_get_contents("/var/db/pingstatus/$ipaddress"); + $monitorip = $row['monitorip']; + if(file_exists("/var/db/pingstatus/$monitorip")) + $status = file_get_contents("/var/db/pingstatus/$monitorip"); + else + $status = "N/A"; echo ""; echo "          |->  "; echo $ipaddress; if($row['loadbalance']) echo " (LB)"; - if(stristr($tinydns_data, "+{$hostname}:{$row['failoverip']}")) + if(stristr($tinydns_data, "+{$hostname}:{$row['monitorip']}")) $inservice = "YES"; else $inservice = "NO"; @@ -130,7 +140,7 @@ foreach($config['installedpackages']['tinydnsdomains']['config'] as $ping) { if(stristr($status,"DOWN")) echo "DOWN"; else - echo $status; + echo "UP"; echo ""; echo ""; @@ -138,14 +148,16 @@ foreach($config['installedpackages']['tinydnsdomains']['config'] as $ping) { echo ""; echo ""; - if(file_exists("/var/db/pingmsstatus/$ipaddress")) - $msstatus = file_get_contents("/var/db/pingmsstatus/$ipaddress"); + if(!$monitorip) + $monitorip = $ipaddress; + if(file_exists("/var/db/pingmsstatus/$monitorip")) + $msstatus = file_get_contents("/var/db/pingmsstatus/$monitorip"); else $msstatus = "N/A"; + echo $msstatus; echo ""; echo ""; - } echo " "; } -- cgit v1.2.3