11 |
use IO::Socket::INET; |
use IO::Socket::INET; |
12 |
|
|
13 |
my $meteor_server = '192.168.1.13:4671'; |
my $meteor_server = '192.168.1.13:4671'; |
14 |
|
my $meteor_fh; |
|
my $meteor = IO::Socket::INET->new( $meteor_server ) |
|
|
|| die "can't connect to meteor $meteor_server: $!"; |
|
15 |
|
|
16 |
sub meteor { |
sub meteor { |
17 |
my @a = @_; |
my @a = @_; |
18 |
push @a, scalar localtime() if $a[0] =~ m{^info}; |
push @a, scalar localtime() if $a[0] =~ m{^info}; |
19 |
|
|
20 |
|
if ( ! defined $meteor_fh ) { |
21 |
|
warn "# open connection to $meteor_server"; |
22 |
|
$meteor_fh = IO::Socket::INET->new( |
23 |
|
PeerAddr => $meteor_server, |
24 |
|
Timeout => 1, |
25 |
|
) || warn "can't connect to meteor $meteor_server: $!"; # FIXME warn => die for production |
26 |
|
$meteor_fh = 0; # don't try again |
27 |
|
} |
28 |
|
|
29 |
warn ">> meteor ",dump( @a ); |
warn ">> meteor ",dump( @a ); |
30 |
print $meteor "ADDMESSAGE test ",join('|',@a),"\n"; |
print $meteor_fh "ADDMESSAGE test ",join('|',@a),"\n" if $meteor_fh; |
31 |
} |
} |
32 |
|
|
33 |
my $debug = 0; |
my $debug = 0; |
59 |
'parity=s' => \$parity, |
'parity=s' => \$parity, |
60 |
'stopbits=i' => \$stopbits, |
'stopbits=i' => \$stopbits, |
61 |
'handshake=s' => \$handshake, |
'handshake=s' => \$handshake, |
62 |
|
'meteor=s' => \$meteor_server, |
63 |
) or die $!; |
) or die $!; |
64 |
|
|
65 |
my $verbose = $debug > 0 ? $debug-- : 0; |
my $verbose = $debug > 0 ? $debug-- : 0; |