line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SyslogScan::ByGroup; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = 0.20; |
4
|
0
|
|
|
0
|
|
|
sub Version { $VERSION }; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
990
|
use SyslogScan::Group; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use SyslogScan::Summary; |
8
|
|
|
|
|
|
|
use SyslogScan::Delivery; |
9
|
|
|
|
|
|
|
use strict; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Given an e-mail address, tries to return the internet domain name of |
12
|
|
|
|
|
|
|
# the host. Probably not a very reliable routine. |
13
|
|
|
|
|
|
|
my $pDefaultGroupingSubroutine = sub { |
14
|
|
|
|
|
|
|
my $address = shift; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$address =~ s/^\<(.+)\>$/$1/; |
17
|
|
|
|
|
|
|
if ($address =~ /^[^\@\!]+\@([^\@\!]+\.)?([^\.\@\!]+\.[^\.\@\!]+)$/) |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
return $2; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
if ($address !~ /[\@\!]/) |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
return 'localhost'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
return 'unknown'; |
26
|
|
|
|
|
|
|
}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new |
29
|
|
|
|
|
|
|
{ |
30
|
|
|
|
|
|
|
my $type = shift; |
31
|
|
|
|
|
|
|
my $summary = shift; |
32
|
|
|
|
|
|
|
my $pGroupingSubroutine = shift || $pDefaultGroupingSubroutine; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $self = {}; |
35
|
|
|
|
|
|
|
bless ($self,$type); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $address; |
38
|
|
|
|
|
|
|
foreach $address (keys %$summary) |
39
|
|
|
|
|
|
|
{ |
40
|
|
|
|
|
|
|
my $group = &$pGroupingSubroutine($address); |
41
|
|
|
|
|
|
|
next unless defined($group); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
if (! defined $$self{$group}) |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
$$self{$group} = new SyslogScan::Group(); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$$self{$group} -> registerUsage($address,$$summary{$address}); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $self; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub createSummary |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
my $summary = new SyslogScan::Summary(); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $groupName; |
61
|
|
|
|
|
|
|
foreach $groupName (keys %$self) |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
my $group = $$self{$groupName}; |
64
|
|
|
|
|
|
|
$$summary{$groupName} = $$group{groupUsage} -> deepCopy(); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
return $summary; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub dump |
70
|
|
|
|
|
|
|
{ |
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $retString; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $group; |
76
|
|
|
|
|
|
|
foreach $group (sort keys %$self) |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
$retString .= "$group TOTAL:\n"; |
79
|
|
|
|
|
|
|
$retString .= $$self{$group} -> dump(); |
80
|
|
|
|
|
|
|
$retString .= "\n"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
return $retString; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |