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 to read out the information in a similar manner as the
command "socat" is doing, like:
echo "show stat" | /usr/local/bin/socat /var/lib/haproxy-stat stdio

The problem is when I am accessing to the socket for reading some
information, nothing is printed out into stdout. I also found under the
source folder of haproxy a similar perl script what uses nmtp. I do not
believe that I need nmtp for my purpose, isn't it? Does somebody has any
idea, what I am doing wrong?

Thanks for any help

regards Maria

P.S below there is my perl script.


############### 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