Re: Read stat or info from the socket via perl

From: Willy Tarreau <w#1wt.eu>
Date: Thu, 19 Feb 2009 23:01:04 +0100


Hi,

On Sat, Feb 14, 2009 at 10:53:11PM +0100, vmware vmware wrote:
> Hi all,
>
> I am trying to read the information (show info, show stat) from the socket
> of haproxy with a perl script in order to get a similar result when using
> the socat command. The problem is that I am not able to read something.
> I see also a similar example in the sources in the contrib folder, but
> somehow I don't get the point how to read and print this information.
>
> This is my perl program.
>
> Thanks for any help
>
> ###############################################
>
> use strict;
> use IO::Socket;
> use lib "/usr/local/nagios/libexec";
>
> my $sock = new IO::Socket::UNIX (
> LocalAddr => "/var/run/haproxy.socket",
> Type => SOCK_STREAM,
> Timeout => 1)
> or die 'error on connectin.';

Well, about 10 years have elapsed since I last wrote a perl line, but I find the name "LocalAddr" above suspect for a connection. How do you know from the code above that your program is trying to connect and is not setting up a listening socket instead ? That would explain your problem !

Perl still looks awfully obscure to me :-(

Willy Received on 2009/02/19 23:01

This archive was generated by hypermail 2.2.0 : 2009/02/20 00:15 CET