| 1 | package eris::log::context::yum; | ||||||||||
| 2 | # ABSTRACT: Parse the yum syslog output into structured data | ||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use Const::Fast; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | with qw( | |||||||||
| 8 | eris::role::context | ||||||||||
| 9 | ); | ||||||||||
| 10 | |||||||||||
| 11 | 1 | our $VERSION = '0.008'; # VERSION | |||||||||
| 12 | |||||||||||
| 13 | |||||||||||
| 14 | sub sample_messages { | ||||||||||
| 15 | 0 | ▶ | my @msgs = split /\r?\n/, <<EOF; | ||||||||
|
Subroutine
sample_messages: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 16 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-filesystem-1.10.1-1.el6.noarch | ||||||||||
| 17 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-mod-http-geoip-1.10.1-1.el6.x86_64 | ||||||||||
| 18 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-mod-mail-1.10.1-1.el6.x86_64 | ||||||||||
| 19 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-mod-stream-1.10.1-1.el6.x86_64 | ||||||||||
| 20 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-mod-http-image-filter-1.10.1-1.el6.x86_64 | ||||||||||
| 21 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-mod-http-perl-1.10.1-1.el6.x86_64 | ||||||||||
| 22 | Sep 7 03:43:36 ether yum[26202]: Updated: nginx-1.10.1-1.el6.x86_64 | ||||||||||
| 23 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-mod-http-xslt-filter-1.10.1-1.el6.x86_64 | ||||||||||
| 24 | Sep 7 03:43:36 ether yum[26202]: Installed: nginx-all-modules-1.10.1-1.el6.noarch | ||||||||||
| 25 | Sep 7 03:43:36 ether yum[26202]: Updated: libudev-147-2.73.el6_8.2.x86_64 | ||||||||||
| 26 | Sep 7 03:43:36 ether yum[26202]: Updated: libgudev1-147-2.73.el6_8.2.x86_64 | ||||||||||
| 27 | Sep 7 03:43:37 ether yum[26202]: Updated: udev-147-2.73.el6_8.2.x86_64 | ||||||||||
| 28 | Sep 9 03:51:41 ether yum[12333]: Updated: puppetlabs-release-22.0-2.noarch | ||||||||||
| 29 | Sep 10 04:14:59 ether yum[22005]: Updated: perl-File-Next-1.16-1.el6.noarch | ||||||||||
| 30 | EOF | ||||||||||
| 31 | 0 | return @msgs; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | sub contextualize_message { | ||||||||||
| 36 | 0 | ▶ | my ($self,$log) = @_; | ||||||||
|
Subroutine
contextualize_message: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 37 | 0 | my $str = $log->context->{message}; | |||||||||
| 38 | 0 | my %ctxt = (); | |||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | if($str =~ /^(\S+): (\S+)/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | $ctxt{action} = lc $1; | |||||||||
| 42 | 0 | $ctxt{file} = $2; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | $log->add_context($self->name,\%ctxt) if keys %ctxt; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | 1 | 1; | |||||||||
| 50 | |||||||||||
| 51 | __END__ | ||||||||||
| 52 | |||||||||||
| 53 | =pod | ||||||||||
| 54 | |||||||||||
| 55 | =encoding UTF-8 | ||||||||||
| 56 | |||||||||||
| 57 | =head1 NAME | ||||||||||
| 58 | |||||||||||
| 59 | eris::log::context::yum - Parse the yum syslog output into structured data | ||||||||||
| 60 | |||||||||||
| 61 | =head1 VERSION | ||||||||||
| 62 | |||||||||||
| 63 | version 0.008 | ||||||||||
| 64 | |||||||||||
| 65 | =head1 METHODS | ||||||||||
| 66 | |||||||||||
| 67 | =head2 contextualize_message | ||||||||||
| 68 | |||||||||||
| 69 | Extracts the package and action from the yum log into: | ||||||||||
| 70 | |||||||||||
| 71 | action => installed/updated/removed | ||||||||||
| 72 | file => package name with full version | ||||||||||
| 73 | |||||||||||
| 74 | =for Pod::Coverage sample_messages | ||||||||||
| 75 | |||||||||||
| 76 | =head1 SEE ALSO | ||||||||||
| 77 | |||||||||||
| 78 | L<eris::log::contextualizer>, L<eris::role::context> | ||||||||||
| 79 | |||||||||||
| 80 | =head1 AUTHOR | ||||||||||
| 81 | |||||||||||
| 82 | Brad Lhotsky <brad@divisionbyzero.net> | ||||||||||
| 83 | |||||||||||
| 84 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 85 | |||||||||||
| 86 | This software is Copyright (c) 2015 by Brad Lhotsky. | ||||||||||
| 87 | |||||||||||
| 88 | This is free software, licensed under: | ||||||||||
| 89 | |||||||||||
| 90 | The (three-clause) BSD License | ||||||||||
| 91 | |||||||||||
| 92 | =cut | ||||||||||