Created
April 27, 2013 06:57
-
-
Save vmadman/5472159 to your computer and use it in GitHub Desktop.
A PERL UDP client. This client serves (in my usage) as a pipe target for apache logs. After reception, logs are forwarded to logstash. I found this at: http://untergeek.com/2012/10/11/getting-apache-to-output-json-for-logstash/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
#udpclient.pl | |
use IO::Socket::INET; | |
my $host = $ARGV[0]; | |
my $port = $ARGV[1]; | |
# flush after every write | |
$| = 1; | |
my ($socket,$logdata); | |
# We call IO::Socket::INET->new() to create the UDP Socket | |
# and bind with the PeerAddr. | |
$socket = new IO::Socket::INET ( | |
PeerAddr => "$host:$port", | |
Proto => 'udp' | |
) or die "ERROR in Socket Creation : $!\n"; | |
while ($logdata = <STDIN>) { | |
$socket->send($logdata); | |
} | |
$socket->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment