From 66866720dda9ae0e220a0dce891d6a1cf3983ac7 Mon Sep 17 00:00:00 2001 From: Scott Barninger Date: Sat, 8 Jan 2005 14:03:18 +0000 Subject: [PATCH] Add logwatch filter. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1794 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/configure.in | 2 + bacula/configure | 4 +- bacula/scripts/logwatch/Makefile.in | 18 ++++ bacula/scripts/logwatch/bacula | 82 +++++++++++++++++++ .../scripts/logwatch/logfile.bacula.conf.in | 3 + bacula/scripts/logwatch/services.bacula.conf | 5 ++ 6 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 bacula/scripts/logwatch/Makefile.in create mode 100755 bacula/scripts/logwatch/bacula create mode 100644 bacula/scripts/logwatch/logfile.bacula.conf.in create mode 100644 bacula/scripts/logwatch/services.bacula.conf diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 4988c5cc2d..c30b359f3e 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1953,6 +1953,8 @@ AC_OUTPUT([autoconf/Make.common \ scripts/gnome-console.console_apps \ scripts/mtx-changer \ scripts/bacula-tray-monitor.desktop \ + scripts/logwatch/Makefile \ + scripts/logwatch/logfile.bacula.conf \ doc/Makefile \ src/Makefile \ src/host.h \ diff --git a/bacula/configure b/bacula/configure index 098adb2d5c..a9af613b08 100755 --- a/bacula/configure +++ b/bacula/configure @@ -21251,7 +21251,7 @@ if test "x${subsysdir}" = "x${sbindir}" ; then exit 1 fi - ac_config_files="$ac_config_files autoconf/Make.common Makefile rescue/Makefile rescue/linux/Makefile rescue/linux/floppy/Makefile rescue/linux/cdrom/Makefile rescue/linux/cdrom/bacula/Makefile rescue/freebsd/Makefile rescue/solaris/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer scripts/bacula-tray-monitor.desktop doc/Makefile src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome-console/Makefile src/gnome-console/gnome-console.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/filed/win32/Makefile src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/tools/Makefile src/win32/winbacula.nsi src/win32/baculafd/bacula-fd.conf src/win32/Makefile src/win32/console/bconsole.conf src/win32/wx-console/wx-console.conf src/win32/pebuilder/Makefile src/bimagemgr/Makefile src/bimagemgr/bacula-bimagemgr.spec $PFILES" + ac_config_files="$ac_config_files autoconf/Make.common Makefile rescue/Makefile rescue/linux/Makefile rescue/linux/floppy/Makefile rescue/linux/cdrom/Makefile rescue/linux/cdrom/bacula/Makefile rescue/freebsd/Makefile rescue/solaris/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer scripts/bacula-tray-monitor.desktop scripts/logwatch/Makefile scripts/logwatch/logfile.bacula.conf doc/Makefile src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome-console/Makefile src/gnome-console/gnome-console.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/filed/win32/Makefile src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/tools/Makefile src/win32/winbacula.nsi src/win32/baculafd/bacula-fd.conf src/win32/Makefile src/win32/console/bconsole.conf src/win32/wx-console/wx-console.conf src/win32/pebuilder/Makefile src/bimagemgr/Makefile src/bimagemgr/bacula-bimagemgr.spec $PFILES" ac_config_commands="$ac_config_commands default" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -21810,6 +21810,8 @@ do "scripts/gnome-console.console_apps" ) CONFIG_FILES="$CONFIG_FILES scripts/gnome-console.console_apps" ;; "scripts/mtx-changer" ) CONFIG_FILES="$CONFIG_FILES scripts/mtx-changer" ;; "scripts/bacula-tray-monitor.desktop" ) CONFIG_FILES="$CONFIG_FILES scripts/bacula-tray-monitor.desktop" ;; + "scripts/logwatch/Makefile" ) CONFIG_FILES="$CONFIG_FILES scripts/logwatch/Makefile" ;; + "scripts/logwatch/logfile.bacula.conf" ) CONFIG_FILES="$CONFIG_FILES scripts/logwatch/logfile.bacula.conf" ;; "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/host.h" ) CONFIG_FILES="$CONFIG_FILES src/host.h" ;; diff --git a/bacula/scripts/logwatch/Makefile.in b/bacula/scripts/logwatch/Makefile.in new file mode 100644 index 0000000000..564e0517c9 --- /dev/null +++ b/bacula/scripts/logwatch/Makefile.in @@ -0,0 +1,18 @@ +# Makefile to install logwatch script +# 08 Jan 2005 D. Scott Barninger + +SYSCONFDIR=/etc/log.d +INSTALL=@INSTALL@ + +all: install + +install: + + $(INSTALL) -m 755 bacula $(DESTDIR)$(SYSCONFDIR)/scripts/services/bacula + $(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)/conf/logfiles/bacula.conf + rm -f $(DESTDIR)$(SYSCONFDIR)/conf/services/bacula.conf diff --git a/bacula/scripts/logwatch/bacula b/bacula/scripts/logwatch/bacula new file mode 100755 index 0000000000..d567576f74 --- /dev/null +++ b/bacula/scripts/logwatch/bacula @@ -0,0 +1,82 @@ +#!/usr/bin/perl -w +# +# logwatch filter script for bacula log files +# +# Mon Jan 03 2005 +# D. Scott Barninger and Karl Cunningham +# +# Copyright 2005 Kern Sibbald +# licensed under GPL-v2 + +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)); +} + +# set debug level +$Debug = $ENV{'LOGWATCH_DEBUG'} || 0; + +if ( $Debug >= 5 ) { + print STDERR "\n\nDEBUG: Inside Bacula Filter \n\n"; + $DebugCounter = 1; +} + +while () { + chomp; + if ( $Debug >= 5 ) { + print STDERR "DEBUG($DebugCounter): $_\n"; + $DebugCounter++; + } + + # 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 we have data print it out, otherwise do nothing +if (scalar(keys(%data))) { + print "\nJobs Run:\n"; + foreach my $Id (sort {$a<=>$b} (keys(%data))) { + $ThisName = $data{$Id}{Job}; + $ThisStatus = $data{$Id}{JobStatus}; + $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"; + } + } +} + +exit(0); + + diff --git a/bacula/scripts/logwatch/logfile.bacula.conf.in b/bacula/scripts/logwatch/logfile.bacula.conf.in new file mode 100644 index 0000000000..3eaf0e2c75 --- /dev/null +++ b/bacula/scripts/logwatch/logfile.bacula.conf.in @@ -0,0 +1,3 @@ +# What actual file? Defaults to LogPath if not absolute path.... +LogFile = @working_dir@/log + diff --git a/bacula/scripts/logwatch/services.bacula.conf b/bacula/scripts/logwatch/services.bacula.conf new file mode 100644 index 0000000000..298a3f8d43 --- /dev/null +++ b/bacula/scripts/logwatch/services.bacula.conf @@ -0,0 +1,5 @@ +Title = "bacula" + +# Which logfile group... +LogFile = bacula + -- 2.39.5