Hi folks,

   We have a LVS server it's a MTA cluster where is using a dummy
interface for transport VS <-> RS . So our policy is each server has 2
NICs, one is for internet access and other one is to for internal
network. The realserver didn't bind the external IP, just a aliases IP
in dummy interface equal the Virtual Server than the ldirectord think
the realserver is down.

I made this patch for the ldirectord add the rule in IPVS, but
monitoring another ip, in my case, monitor a internal ip. 

suggestions and bugs is welcome. :)

--
Aslan Carlos de M. Ramos
Network Administrator
Digirati Telecom, K8 Networks, Hostnet Web Hosting
Phone : +55(21) 2233-5950 Tie-line: 29
Mobile: +55(21) 7891-2292 / 81*74623
Skype : aslancarlos
--- /tmp/ldirectord	2007-07-19 09:46:06.740045558 -0300
+++ /etc/ha.d/resource.d/ldirectord	2007-07-19 09:47:25.193134240 -0300
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-my($VERSION)=(qw$Id: ldirectord,v 1.143 2006/08/08 15:57:09 lars Exp $)[2];
+my($VERSION)=(qw$Id: ldirectord,v 1.152 2007/07/02 14:26:09 aslan Exp $)[2];
 
 ######################################################################
 # ldirectord                 http://www.vergenet.net/linux/ldirectord/
@@ -209,7 +209,7 @@
 The following commands must follow a B<virtual> entry and must be indented
 with a minimum of 4 spaces or one tab.
 
-B<real => I<ip_address|hostname[-E<gt>ip_address|hostname][:portnumber|servicename>] B<gate>|B<masq>|B<ipip> [I<weight>] [B<">I<request>B<", ">I<receive>B<">]
+B<real => I<ip_address|hostname[-E<gt>ip_address|hostname][:portnumber|servicename>] B<MonitoredIP> B<gate>|B<masq>|B<ipip> [I<weight>] [B<">I<request>B<", ">I<receive>B<">]
 
 Defines a real service by IP-address (or hostname) and port (or
 servicename). If the port is omitted then a 0 will be used, this is
@@ -1208,33 +1208,55 @@
 	my $line;
 	my $ip1;
 	my $ip2;
+	my $ip_monitor;
 	my $port;
 	my $resolved_ip1;
 	my $resolved_ip2;
+	my $resolved_ip_monitor;
 	my $resolved_port;
 	my $flags;
 
 	for $i (@$rsrv_todo) {
 		($str, $line)[EMAIL PROTECTED];
-		$str =~	 /(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+)(->(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+))?(:(\d+|[A-Za-z0-9-]+))?\s+(.*)/
+		$str =~	 /(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+)(->(\d+\.\d+\.\d+\.\d+|[A-Za-z0-9.-]+))?(:(\d+|[A-Za-z0-9-]+))?\s+?(\d+\.\d+\.\d+\.\d+)?(.*)/
 			or &config_error($line, 
 				"invalid address for real server" .
                                 " (wrong format)");
 		$ip1=$1;
 		$ip2=$3;
+		
+		if(defined($7) and defined($6) ){
+		   $ip_monitor = $6;
+		   $flags=$7;
+		}
+		else {
+		   $ip_monitor = $1;
+		   $flags=$7;
+		}
+
                 if(defined($5)){
 		   $port=$5;
                 }
                 else {
                    $port="0";
                 }
-		$flags=$6;
 		$resolved_ip1=&ld_gethostbyname($ip1);
                 unless( defined($resolved_ip1) ) {
 			&config_error($line, 
                                 "invalid address ($ip1) for real server" .
                                 " (could not resolve host)");
                 }
+
+		if ( defined ($ip_monitor) ) {
+			$resolved_ip_monitor=&ld_gethostbyname($ip_monitor);
+                        unless( defined ($resolved_ip_monitor) ) {
+				&config_error($line, 
+                                        "invalid address ($ip_monitor) for " .
+					"real server" .
+                                        " (could not resolve end host)");
+                        }
+		}
+
 		if( defined($port) ){
 			$resolved_port=&ld_getservbyname($port);
                         unless( defined($resolved_port) ){
@@ -1252,10 +1274,10 @@
                                         " (could not resolve end host)");
                         }
 			&add_real_server_range($line, $vsrv, $resolved_ip1, 
-				$resolved_ip2, $resolved_port, $flags);
+				$resolved_ip2, $resolved_port, $resolved_ip_monitor,$flags);
 		} else {
 			&add_real_server($line, $vsrv, $resolved_ip1, 
-				$resolved_port, $flags);
+				$resolved_port, $resolved_ip_monitor, $flags);
 		}
 	}
 }
