| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Message::Passing::Input::Syslog; |
|
2
|
1
|
|
|
1
|
|
2778
|
use Moo; |
|
|
1
|
|
|
|
|
23469
|
|
|
|
1
|
|
|
|
|
8
|
|
|
3
|
1
|
|
|
1
|
|
2708
|
use MRO::Compat; |
|
|
1
|
|
|
|
|
1628
|
|
|
|
1
|
|
|
|
|
40
|
|
|
4
|
1
|
|
|
1
|
|
1259
|
use Time::ParseDate; |
|
|
1
|
|
|
|
|
14235
|
|
|
|
1
|
|
|
|
|
85
|
|
|
5
|
1
|
|
|
1
|
|
1063
|
use Socket qw( getnameinfo NI_NUMERICHOST NI_NUMERICSERV ); |
|
|
1
|
|
|
|
|
3766
|
|
|
|
1
|
|
|
|
|
241
|
|
|
6
|
1
|
|
|
1
|
|
957
|
use Parse::Syslog::Line qw( parse_syslog_line ); |
|
|
1
|
|
|
|
|
186777
|
|
|
|
1
|
|
|
|
|
92
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# for speed, we don't need the created DateTime object |
|
9
|
|
|
|
|
|
|
$Parse::Syslog::Line::DateTimeCreate = 0; |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
9
|
use namespace::clean -except => 'meta'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
10
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
extends 'Message::Passing::Input::Socket::UDP'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+port' => ( |
|
16
|
|
|
|
|
|
|
default => sub { 5140 }, |
|
17
|
|
|
|
|
|
|
required => 0, |
|
18
|
|
|
|
|
|
|
); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has protocol => ( |
|
21
|
|
|
|
|
|
|
is => 'ro', |
|
22
|
|
|
|
|
|
|
default => sub { 'udp' }, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub BUILD { |
|
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
27
|
0
|
0
|
|
|
|
|
die sprintf("Protocol '%s' is not supported, only 'udp' currently", $self->protocol) |
|
28
|
|
|
|
|
|
|
if $self->protocol ne 'udp'; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _send_data { |
|
32
|
0
|
|
|
0
|
|
|
my ( $self, $message, $from ) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my $msg = parse_syslog_line( $message ); |
|
35
|
0
|
0
|
|
|
|
|
my $time = defined $msg->{datetime_raw} ? parsedate($msg->{datetime_raw}) : undef; |
|
36
|
0
|
|
0
|
|
|
|
$msg->{epochtime} = $time || time(); |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my ( $err, $ipaddr, $port ) = getnameinfo( $from, NI_NUMERICHOST, NI_NUMERICSERV ); |
|
39
|
0
|
0
|
|
|
|
|
$msg->{received_from} = $ipaddr |
|
40
|
|
|
|
|
|
|
unless $err; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$self->output_to->consume( $msg ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Message::Passing::Input::Syslog - input messages from Syslog. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
message-pass --input Syslog --input_options '{"port":"5140"}' --output STDOUT |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Provides a syslog server for UDP syslog. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Can be used to ship syslog logs into a L system. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The message format is a hashref containing all keys returned from |
|
62
|
|
|
|
|
|
|
L plus received_from. |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 hostname |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The IP to bind the daemon to. By default, binds to 127.0.0.1, which |
|
69
|
|
|
|
|
|
|
means that the server can only be accessed from localhost. Use C<0.0.0.0> |
|
70
|
|
|
|
|
|
|
to bind to all interfaces. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 port |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The port to bind to, defaults to 5140, as the default syslog port (514) |
|
75
|
|
|
|
|
|
|
is likely already taken by your regular syslogd, and needs root permissio |
|
76
|
|
|
|
|
|
|
to bind to it. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 protocol |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The protocol to listen on, currently only UDP is supported. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=over |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item L |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item L |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
See L. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |