]> git.sur5r.net Git - bacula/bacula/commitdiff
Apply patch in bug #1315 by McMichaeli that fixes scripts/logwatch
authorKern Sibbald <kern@sibbald.com>
Tue, 14 Jul 2009 19:10:08 +0000 (19:10 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 14 Jul 2009 19:10:08 +0000 (19:10 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8996 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/scripts/logwatch/Makefile.in
bacula/scripts/logwatch/README
bacula/scripts/logwatch/applybaculadate [new file with mode: 0644]
bacula/scripts/logwatch/bacula
bacula/scripts/logwatch/services.bacula.conf
bacula/technotes

index 564e0517c9859d29c6b2ee49c1922494ebc6b1dd..f1f5be28620f314168195c9617efcdf8086c54d9 100644 (file)
@@ -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
index a00874a3e39dc11a6e359287ba05a1785e8d4822..b3b8617fead19a0290b33b9e07878fcef11f76ee 100644 (file)
@@ -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 (file)
index 0000000..ec7fe60
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+########################################################################
+
+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 = <STDIN>)) {
+   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
index 1d0b3849b174ede8ecb049fa387b18e13cbd1f1d..c0c7ad892c262f0247b23c3a6a662663126603f8 100755 (executable)
 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 (<STDIN>) {
 
         # 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";
         }
 }
 
index 298a3f8d4340ffd134a827fb31f5b7178b6f79ed..b0b1d8148b630147587048d3a4f01e4750167d95 100644 (file)
@@ -3,3 +3,4 @@ Title = "bacula"
 # Which logfile group...
 LogFile = bacula
 
+*ApplyBaculaDate =
index 0cd00e7408d6e161d597c25ab39041d51bbceee9..07711141e5c1fd77357e59865a3481769a98bb72 100644 (file)
@@ -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 <NULL> rows from time to time.
 kes  More cleanup of bootstrap