line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Saftpresse::Plugin::SyslogFile; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
843
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: plugin to parse syslog logfile format |
6
|
|
|
|
|
|
|
our $VERSION = '1.5'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends 'Log::Saftpresse::Plugin'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
3887
|
use Time::Piece; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub process { |
13
|
0
|
|
|
0
|
1
|
|
my ( $self, $stash ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
0
|
|
|
|
|
if( my ( $date_str, $msg ) = $stash->{'message'} =~ |
16
|
|
|
|
|
|
|
/^(... {1,2}\d{1,2} \d{2}:\d{2}:\d{2}) (.+)$/) { |
17
|
0
|
|
|
|
|
|
my $time = Time::Piece->strptime($date_str, "%b %e %H:%M:%S"); |
18
|
0
|
|
|
|
|
|
my $now = Time::Piece->new; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# guess year |
21
|
0
|
0
|
|
|
|
|
if( $time->mon > $now->mon ) { |
22
|
|
|
|
|
|
|
# Time::Piece->year is ro :-/ |
23
|
0
|
|
|
|
|
|
$time->[5] = $now->[5] - 1; |
24
|
|
|
|
|
|
|
} else { |
25
|
0
|
|
|
|
|
|
$time->[5] = $now->[5]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$stash->{'time'} = $time; |
29
|
0
|
|
|
|
|
|
$stash->{'message'} = $msg; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if( my ( $date_str, $msg ) = $stash->{'message'} =~ |
33
|
|
|
|
|
|
|
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d+)?(?:[\+\-](?:\d{2}):(?:\d{2})|Z) (.+)$/) { |
34
|
0
|
|
|
|
|
|
$stash->{'time'} = Time::Piece->strptime($date_str, "%Y-%m-%dT%H:%M:%S%z"); |
35
|
0
|
|
|
|
|
|
$stash->{'message'} = $msg; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
0
|
|
|
|
|
if( my ( $host, $program, $pid, $msg ) = $stash->{'message'} =~ |
39
|
|
|
|
|
|
|
/^(\S+) ([^[]+)\[([^\]]+)\]: (.+)$/) { |
40
|
0
|
|
|
|
|
|
$stash->{'host'} = $host; |
41
|
0
|
|
|
|
|
|
$self->incr_one('by_host', $host); |
42
|
0
|
|
|
|
|
|
$stash->{'program'} = $program; |
43
|
0
|
|
|
|
|
|
$self->incr_one('by_program', $program); |
44
|
0
|
|
|
|
|
|
$stash->{'pid'} = $pid; |
45
|
0
|
|
|
|
|
|
$stash->{'message'} = $msg; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Log::Saftpresse::Plugin::SyslogFile - plugin to parse syslog logfile format |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
version 1.5 |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This is free software, licensed under: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |