annotate common/logwatch/http-error @ 224:636866c00b86 puppet-3.6

Blacklist more user probes - a database and a generic "service"
author IBBoard <dev@ibboard.co.uk>
date Sun, 27 Oct 2019 16:59:42 +0000
parents 8316d4e55e92
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
1 #!/usr/bin/perl
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 #
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
3 ##########################################################################
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
4 ## Copyright (c) 2016 Logwatch
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 ## Covered under the included MIT/X-Consortium License:
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 ## http://www.opensource.org/licenses/mit-license.php
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 ## All modifications and contributions by other persons to
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 ## this script are assumed to have been donated to the
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 ## Logwatch project and thus assume the above copyright
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 ## and licensing terms. If you want to make contributions
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 ## under your own copyright or a different license this
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 ## must be explicitly stated in the contribution an the
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 ## Logwatch project reserves the right to not accept such
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 ## contributions. If you have made significant
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 ## contributions to this script and want to claim
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 ## copyright please contact logwatch-devel@lists.sourceforge.net.
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
17 ##########################################################################
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
19 use diagnostics;
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 use strict;
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
22 my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
24 sub CustomizeErrorString {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
25 my ($LogLevel, $ErrorCode, $Description) = @_;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
26 # This function is only invoked when detail is set to 8 or 9.
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
27 # Here you would modify the Description. Some Description strings
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
28 # may differ only on some printed parameters, and it is preferable
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
29 # to group them together. Examples of these may be process numbers,
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
30 # IP addresses, port numbers, or file names. The purpose of this
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
31 # function is to "collapse" these different messages into the same
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
32 # array entry.
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
34 # For now, simply return the string.
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
35 return($Description);
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
36 }
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
38 my %LogMessages = ();
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
39 my $MatchFilter = $ENV{'http_error_matchfilter'} || "";
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
40 my $ReportFilter = $ENV{'http_error_reportfilter'} || "";
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
42 while (defined(my $ThisLine = <STDIN>)) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
43 if (my ($LogLevel, $ErrorCode, $Description) =
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
44 ($ThisLine =~ /:(.*?)\].*(AH\d{5}): (.*)/) ) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
45 # $MatchFilter is a variable that is set by setting the
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
46 # $HTTP_Error_MatchFilter variable in the conf/services/http-error.conf
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
47 # file. It is executed here, before any other matching statements.
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
48 eval $MatchFilter;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
49 if ($@) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
50 print $@;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
51 print "While processing MatchFilter:\n$MatchFilter\n";
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
52 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
53 # $ThisLine might have been reset (undef, or empty string) in $MatchFilter
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
54 next unless $ThisLine;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
55
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
56 if (($Detail == 8) || ($Detail == 9)) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
57 $Description = CustomizeErrorString($LogLevel, $ErrorCode, $Description);
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
58 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
59 if (($Detail >= 1) || ($LogLevel =~ "emerg|alert|crit|error")) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
60 $LogMessages{$LogLevel}{$ErrorCode}{$Description}++;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
61 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
62 }
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
65 # $ReportFilter is a variable that is set by setting the
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
66 # $HTTP_Error_ReportFilter variable in the conf/services/http-error.conf
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
67 # file. It is executed here, before any other printing statements.
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
68 eval $ReportFilter;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
69 if ($@) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
70 print $@;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
71 print "While processing ReportFilter:\n$ReportFilter\n";
0
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 }
956e484adc12 Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73
126
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
74 if (keys %LogMessages) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
75 my $Count = 0;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
76 foreach my $LogLevel (keys %LogMessages) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
77 printf("\nLevel %-6s", $LogLevel);
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
78 foreach my $ErrorCode (keys %{$LogMessages{$LogLevel}}) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
79 print "\n Error Code: $ErrorCode" if $Detail >= 5;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
80 foreach my $Description (keys %{$LogMessages{$LogLevel}{$ErrorCode}}) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
81 if ($Detail >= 9) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
82 print "\n $Description: ";
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
83 print "$LogMessages{$LogLevel}{$ErrorCode}{$Description} Time(s)";
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
84 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
85 $Count += $LogMessages{$LogLevel}{$ErrorCode}{$Description};
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
86 } # foreach $Description
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
87 if (($Detail >= 5) && ($Detail < 9)) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
88 printf(": %5d Time(s)", $Count);
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
89 $Count = 0;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
90 if ($Detail >=6) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
91 print "\n E.g.: ";
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
92 # print only first entry (index 0)
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
93 my $EG_string = (keys %{$LogMessages{$LogLevel}{$ErrorCode}})[0];
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
94 if (($Detail == 6) && (length($EG_string) > 66)) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
95 printf ("%.62s ...", $EG_string);
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
96 } else {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
97 print $EG_string;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
98 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
99 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
100 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
101 } # foreach $ErrorCode
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
102 if ($Detail < 5) {
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
103 printf("%s%5d%s", ": ", $Count, " Time(s)");
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
104 $Count = 0;
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
105 }
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
106 } # foreach $LogLevel
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
107 } # if keys %LogMessages
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
108
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
109 exit(0);
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
110
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
111 # vi: shiftwidth=3 tabstop=3 syntax=perl et
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
112 # Local Variables:
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
113 # mode: perl
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
114 # perl-indent-level: 3
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
115 # indent-tabs-mode: nil
8316d4e55e92 Fix Apache 2.4 Logwatch support
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
116 # End: