]>
Commit | Line | Data |
---|---|---|
a2e095af TF |
1 | ########################################################################### |
2 | # ipblocklist script for Logwatch | |
3 | # Analyzes the IPFire IP Blocklist log | |
4 | # | |
5 | ######################################################################### | |
6 | ||
7 | ######################################################## | |
8 | ## Copyright (c) 2008 Lars Skjærlund | |
9 | ## Covered under the included MIT/X-Consortium License: | |
10 | ## http://www.opensource.org/licenses/mit-license.php | |
11 | ## All modifications and contributions by other persons to | |
12 | ## this script are assumed to have been donated to the | |
13 | ## Logwatch project and thus assume the above copyright | |
14 | ## and licensing terms. If you want to make contributions | |
15 | ## under your own copyright or a different license this | |
16 | ## must be explicitly stated in the contribution and the | |
17 | ## Logwatch project reserves the right to not accept such | |
18 | ## contributions. If you have made significant | |
19 | ## contributions to this script and want to claim | |
20 | ## copyright please contact logwatch-devel@lists.sourceforge.net. | |
21 | ######################################################### | |
22 | ||
23 | ######################################################################### | |
24 | # Files - all shown with default paths: | |
25 | # | |
26 | # /usr/share/logwatch/default.conf/logfiles/messages.conf | |
27 | # /usr/share/logwatch/dist.conf/services/blocklist.conf | |
28 | # /usr/share/logwatch/scripts/services/ipblocklist (this file) | |
29 | # | |
30 | # ... and of course | |
31 | # | |
32 | # /var/log/messages | |
33 | ######################################################################### | |
34 | ||
35 | use Logwatch ':dates'; | |
36 | ||
37 | my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'}; | |
38 | ||
39 | my $SearchDate; | |
40 | ||
41 | my %Updates; | |
42 | my %Errors; | |
43 | ||
44 | $SearchDate = TimeFilter("%b %e"); | |
45 | ||
46 | while (defined(my $ThisLine = <STDIN>)) | |
47 | { | |
48 | next unless ($ThisLine =~ m/^\s*\w+\s+\w+\s+(..:..:..) .* ipblocklist: (.*)/); | |
49 | ||
50 | my $text = $2; | |
51 | ||
52 | if ($text =~ m/Successfully updated (\w+) blocklist/) | |
53 | { | |
54 | $Updates{$1}{updates}++; | |
55 | } | |
56 | elsif ($text !~ m/Skipping (\w+) blocklist - Too frequent update attempts!/ and | |
57 | $text !~ m/Skipping (\w+) blocklist - It has not been modified!/ ) | |
58 | { | |
59 | $Errors{$text}++; | |
60 | } | |
61 | } | |
62 | ||
63 | ##################################################################### | |
64 | ||
65 | if (keys %Updates) | |
66 | { | |
67 | print "\nThe following block lists were updated:\n"; | |
68 | foreach my $Lists (sort keys %Updates) | |
69 | { | |
70 | print " $Lists: $Updates{$Lists}{updates} Time(s)\n"; | |
71 | } | |
72 | } | |
73 | ||
74 | if (keys %Errors) | |
75 | { | |
76 | print "\nThe following errors were detected:\n"; | |
77 | ||
78 | foreach my $Text (keys %Errors) | |
79 | { | |
80 | print " $Text: $Errors{$Text} Time(s)\n"; | |
81 | } | |
82 | } | |
83 | ||
84 | exit(0); | |
85 | ||
86 | # vi: shiftwidth=3 tabstop=3 syntax=perl et | |
87 | # Local Variables: | |
88 | # mode: perl | |
89 | # perl-indent-level: 3 | |
90 | # indent-tabs-mode: nil | |
91 | # End: |