Add systemd journal support (#864872)
This commit is contained in:
parent
97c5a5779f
commit
bf7f580f8f
95
logwatch-journal.patch
Normal file
95
logwatch-journal.patch
Normal file
@ -0,0 +1,95 @@
|
||||
commit 23e714ad43285d59c5b5852ef2c6013593d64671
|
||||
Author: bjorn <bjorn1@users.sourceforge.net>
|
||||
Date: Sun May 15 13:49:08 2016 -0700
|
||||
|
||||
[journalctl] Added shared script contributed by Mark Grimes.
|
||||
|
||||
diff --git a/scripts/shared/journalctl b/scripts/shared/journalctl
|
||||
new file mode 100755
|
||||
index 0000000..1627fd4
|
||||
--- /dev/null
|
||||
+++ b/scripts/shared/journalctl
|
||||
@@ -0,0 +1,83 @@
|
||||
+#!/usr/bin/perl
|
||||
+#
|
||||
+# The purpose of this script is to pass the output of the journalctl
|
||||
+# command to the logwatch parsers. The corresponding conf/logfile
|
||||
+# can be simple. The following example shows a logfile with two lines:
|
||||
+# LogFile = /dev/null
|
||||
+# *JournalCtl = "--output=cat --unit=service_name.service"
|
||||
+#
|
||||
+# In the example above, the arguments to the JournalCtl command are
|
||||
+# passed to the journalctl system command. It is advised to delimit
|
||||
+# the arguments in double quotes to preserve mixed case, if
|
||||
+# applicable.
|
||||
+
|
||||
+use strict;
|
||||
+use warnings;
|
||||
+
|
||||
+eval "use Date::Manip";
|
||||
+my $hasDM = $@ ? 0 : 1;
|
||||
+
|
||||
+# logwatch passes arguments as one string delimited by single quotes
|
||||
+my @args = split(" ", $ARGV[0]);
|
||||
+my @range = get_range( $ENV{LOGWATCH_DATE_RANGE} );
|
||||
+
|
||||
+my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
|
||||
+
|
||||
+if ($Debug > 5) {
|
||||
+ warn join " ", 'journalctl', @args, @range, "\n";
|
||||
+}
|
||||
+
|
||||
+system( 'journalctl', @args, @range );
|
||||
+
|
||||
+sub get_range {
|
||||
+ my $range = lc( shift || 'all' );
|
||||
+ my @range;
|
||||
+
|
||||
+ if ( !$range || $range eq 'all' ) {
|
||||
+ @range = ();
|
||||
+ } elsif ( $range eq 'yesterday' ) {
|
||||
+ push @range, '--since', 'yesterday', '--until', 'today';
|
||||
+ } elsif ( $range eq 'today' ) {
|
||||
+ push @range, '--since', 'today', '--until', 'tomorrow';
|
||||
+ } elsif ($hasDM) {
|
||||
+
|
||||
+ # Strip off any period
|
||||
+ $range =~
|
||||
+ s/for\s+(?:those|that|this)\s+((year|month|day|hour|minute|second)s?)\s*$//;
|
||||
+
|
||||
+ # Look for between x and y
|
||||
+ my ( $range1, $range2 ) =
|
||||
+ ( $range =~ /^between\s+(.*)\s+and\s+(.*)\s*$/ );
|
||||
+
|
||||
+ # Look for since x
|
||||
+ if ( $range =~ /^\s*since\s+/ ) {
|
||||
+ ($range1) = ( $range =~ /\s*since\s+(.*)/ );
|
||||
+ $range2 = "now";
|
||||
+ }
|
||||
+
|
||||
+ # Now convert to journalctl friendly dates
|
||||
+ if ( $range1 && $range2 ) {
|
||||
+
|
||||
+ # Parse dates
|
||||
+ my $date1 = ParseDate($range1);
|
||||
+ my $date2 = ParseDate($range2);
|
||||
+
|
||||
+ # Switch if date2 is before date1
|
||||
+ if ( $date1 && $date2 and Date_Cmp( $date1, $date2 ) > 0 ) {
|
||||
+ my $switch_date = $date1;
|
||||
+ $date1 = $date2;
|
||||
+ $date2 = $switch_date;
|
||||
+ }
|
||||
+
|
||||
+ # If we ask for 1/1 to 1/2, we mean 1/2 inclusive. DM returns
|
||||
+ # 1/2 00:00:00. So we add 1 day to the end time.
|
||||
+ $date2 = DateCalc( $date2, '1 day' );
|
||||
+
|
||||
+ my $fmt = "%Y-%m-%d %H:%M:%S";
|
||||
+ push @range, '--since', UnixDate( $date1, $fmt ), '--until',
|
||||
+ UnixDate( $date2, $fmt );
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return @range;
|
||||
+}
|
||||
38
logwatch-journald-source.patch
Normal file
38
logwatch-journald-source.patch
Normal file
@ -0,0 +1,38 @@
|
||||
commit ed6eb62f40cb97f71f3df4d982682de68cdf1037
|
||||
Author: Stefan Jakobs <projects@localside.net>
|
||||
Date: Tue May 31 23:34:11 2016 +0200
|
||||
|
||||
support journald as source
|
||||
|
||||
diff --git a/scripts/services/syslog-ng b/scripts/services/syslog-ng
|
||||
old mode 100755
|
||||
new mode 100644
|
||||
index dcd1692..d78c835
|
||||
--- a/scripts/services/syslog-ng
|
||||
+++ b/scripts/services/syslog-ng
|
||||
@@ -1,5 +1,5 @@
|
||||
###########################################################################
|
||||
-# $Id$
|
||||
+# $Id: syslog-ng 280 2014-12-24 15:29:13Z stefjakobs $
|
||||
###########################################################################
|
||||
|
||||
###########################################################################
|
||||
@@ -168,7 +168,7 @@ while (defined($ThisLine = <STDIN>)) {
|
||||
$Stats_dest{$processed[$i+1]} =
|
||||
$Stats_dest{$processed[$i+1]} + $processed[$i+2];
|
||||
} elsif ($processed[$i] eq "source" || $processed[$i] eq "src.internal" ||
|
||||
- $processed[$i] eq 'src.none' ) {
|
||||
+ $processed[$i] eq 'src.none' || $processed[$i] eq 'src.journald') {
|
||||
$Stats_source{$processed[$i+1]} =
|
||||
$Stats_source{$processed[$i+1]} + $processed[$i+2];
|
||||
} elsif ($processed[$i] eq "global") {
|
||||
@@ -366,7 +366,8 @@ if (keys %Stats_center || keys %Stats_dest || keys %Stats_source ||
|
||||
$lost_rcvd = 0 - $Stats_center{received};
|
||||
map {
|
||||
# skip 'src#X' as this seams to be aggregated into 'src'
|
||||
- $lost_rcvd = $lost_rcvd + $Stats_source{$_} unless ($_ =~ /src#\d+/);
|
||||
+ # skip 'journal' as this is not counted.
|
||||
+ $lost_rcvd = $lost_rcvd + $Stats_source{$_} unless ($_ =~ /(?:src#\d+|journal)/);
|
||||
} keys %Stats_source;
|
||||
}
|
||||
if ($Stats_center{queued} && %Stats_dest) {
|
||||
@ -1,7 +1,7 @@
|
||||
Summary: A log file analysis program
|
||||
Name: logwatch
|
||||
Version: 7.4.3
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
License: MIT
|
||||
Group: Applications/System
|
||||
URL: http://www.logwatch.org/
|
||||
@ -16,6 +16,10 @@ Patch2: logwatch-secure-userhelper.patch
|
||||
Patch3: logwatch-sshd.patch
|
||||
# Submitted upstream: https://sourceforge.net/p/logwatch/mailman/message/35076800/
|
||||
Patch4: logwatch-postfix.patch
|
||||
# https://sourceforge.net/p/logwatch/git/ci/23e714ad43285d59c5b5852ef2c6013593d64671/
|
||||
Patch5: logwatch-journal.patch
|
||||
# https://sourceforge.net/p/logwatch/git/ci/ed6eb62f40cb97f71f3df4d982682de68cdf1037/
|
||||
Patch6: logwatch-journald-source.patch
|
||||
BuildRequires: perl-generators
|
||||
Requires: textutils sh-utils grep mailx
|
||||
Requires: perl(Date::Manip)
|
||||
@ -37,6 +41,8 @@ of the package on many systems.
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
%patch6 -p1
|
||||
rm -f scripts/services/*.orig
|
||||
|
||||
%build
|
||||
@ -136,6 +142,9 @@ echo "# Configuration overrides for specific logfiles/services may be placed her
|
||||
%{_mandir}/man*/*
|
||||
|
||||
%changelog
|
||||
* Wed Nov 30 2016 Jan Synáček <jsynacek@redhat.com> - 7.4.3-3
|
||||
- Add systemd journal support (#864872)
|
||||
|
||||
* Tue May 10 2016 Jan Synáček <jsynacek@redhat.com> - 7.4.3-2
|
||||
- Fix misaligned output in postfix (#1326808)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user