Hi once again,

Sorry for my previous weired posting. Now I formulated my code cleaner.
My question was:

I am trying to read the information logged from haproxy (e.g. show info,
show stat) from the socket using perl.
My intention is read out the information in a similar manner as the command
so

 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

############### begin ###################

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.';

next if !$sock;

print $sock "show info\n";
# here i would like to read out the information from the socket
while(<$sock>){
        chomp;
        print;
}
$sock->close;

############### end #########################

Reply via email to