File Coverage

blib/lib/Log/Saftpresse/Plugin/LinuxNetfilter.pm
Criterion Covered Total %
statement 3 17 17.6
branch 0 6 0.0
condition 0 6 0.0
subroutine 1 2 50.0
pod 1 1 100.0
total 5 32 15.6


line stmt bran cond sub pod time code
1             package Log::Saftpresse::Plugin::LinuxNetfilter;
2              
3 1     1   1526 use Moose;
  1         3  
  1         38  
4              
5             # ABSTRACT: plugin to parse network packets logged by linux/netfilter
6             our $VERSION = '1.6'; # VERSION
7              
8             extends 'Log::Saftpresse::Plugin';
9              
10             with 'Log::Saftpresse::Plugin::Role::CounterUtils';
11              
12             sub process {
13 0     0 1   my ( $self, $stash ) = @_;
14 0           my $program = $stash->{'program'};
15 0 0 0       if( ! defined $program || $program ne 'kernel' ) {
16 0           return;
17             }
18              
19             my ( $prefix, $msg ) =
20 0           $stash->{'message'} =~ /^\[\d+\.\d+\] ([^:]+): (IN=\S* OUT=\S* .+) ?$/;
21              
22 0 0         if( ! defined $prefix ) {
23 0           return;
24             }
25              
26             my %values = map {
27 0           my ( $key, $value ) = split('=', $_, 2);
  0            
28 0 0 0       defined $value && $value ne '' ? ( lc($key) => $value ) : ();
29             } split(' ', $msg);
30              
31 0           $stash->{'prefix'} = $prefix;
32 0           @$stash{ keys %values } = values %values;
33              
34 0           $self->count_fields_occur( $stash, 'prefix' );
35              
36 0           return;
37             }
38              
39             1;
40              
41             __END__
42              
43             =pod
44              
45             =encoding UTF-8
46              
47             =head1 NAME
48              
49             Log::Saftpresse::Plugin::LinuxNetfilter - plugin to parse network packets logged by linux/netfilter
50              
51             =head1 VERSION
52              
53             version 1.6
54              
55             =head1 AUTHOR
56              
57             Markus Benning <ich@markusbenning.de>
58              
59             =head1 COPYRIGHT AND LICENSE
60              
61             This software is Copyright (c) 1998 by James S. Seymour, 2015 by Markus Benning.
62              
63             This is free software, licensed under:
64              
65             The GNU General Public License, Version 2, June 1991
66              
67             =cut