diff -Naur bacula-2.4.4.old/null bacula-2.4.4/null --- /dev/null 1970-01-01 01:00:00.000000000 +0100 +++ bacula-2.4.4/scripts/logwatch/applybaculadate 2012-07-19 14:50:03.298459699 +0200 @@ -0,0 +1,92 @@ +#!/usr/bin/perl + +######################################################################## +## Copyright (c) 2009 Sigma Consulting Services Limited +## v1.00 2009/06/21 16:54:23 Ian McMichael +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 2 of the License, or +## any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . +######################################################################## + +use Logwatch ':dates'; + +my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0; + +$SearchDate = TimeFilter('%d-%b %H:%M'); + +if ( $Debug > 5 ) { + print STDERR "DEBUG: Inside ApplyBaculaDate...\n"; + print STDERR "DEBUG: Looking For: " . $SearchDate . "\n"; +} + +my $OutputLine = 0; + +while (defined($ThisLine = )) { + if ($ThisLine =~ m/^$SearchDate /o) { + $OutputLine = 1; + } elsif ($ThisLine !~ m/^\s+/o) { + $OutputLine = 0; + } + + if ($OutputLine) { + print $ThisLine; + } +} + +# vi: shiftwidth=3 syntax=perl tabstop=3 et +#!/usr/bin/perl + +######################################################################## +## Copyright (c) 2009 Sigma Consulting Services Limited +## v1.00 2009/06/21 16:54:23 Ian McMichael +## +## This program is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 2 of the License, or +## any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . +######################################################################## + +use Logwatch ':dates'; + +my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0; + +$SearchDate = TimeFilter('%d-%b %H:%M'); + +if ( $Debug > 5 ) { + print STDERR "DEBUG: Inside ApplyBaculaDate...\n"; + print STDERR "DEBUG: Looking For: " . $SearchDate . "\n"; +} + +my $OutputLine = 0; + +while (defined($ThisLine = )) { + if ($ThisLine =~ m/^$SearchDate /o) { + $OutputLine = 1; + } elsif ($ThisLine !~ m/^\s+/o) { + $OutputLine = 0; + } + + if ($OutputLine) { + print $ThisLine; + } +} + +# vi: shiftwidth=3 syntax=perl tabstop=3 et diff -Naur bacula-2.4.4.old/scripts/logwatch/bacula bacula-2.4.4/scripts/logwatch/bacula --- bacula-2.4.4.old/scripts/logwatch/bacula 2012-07-19 14:48:12.725285088 +0200 +++ bacula-2.4.4/scripts/logwatch/bacula 2012-07-19 14:49:23.998686777 +0200 @@ -11,18 +11,8 @@ use strict; use POSIX qw(strftime); -my (@JobName,$JobStatus,$ThisName,$ThisStatus,$ThisDate,$SearchDate); -my ($Job,$JobId,$JobDate,$Debug,$DebugCounter,%data,$time); - -# set the logwatch search date we want -$time = time; - -if ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'yesterday') { - $SearchDate = strftime("%Y-%m-%d", localtime($time-86400)); -} -elsif ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'today') { - $SearchDate = strftime("%Y-%m-%d", localtime($time)); -} +my (@JobName,$JobStatus,$ThisName,$ThisStatus,$ThisDate); +my ($Job,$JobId,$JobDate,$Debug,$DebugCounter,%data); # set debug level $Debug = $ENV{'LOGWATCH_DEBUG'} || 0; @@ -41,22 +31,22 @@ # Test the line for a new entry, which is a jobid record if (/^\s*JobId:\s+(\d+)/) { - # A new entry. Test, then save the previous stuff and - # set up to grab more. - if ($JobId and $Job and $JobStatus and $JobDate) { - $data{$JobId} = { - "Job" => $Job, - "JobStatus" => $JobStatus, - "JobDate" => $JobDate, - }; - $Job = $JobStatus = $JobDate = ""; - } $JobId = $1; next; } + (/^\s*Job:\s*(.*)/) and $Job = $1; (/^\s*Termination:\s*(.*)/) and $JobStatus = $1; (/^\s*Job:.*(\d{4}-\d{2}-\d{2})/) and $JobDate = $1; + + if ($JobId and $Job and $JobStatus and $JobDate) { + $data{$JobId} = { + "Job" => $Job, + "JobStatus" => $JobStatus, + "JobDate" => $JobDate, + }; + $JobId = $Job = $JobStatus = $JobDate = ""; + } } # if we have data print it out, otherwise do nothing @@ -68,12 +58,7 @@ $ThisDate = $data{$Id}{JobDate}; $ThisName =~ s/\s//g; $ThisStatus =~ s/\s//g; - if ( $ENV{'LOGWATCH_DATE_RANGE'} eq 'all') { - $SearchDate = $ThisDate; - } - if ($ThisDate eq $SearchDate) { - print "$ThisDate $Id $ThisName\n $ThisStatus\n\n"; - } + print "$ThisDate $Id $ThisName\n $ThisStatus\n\n"; } } diff -Naur bacula-2.4.4.old/scripts/logwatch/Makefile.in bacula-2.4.4/scripts/logwatch/Makefile.in --- bacula-2.4.4.old/scripts/logwatch/Makefile.in 2012-07-19 14:48:12.726285108 +0200 +++ bacula-2.4.4/scripts/logwatch/Makefile.in 2012-07-19 14:49:23.990686620 +0200 @@ -9,10 +9,12 @@ install: $(INSTALL) -m 755 bacula $(DESTDIR)$(SYSCONFDIR)/scripts/services/bacula + $(INSTALL) -m 755 applybaculadate $(DESTDIR)$(SYSCONFDIR)/scripts/shared/applybaculadate $(INSTALL) -m 644 logfile.bacula.conf $(DESTDIR)$(SYSCONFDIR)/conf/logfiles/bacula.conf $(INSTALL) -m 644 services.bacula.conf $(DESTDIR)$(SYSCONFDIR)/conf/services/bacula.conf uninstall: rm -f $(DESTDIR)$(SYSCONFDIR)/scripts/services/bacula + rm -f $(DESTDIR)$(SYSCONFDIR)/scripts/shared/applybaculadate rm -f $(DESTDIR)$(SYSCONFDIR)/conf/logfiles/bacula.conf rm -f $(DESTDIR)$(SYSCONFDIR)/conf/services/bacula.conf diff -Naur bacula-2.4.4.old/scripts/logwatch/README bacula-2.4.4/scripts/logwatch/README --- bacula-2.4.4.old/scripts/logwatch/README 2012-07-19 14:48:12.726285108 +0200 +++ bacula-2.4.4/scripts/logwatch/README 2012-07-19 14:49:23.991686637 +0200 @@ -7,9 +7,11 @@ For manual install copy the files as indicated below: cp -p scripts/logwatch/bacula /etc/log.d/scripts/services/bacula +cp -p scripts/logwatch/bacula /etc/log.d/scripts/shared/applybaculadate cp -p scripts/logwatch/logfile.bacula.conf /etc/log.d/conf/logfiles/bacula.conf cp -p scripts/logwatch/services.bacula.conf /etc/log.d/conf/services/bacula.conf chmod 755 /etc/log.d/scripts/services/bacula +chmod 755 /etc/log.d/scripts/shared/applybaculadate chmod 644 /etc/log.d/conf/logfiles/bacula.conf chmod 644 /etc/log.d/conf/services/bacula.conf diff -Naur bacula-2.4.4.old/scripts/logwatch/services.bacula.conf bacula-2.4.4/scripts/logwatch/services.bacula.conf --- bacula-2.4.4.old/scripts/logwatch/services.bacula.conf 2012-07-19 14:48:12.725285088 +0200 +++ bacula-2.4.4/scripts/logwatch/services.bacula.conf 2012-07-19 14:49:23.998686777 +0200 @@ -3,3 +3,4 @@ # Which logfile group... LogFile = bacula +*ApplyBaculaDate =