@@ -1278,7 +1300,7 @@
 
 sub add_real_server_range
 {
-	my ($line, $vsrv, $first, $last, $port, $flags) = (@_);
+	my ($line, $vsrv, $first, $last, $port, $ip_monitor ,$flags) = (@_);
 
         my (@tmp, $first_i, $last_i, $i, $rsrv);
 
@@ -1320,14 +1342,14 @@
 
 sub add_real_server
 {
-	my ($line, $vsrv, $ip, $port, $flags) = (@_);
+	my ($line, $vsrv, $ip, $port, $ip_monitor ,$flags) = (@_);
 
 	my $ref;
 	my $realsrv=0;
 	my $new_rsrv;
 	my $rsrv;
 
-	$new_rsrv = {"server"=>$ip, "port"=>$port};
+	$new_rsrv = {"server"=>$ip, "port"=>$port, "monitor"=>$ip_monitor};
 
 	$flags =~ /(\w+)(.*)/ && ($1 eq "gate" || $1 eq "masq" || $1 eq "ipip")
 	    or &config_error($line, 
@@ -1898,12 +1920,18 @@
 {
 	require Net::SMTP;
 	my ($v, $r) = @_;
+	my $smtp;
 	my $port=(defined $$v{checkport}?$$v{checkport}:$$r{port});
 	
-	&ld_debug(2, "Checking http: server=$$r{server} port=$port");
+	&ld_debug(2, "Checking smtp: server=$$r{server} port=$port");
 	
-	my $smtp = new Net::SMTP($$r{server}, Port => $port,
-			Timeout => $$v{negotiatetimeout});
+	if ( $$r{server} eq $$r{monitor} ) {
+	 $smtp = new Net::SMTP($$r{server},Timeout => $$v{negotiatetimeout});
+        }
+	else {
+	 $smtp = new Net::SMTP($$r{monitor},Timeout => $$v{negotiatetimeout});
+	}
+  
 	if ($smtp) {
 		$smtp->quit;
 		service_set($v, $r, "up");
@@ -3057,7 +3085,7 @@
 # ld_emailalert_resend
 # Resend email alerts as neccessary
 # pre: none
-# post: EMAILSTATUS array is updated and alears are sent as neccessary
+# post: EAILSTATUS array is updated and alears are sent as neccessary
 # return: none
 sub ld_emailalert_resend
 {
@@ -3315,6 +3343,14 @@
 	my $virtualhost = "";
 	my $check;
 	my $real;
+	my $monitor;
+
+	if(defined($r->{"monitor"})) {
+		$monitor = $r->{"monitor"};
+	}
+	else {
+		$monitor = $v->{"monitor"};
+	}
 
 	if(defined($r->{"request"})) {
 		$request = $r->{"request"};
@@ -3346,8 +3382,9 @@
 		$virtualhost = $v->{"virtualhost"};
 	}
 
+
         $real    = $check . ":" . $v->{"protocol"} . ":" 
-	         . $r->{"server"} . ":" . $r->{"port"} . ":" 
+	         . $r->{"server"} . ":" . $r->{"port"} . ":" . $monitor . ":"
 		 . $virtualhost . ":" . $checkport . ":" 
 		 . $r->{"weight"} . ":"
 		 . quotemeta($request) . ":" . quotemeta($receive);
_______________________________________________
LinuxVirtualServer.org mailing list - [email protected]
Send requests to [EMAIL PROTECTED]
or go to http://lists.graemef.net/mailman/listinfo/lvs-users

Reply via email to