Re: [lvs-users] Checking SSH with ldirectord.-

To: " users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [lvs-users] Checking SSH with ldirectord.-
From: Graeme Fowler <graeme@xxxxxxxxxxx>
Date: Thu, 27 Nov 2008 10:35:03 +0000
Hi Ariel

On Tue, 2008-11-25 at 11:57 -0200, Ariel Liguori wrote:
> Hi friends, i've attached a new functionality to my ldirectord, the
> capability of test if an SSH port is listening and based on that redirect
> the trafic or not.
> Basically i create a new sub called check_ssh, look up the code and feel
> free to correct me if something is worng :)

Correct me if I'm wrong :) but this looks almost exactly like the
existing "connect" check type in ldirectord:

sub check_connect
        my ($v, $r) = @_;
        my $port = ld_checkport($v, $r);

        eval {
                local $SIG{'__DIE__'} = "DEFAULT";
                local $SIG{'ALRM'} = sub { die "Timeout Alarm" };
                &ld_debug(4, "Timeout is $$v{checktimeout}");
                alarm $$v{checktimeout};
                my $sock = &ld_open_socket($$r{server}, $port,
                if ($sock) {
                } else {
                        alarm 0; # Cancel the alarm
                        die("Socket Connect Failed");
                &ld_debug(3, "Connected to $$r{server} (port $port)");
                alarm 0; # Cancel the alarm
        if ($@) {
                &service_set($v, $r, "down");
                &ld_debug(3, "Deactivated service $$r{server}:$$r{port}:
                return $SERVICE_DOWN;
        } else {
                &service_set($v, $r, "up");
                &ld_debug(3, "Activated service $$r{server}:$$r{port}");
                return $SERVICE_UP;

in that it opens a socket to the listening server and confirms that the
three-way handshake is successful, then closes the connection.

It looks to me like you've reinvented the wheel here.


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