LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: ldirectord patch

To: "jarol1@xxxxxxxxx" <J.Libak@xxxxxxxxxx>
Subject: Re: ldirectord patch
Cc: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
From: Horms <horms@xxxxxxxxxxxx>
Date: Fri, 9 Feb 2007 11:24:20 +0900
On Fri, Jan 12, 2007 at 03:14:38PM +0100, jarol1@xxxxxxxxx wrote:
> Graeme Fowler wrote:
> >On 12/01/2007 09:59, Jaroslav Libák wrote:
> >>Last time attachment wasnt sent for some reason.
> >
> >The list MLM strips attachments. Best to either put it in the body of the 
> >message or, if it's a biggun, put it somewhere accessible and send the URL.
> >
> >Graeme
> >_______________________________________________
> >LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
> >Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
> >or go to http://www.in-addr.de/mailman/listinfo/lvs-users
> >
> Here it is:

Hi,

sorry for the delay in getting back to you.
This has been in my INBOX for a while now :(

This seems pretty fine to me. The one thing that you could do to make
my life easier is to provide a sign-off-line, as described at the link
below. Basically its a way of you saying, I wrote this code, and
its ok for it to be included in GPL code. Its primary purpose
is so that if someone else claims they own the code there is
a way of tracking where it came from.

See section 5 of http://linux.yyz.us/patch-format.html

> diff -ru original/ldirectord patchedldirector/ldirectord
> --- original/ldirectord    2006-11-03 01:24:56.000000000 +0100
> +++ patchedldirector/ldirectord    2007-01-12 10:35:59.000000000 +0100

The patch should really be against ldirectord.in. You can get
the lastest from:

http://hg.linux-ha.org/dev/raw-file/466b5d495b37/ldirectord/ldirectord.in

> @@ -248,7 +248,7 @@
> also appear inside a virtual section, in which case the global setting is
> overridden.
> -B<checktype = >I<negotiate>|I<connect>|I<N>|I<ping>|I<off>|I<on>
> +B<checktype = >I<negotiate>|I<connect>|I<N>|I<ping>|I<off>|I<on>|I<external>
> Type of check to perform. Negotiate sends a request and matches a receive
> string. Connect only attemts to make a TCP/IP connection, thus the
> @@ -271,6 +271,14 @@
> B<imap>, <B<imaps>, B<ldap>, B<https>, B<mysql>, B<pgsql> or B<sip> 
> respectivly.
> Otherwise the default service is B<none>.
> +B<externalpath = ">I<path to script>B<">
> +
> +This setting is taken into account if checktype is external - by external
> +script. Enter path of the script into double quotes. Script should return
> +0 if everything is ok, or something else if it isn't. 4 parameters are passed
> +to the script - virtual server ip/firewall mark, virtual server port,
> +real server ip, real server port

This setting is used if the checktype is external. It should
be set to the path of the script to run, enclosed in double quotes.
The script should exit with status 0 if everything is ok, and non-zero
otherwise. Four parameters are passed to the script:

=over 4

=item * The virtual server ip or firewall mark. 

=item * The virtual server port, zero in the case of a firewall mark.

=item * The real server IP.

=item * The real server port.

=back 4

> +
> B<checkport = >I<n>
> Number of port to monitor. Sometimes check port differs from service port.
> @@ -816,6 +824,7 @@
>             }
>             $vsrv{real} = \@rsrv;
>             $vsrv{scheduler} = "wrr";
> +            $vsrv{externalpath} = "/bin/true";
>             $vsrv{request} = "/";
>             $vsrv{receive} = "";
>             $vsrv{login} = "";
> @@ -856,11 +865,14 @@
>                     if ($1 =~ /(\d+)/ && $1>=0) {
>                         $vsrv{num_connects} = $1;
>                         $vsrv{checktype} = "combined";
> -                    } elsif ( $1 =~ /(\w+)/ && ($1 eq "connect" || $1 eq 
> "negotiate" || $1 eq "ping" || $1 eq "off" || $1 eq "on") ) {
> +                    } elsif ( $1 =~ /(\w+)/ && ($1 eq "connect" || $1 eq 
> "negotiate" || $1 eq "ping" || $1 eq "off" || $1 eq "on" || $1 eq "external") 
> ) 
> {
>                         $vsrv{checktype} = $1;
>                     } else {
> -                        &config_error($line, "checktype must be connect, 
> negotiate, ping, off, on or a positive number");
> +                        &config_error($line, "checktype must be connect, 
> negotiate, ping, off, on, external or a positive number");
>                     }
> +                } elsif ($rcmd =~ /^externalpath\s*=\s*(.*)/){
> +                                        $1 =~ /(.+)/ or &config_error($line, 
> "invalid external script");
> +                                        $vsrv{externalpath} = $1;
>                 } elsif ($rcmd =~ /^checktimeout\s*=\s*(.*)/){
>                                         $1 =~ /(\d+)/ && $1 or 
> &config_error($line, "invalid check timeout");
>                                         $vsrv{checktimeout} = $1;
> @@ -1836,6 +1848,9 @@
>                 } elsif ($$v{checktype} eq "ping") {
>                     &ld_debug(2, "Checking ping: real server=$real_id 
> (virtual=$virtual_id)");
>                     check_ping($v, $r);
> +                } elsif ($$v{checktype} eq "external") {
> +                    &ld_debug(2, "Checking external: real server=$real_id 
> (virtual=$virtual_id)");
> +                    check_external($v, $r);
>                 } elsif ($$v{checktype} eq "off") {
>                     &ld_debug(2, "Checking off: No real or fallback servers 
> to 
> be added\n");
>                 } elsif ($$v{checktype} eq "on") {
> @@ -2256,6 +2271,37 @@
>     }
> }
> +sub check_external
> +{
> +    my ($v, $r) = @_;
> +    my $result;
> +    my $v_server;
> +
> +    eval {
> +        local $SIG{'__DIE__'} = "DEFAULT";
> +        local $SIG{'ALRM'} = sub { die "Timeout Alarm" };
> +        &ld_debug(4, "Timeout is $$v{checktimeout}");
> +        alarm $$v{checktimeout};
> +        if (defined $$v{server}) {
> +            $v_server = $$v{server};
> +        } else {
> +            $v_server = $$v{fwm};
> +        }
> +        $result = system("$$v{externalpath} $v_server $$v{port} $$r{server} 
> $$r{port}");

I know that the code is somewhat inconsistent, but if you could
make the code in check_external() <= 80 characters wide, that would be
great.

> +        alarm 0;
> +        $result >>= 8;
> +    };
> +    if ($@ or $result != 0) {
> +        &service_set($v, $r, "down");
> +        &ld_debug(3, "Deactivated service $$r{server}:$$r{port}: $@ after 
> calling $$v{externalpath} with result $result");
> +        return 0;
> +    } else {
> +        &service_set($v, $r, "up");
> +        &ld_debug(3, "Activated service $$r{server}:$$r{port}");
> +        return 1;
> +    }
> +}
> +
> sub check_sip
> {
> 
> _______________________________________________
> LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
> Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
> or go to http://www.in-addr.de/mailman/listinfo/lvs-users

-- 
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/


<Prev in Thread] Current Thread [Next in Thread>
  • Re: ldirectord patch, Horms <=