File: clamav-milter

package info (click to toggle)
logwatch 7.14-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,572 kB
  • sloc: perl: 8,290; sh: 354; makefile: 38
file content (136 lines) | stat: -rw-r--r-- 4,977 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

########################################################
# Please file all bug reports, patches, and feature
# requests under:
#      https://sourceforge.net/p/logwatch/_list/tickets
# Help requests and discusion can be filed under:
#      https://sourceforge.net/p/logwatch/discussion/
########################################################

########################################################
#
# Written by S. Schimkat <www.schimkat.dk>.
#
# Find latest version here: www.schimkat.dk/clamav
#
########################################################

########################################################
## Copyright (c) 2008 S. Schimkat
## Covered under the included MIT/X-Consortium License:
##    http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms.  If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions.  If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################
use strict;

my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'};
my $IgnoreUnmatched = $ENV{'clamav_ignoreunmatched'} || 0;

#Init Counters
my (
$CleanMessage,      $DaemonStart,       $DaemonStop,
$DatabaseReloads,   $DatabaseViruses
);
#Init Hashes
my (
%MaxChildrenLimit,      %OtherList,     %VirusList
);
while (defined(my $ThisLine = <STDIN>)) {

   chomp($ThisLine);
   if (
       ( $ThisLine =~ /^clamav-milter (startup|shutdown) succeeded$/ ) or
       ( $ThisLine =~ /^clamav-milter started at/i ) or
       ( $ThisLine =~ /^(WARNING: )?No clamd server appears to be available/i ) or
       ( $ThisLine =~ /^Database has changed, loading updated database/ ) or
       ( $ThisLine =~ /^Quarantined infected mail as/ ) or
       ( $ThisLine =~ /^\w+ quarantined as/ ) or
       ( $ThisLine =~ /^ClamAv: mi_stop/i ) or
       ( $ThisLine =~ m#^\/tmp\/clamav-.* .* FOUND# ) or
       # These two go along with "max-children limit" so we ignore them
       ( $ThisLine =~ /n_children \d+: waiting \d+ seconds for some to exit/ ) or
       ( $ThisLine =~ /Finished waiting, n_children = \d+/ ) or
       # These 3 precede "correctly reloaded" (we hope)
       # - Toss-up: Keep "correctly reloaded" or "Protecting against"?
       ( $ThisLine =~ /^Database has changed, loading updated database/ ) or
       ( $ThisLine =~ /^Loaded ClamAV \d+\./ ) or
       ( $ThisLine =~ /^ClamAV: Protecting against \d+ viruses/ ) or
       0 ) {
       # We do not care about these.
   } elsif (($ThisLine =~ /clean message from/)) {
      $CleanMessage++;
   } elsif (($ThisLine =~ /.*: (.+?) Intercepted virus/i ) or
            ($ThisLine =~ /Message from .* to .* infected by (.+)/)) {
      $VirusList{$1}++;
   } elsif (my ($ChildLimit) = ($ThisLine =~ /hit max-children limit \((\d+ >= \d+)\): waiting for some to exit/)) {
      $MaxChildrenLimit{$ChildLimit}++;
   } elsif (($ThisLine =~ /^Stopping|ClamAV=terminating/)) {
      $DaemonStop++;
   } elsif (($ThisLine =~ /^(Starting|\+\+\+ Started)/)) {
      $DaemonStart++;
   } elsif (my ($Viruses) = ($ThisLine =~ /^Database correctly reloaded \((\d+) (signatures|viruses)\)/i )) {
      $DatabaseReloads++;
      $DatabaseViruses = $Viruses;
   } else {
      $OtherList{$ThisLine}++;
   }
}


if (($DaemonStop) and ($Detail >= 5)) {
   print "\nDaemon stopped: " . $DaemonStop . " Time(s)\n";
}

if (($DaemonStart) and ($Detail >= 5)) {
   print "\nDaemon started: " . $DaemonStart . " Time(s)\n";
}

if (($DatabaseReloads) and ($Detail >= 5)) {
   print "\nVirus database reloaded $DatabaseReloads time(s) (last time with $DatabaseViruses viruses)\n";
}

if (keys %MaxChildrenLimit) {
   print "\nHit max-children limit:\n";
   foreach my $Limit (sort {$a cmp $b} keys %MaxChildrenLimit) {
      print '   Limit ' . $Limit . ' children(s) exceeded ' . $MaxChildrenLimit{$Limit} . " Time(s)\n"
   }
}

if ($CleanMessage) {
   print "\nClean messages: " . $CleanMessage . " Message(s)\n";
}

if (keys %VirusList) {
   my $Total = 0;
   print "\nInfected messages:\n";
   foreach my $Virus (sort {$a cmp $b} keys %VirusList) {
      print '   ' . $Virus . ": ". $VirusList{$Virus} . " Message(s)\n";
      $Total += $VirusList{$Virus};
   }
   print "  Total: $Total\n";
}

if ((keys %OtherList) and (not $IgnoreUnmatched)){
   print "\n**Unmatched Entries**\n";
   foreach my $line (sort {$OtherList{$b}<=>$OtherList{$a} } keys %OtherList) {
      print "\n   $line: $OtherList{$line} Time(s)";
   }
}

exit(0);

# vi: shiftwidth=3 tabstop=3 syntax=perl et
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End: