[PATCH] Add rsnapshot support
Hayden Lau <[email protected]> Wed, 24 Aug 2016 13:08:07 -0400
| Newsgroups | gmane.comp.log.logwatch.devel |
|---|---|
| Message-ID | <[email protected]> |
Hey all, Wrote a script to parse logs for rsnapshot, an rsync-based backup tool. Hayden Lau ------------------------------------------------------------------------------ _______________________________________________ Logwatch-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/logwatch-devel
0001-Add-support-for-rsnapshot.patch
(text/x-patch, 3.2 KB)
From 26a5973ce19437060e35e22e1ab79111187b422a Mon Sep 17 00:00:00 2001 From: Hayden Lau <[email protected]> Date: Fri, 22 Jul 2016 01:56:46 -0400 Subject: [PATCH] Add support for rsnapshot --- conf/logfiles/rsnapshot.conf | 10 +++++++ conf/services/rsnapshot.conf | 6 ++++ scripts/services/rsnapshot | 68 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 conf/logfiles/rsnapshot.conf create mode 100644 conf/services/rsnapshot.conf create mode 100644 scripts/services/rsnapshot diff --git a/conf/logfiles/rsnapshot.conf b/conf/logfiles/rsnapshot.conf new file mode 100644 index 0000000..464fc16 --- /dev/null +++ b/conf/logfiles/rsnapshot.conf @@ -0,0 +1,10 @@ +# rsnapshot backup tool logfile + +# default logfile location (relative to /var/log) +# don't forget to change this if changed in /etc/rsnapshot.conf +LogFile = rsnapshot.log +Archive = rsnapshot.log.*.gz + +# parse & remove date tag +*ApplyStdDate = "\[%d/%b/%Y:%H:%M:%S\]" +*RemoveHeaders = "\[\d\d/\w{3}/\d{4}:\d\d:\d\d:\d\d\] " diff --git a/conf/services/rsnapshot.conf b/conf/services/rsnapshot.conf new file mode 100644 index 0000000..24ec612 --- /dev/null +++ b/conf/services/rsnapshot.conf @@ -0,0 +1,6 @@ +# rsnapshot backup tool service + +# just one logfile format +LogFile = rsnapshot + +Title = "rsnapshot" diff --git a/scripts/services/rsnapshot b/scripts/services/rsnapshot new file mode 100644 index 0000000..ca35fa4 --- /dev/null +++ b/scripts/services/rsnapshot @@ -0,0 +1,68 @@ +#!/usr/bin/perl + +# rsnapshot backup tool log parsing script +# Hayden Lau, July 2016 + +use strict; +my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0; +my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0; +my %Error; +my %Warning; +my %Started; +my %Successful; +my %OtherList; + +while (defined(my $ThisLine = <STDIN>)) { + chomp($ThisLine); + if ($Debug) { + print "$ThisLine\n"; + } + if ($ThisLine =~ /ERROR: (\N+)/) { + $Error{$1}++; + } elsif ($ThisLine =~ /WARNING: (\N+)/) { + $Warning{$1}++; + } elsif ($ThisLine =~ / (\S+): started/) { + $Started{$1}++; + } elsif ($ThisLine =~ / (\S+): completed successfully/) { + $Successful{$1}++; + } else { + $OtherList{$ThisLine}++; + } +} + +if (keys %Error) { + print "ERRORS:\n"; + foreach my $line (sort {$a cmp $b} keys %Error) { + print " $line: $Error{$line} Time(s)\n"; + } +} + +if (keys %Warning) { + print "Warnings:\n"; + foreach my $line (sort {$a cmp $b} keys %Warning) { + print " $line: $Warning{$line} Time(s)\n"; + } +} + +if (($Detail > 5) and keys %Started) { + print "Started:\n"; + foreach my $retain (sort { $Started{$b} <=> $Started{$a} } keys %Started) { + print " $retain: $Started{$retain} Time(s)\n"; + } +} + +if ($Detail and keys %Successful) { + print "Completed Successfully:\n"; + foreach my $retain (sort { $Successful{$b} <=> $Successful{$a} } keys %Successful) { + print " $retain: $Successful{$retain} Time(s)\n"; + } +} + +if (keys %OtherList) { + print "\n**Unmatched Entries**\n"; + foreach my $line (sort {$a cmp $b} keys %OtherList) { + print " $line: $OtherList{$line} Time(s)\n"; + } +} + +exit(0); -- 2.9.2.windows.1