that's great !! many thx
oau
----- Mail d'origine -----
De: Henrik Størner <user-ce4a2c883f75@xymon.invalid>
À: xymon at xymon.com
Envoyé: Tue, 15 Nov 2011 15:19:59 +0100 (CET)
Objet: Re: [Xymon] Querying xymond with perl socket
I need to do a xymondboard directly with tcp. nc is working :
echo "hobbitdboard host=xxxxx test=ping" | nc xxx.xxx.xxx.xxx 1984
is working. But my perl code is not working :
#!/usr/bin/perl -w
use strict;
use IO::Socket;
$| = 1;
my $sock = new IO::Socket::INET (
PeerAddr => 'xxx.xxx.xxx.xxx',
PeerPort => '1984',
Proto => 'tcp',
) or warn "Cannot connect to xymon : $!\n";
print $sock "hobbitdboard host=xxxx test=ping\n";
my $answer =<$sock>;
print "$answer\n";
close ($sock);
You need to call the "shutdown" method before trying to read the data,
to tell xymond that you are not going to send any more data - only then
will the response come back from xymond. Something like "shutdown($sock,
1);" (1 = SHUT_WR according to my man-page).
Regards,
Henrik