From: Kern Sibbald Date: Tue, 14 Jul 2009 19:10:08 +0000 (+0000) Subject: Apply patch in bug #1315 by McMichaeli that fixes scripts/logwatch X-Git-Tag: Release-3.0.2~70 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9321c4aea3020df015addaa899cb972796592222;p=bacula%2Fbacula Apply patch in bug #1315 by McMichaeli that fixes scripts/logwatch git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8996 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/scripts/logwatch/Makefile.in b/bacula/scripts/logwatch/Makefile.in index 564e0517c9..f1f5be2862 100644 --- a/bacula/scripts/logwatch/Makefile.in +++ b/bacula/scripts/logwatch/Makefile.in @@ -9,10 +9,12 @@ all: install 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 --git a/bacula/scripts/logwatch/README b/bacula/scripts/logwatch/README index a00874a3e3..b3b8617fea 100644 --- a/bacula/scripts/logwatch/README +++ b/bacula/scripts/logwatch/README @@ -7,9 +7,11 @@ straightforward. Run 'make install' as root from this directory. 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 --git a/bacula/scripts/logwatch/applybaculadate b/bacula/scripts/logwatch/applybaculadate new file mode 100644 index 0000000000..ec7fe60e01 --- /dev/null +++ b/bacula/scripts/logwatch/applybaculadate @@ -0,0 +1,46 @@ +#!/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 --git a/bacula/scripts/logwatch/bacula b/bacula/scripts/logwatch/bacula index 1d0b3849b1..c0c7ad892c 100755 --- a/bacula/scripts/logwatch/bacula +++ b/bacula/scripts/logwatch/bacula @@ -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 @@ while () { # 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 @@ if (scalar(keys(%data))) { $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 --git a/bacula/scripts/logwatch/services.bacula.conf b/bacula/scripts/logwatch/services.bacula.conf index 298a3f8d43..b0b1d8148b 100644 --- a/bacula/scripts/logwatch/services.bacula.conf +++ b/bacula/scripts/logwatch/services.bacula.conf @@ -3,3 +3,4 @@ Title = "bacula" # Which logfile group... LogFile = bacula +*ApplyBaculaDate = diff --git a/bacula/technotes b/bacula/technotes index 0cd00e7408..07711141e5 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -3,6 +3,7 @@ General: 14Jul09 +kes Apply patch in bug #1315 by McMichaeli that fixes scripts/logwatch kes Add more output when spooling and no space left ebl Fix postgresql driver bug that displayed rows from time to time. kes More cleanup of bootstrap