LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: [lvs-users] ldirectord SimpleTCP service check [PATCH]

To: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [lvs-users] ldirectord SimpleTCP service check [PATCH]
From: Aaron Linnen <aaron@xxxxxxxxxxxxxx>
Date: Fri, 30 Nov 2007 15:17:59 -0600
Simon Horman wrote:
On Thu, Nov 29, 2007 at 08:41:27AM -0600, Aaron Linnen wrote:
I have a service with a custom protocol that I'm load balancing and I didn't find an easy way to get that going with ldirectord. I came up with a quick modification that enabled what I needed, but would appreciate comments or, ideally including similar functionality in future releases.

It's a new service type called simpletcp, and is configured like so:
virtual = 192.168.44.3:10301
        protocol = tcp
        scheduler = wlc
        real = 192.168.45.4:10301 gate 100
        real = 192.168.45.5:10301 gate 100
        service = simpletcp
        request = "command\narg\n.\n"
        receive = "^\+OK"

The check simply sends the request string down the connection and tests against the receive regex. My perl-foo is weak these days, so I'm sure there are some easy improvements that could be made.

Hi Arron,

thanks for your patch. This idea looks like a good one to me and
I'm quite happy to push it into the next release (or the one after that,
as the next release is close to going out the door).

A few things:

* How well have you tested this? Its unlikely to break anything except
  itself, but its good to get an idea anyway.
* Can you add something to the documentation at the top of ldirectord?
  Perhaps doding this as a second patch would work well.
* Your patch seemed to replace all tabs with spaces so it didn't apply.
  I manually fixed this up and the fixed version is below.
* If at all possible could you provide a sign-off line as described
  in section 5 of http://linux.yyz.us/patch-format.html
  Thats basically to say this is your work and you are ok with
  it going into a GPL project.

Hi Horms, thanks for the interest.

We're only in development mode here right now, but it's stood up well under the testing we have done including some load testing. The code is pretty much just the check_sip code, with the request swapped out.

Patch attached with some tiny bits of documentation. Sorry about the previous patch. hopefully this one will come through correctly.

One area I see potential improvement is the \n handling - I can see the need for at least \r as well, probably others. I was looking for a quick way to have perl parse the line as it does string literals in code so that all the same perl escape syntax could be used (enabling embedded nulls or other binary data), but didn't see an easy way and I didn't need that for the current project so I left it. If someone knows a simple, safe and secure way to enable that, I think it would really improve this to where it can be used in as many circumstances as possible.

Signed-off-by: Aaron J. Linnen <aaron@xxxxxxxxxxxxxx>

Aaron

--- /usr/sbin/ldirectord        2007-08-10 06:15:50.000000000 -0600
+++ ldirectord  2007-11-30 15:12:35.000000000 -0600
@@ -327,11 +327,15 @@
 On means no checking will take place and real servers will always be
 activated. Default is I<negotiate>.
 
-B<service = 
>B<dns>|B<ftp>|B<http>|B<https>|B<imap>|B<imaps>|B<ldap>|B<mysql>|B<nntp>|B<none>|B<oracle>|B<pgsql>|B<pop>|B<pops>|B<radius>|B<sip>|B<smtp>
+B<service = 
>B<dns>|B<ftp>|B<http>|B<https>|B<imap>|B<imaps>|B<ldap>|B<mysql>|B<nntp>|B<none>|B<oracle>|B<pgsql>|B<pop>|B<pops>|B<radius>|B<simpletcp>|B<sip>|B<smtp>
 
 The type of service to monitor when using checktype=negotiate. None denotes
 a service that will not be monitored. 
 
+simpletcp sends the B<request> string to the server and tests it against
+the B<receive> regexp. The other types of checks connect to the server
+using the specified protocol. Please see the B<request> and B<receive>
+sections for protocol specific information.
 
 Default:
 
@@ -415,6 +419,9 @@
 The data returned is not checked, only that the
 answer is one or more rows.  This is a required setting.
 
+For a simpletcp check, this string is sent verbatim except any occurances
+of \n are replaced with a new line character.
+
 B<receive = ">I<regexp to compare>B<">
 
 If the requested result contains this I<regexp to compare>, the real server
@@ -1233,8 +1241,9 @@
                                                             "oracle, "      .
                                                             "pop, pops, "   .
                                                             "radius, "      .
-                                                            "pgsql, sip "   .
-                                                            "or smtp");
+                                                            "pgsql, "       .
+                                                            "simpletcp, "   .
+                                                            "sip or smtp");
                                        $vsrv{service} = $1;
                                        if($vsrv{service} eq "ftp" and 
                                                        $vsrv{login} eq "") {




<Prev in Thread] Current Thread [Next in Thread>