| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Cisco::IronPort; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24827
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
29
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
882
|
use LWP; |
|
|
1
|
|
|
|
|
54521
|
|
|
|
1
|
|
|
|
|
37
|
|
|
7
|
1
|
|
|
1
|
|
18
|
use Carp qw(croak); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
507
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
|
10
|
|
|
|
|
|
|
our @RANGES = qw (current_hour current_day current_week); |
|
11
|
|
|
|
|
|
|
our %M_MAP = ( |
|
12
|
|
|
|
|
|
|
internal_user_details => { |
|
13
|
|
|
|
|
|
|
report_def_id => 'mga_internal_users', |
|
14
|
|
|
|
|
|
|
report_query_id => 'mga_internal_users_user_monitoring', |
|
15
|
|
|
|
|
|
|
sortby => 'internal_user' |
|
16
|
|
|
|
|
|
|
}, |
|
17
|
|
|
|
|
|
|
top_users_by_clean_outgoing_messages => { |
|
18
|
|
|
|
|
|
|
report_query_id => 'mga_internal_users_top_outgoing_messages', |
|
19
|
|
|
|
|
|
|
report_def_id => 'mga_internal_users', |
|
20
|
|
|
|
|
|
|
sortby => 'internal_user' |
|
21
|
|
|
|
|
|
|
}, |
|
22
|
|
|
|
|
|
|
incoming_mail_summary => { |
|
23
|
|
|
|
|
|
|
report_query_id => 'mga_overview_incoming_mail_summary', |
|
24
|
|
|
|
|
|
|
report_def_id => 'mga_overview', |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
incoming_mail_details => { |
|
27
|
|
|
|
|
|
|
report_query_id => 'mga_incoming_mail_domain_search', |
|
28
|
|
|
|
|
|
|
report_def_id => 'mga_incoming_mail', |
|
29
|
|
|
|
|
|
|
sortby => 'sender_domain' |
|
30
|
|
|
|
|
|
|
}, |
|
31
|
|
|
|
|
|
|
average_time_in_workqueue => { |
|
32
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_average_time_workqueue', |
|
33
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
34
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
|
|
|
|
|
|
average_messages_in_workqueue => { |
|
37
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_average_messages_workqueue', |
|
38
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
39
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
40
|
|
|
|
|
|
|
}, |
|
41
|
|
|
|
|
|
|
maximum_messages_in_workqueue => { |
|
42
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_max_messages_workqueue', |
|
43
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
44
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
45
|
|
|
|
|
|
|
}, |
|
46
|
|
|
|
|
|
|
total_incoming_connections => { |
|
47
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_total_incoming_connections', |
|
48
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
49
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
50
|
|
|
|
|
|
|
}, |
|
51
|
|
|
|
|
|
|
total_incoming_messages => { |
|
52
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_total_incoming_messages', |
|
53
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
54
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
55
|
|
|
|
|
|
|
}, |
|
56
|
|
|
|
|
|
|
average_incoming_message_size => { |
|
57
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_average_incoming_message_size', |
|
58
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
59
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
60
|
|
|
|
|
|
|
}, |
|
61
|
|
|
|
|
|
|
total_incoming_message_size => { |
|
62
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_total_incoming_message_size', |
|
63
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
64
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
65
|
|
|
|
|
|
|
}, |
|
66
|
|
|
|
|
|
|
total_outgoing_connections => { |
|
67
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_total_outgoing_connections', |
|
68
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
69
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
70
|
|
|
|
|
|
|
}, |
|
71
|
|
|
|
|
|
|
total_outgoing_messages => { |
|
72
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_total_outgoing_messages', |
|
73
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
74
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
75
|
|
|
|
|
|
|
}, |
|
76
|
|
|
|
|
|
|
total_outgoing_message_size => { |
|
77
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_total_outgoing_message_size', |
|
78
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
79
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
80
|
|
|
|
|
|
|
}, |
|
81
|
|
|
|
|
|
|
average_outgoing_message_size => { |
|
82
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_average_outgoing_message_size', |
|
83
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
84
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
85
|
|
|
|
|
|
|
}, |
|
86
|
|
|
|
|
|
|
overall_cpu_usage => { |
|
87
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_overall_cpu_usage', |
|
88
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
89
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
90
|
|
|
|
|
|
|
}, |
|
91
|
|
|
|
|
|
|
cpu_by_function => { |
|
92
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_cpu_by_function', |
|
93
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
94
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
95
|
|
|
|
|
|
|
}, |
|
96
|
|
|
|
|
|
|
memory_page_swapping => { |
|
97
|
|
|
|
|
|
|
report_query_id => 'mga_system_capacity_swap_page_out', |
|
98
|
|
|
|
|
|
|
report_def_id => 'mga_system_capacity', |
|
99
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
100
|
|
|
|
|
|
|
}, |
|
101
|
|
|
|
|
|
|
top_incoming_virus_types_detected => { |
|
102
|
|
|
|
|
|
|
report_def_id => 'mga_virus_types', |
|
103
|
|
|
|
|
|
|
report_query_id => 'mga_virus_types_top_incoming_virus_types', |
|
104
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
105
|
|
|
|
|
|
|
}, |
|
106
|
|
|
|
|
|
|
top_outgoing_content_filter_matches => { |
|
107
|
|
|
|
|
|
|
report_def_id => 'mga_content_filters', |
|
108
|
|
|
|
|
|
|
report_query_id => 'mga_content_filters_top_outgoing_cf_matches', |
|
109
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
110
|
|
|
|
|
|
|
}, |
|
111
|
|
|
|
|
|
|
top_incoming_content_filter_matches => { |
|
112
|
|
|
|
|
|
|
report_def_id => 'mga_content_filters', |
|
113
|
|
|
|
|
|
|
report_query_id => 'mga_content_filters_top_incoming_cf_matches', |
|
114
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
115
|
|
|
|
|
|
|
}, |
|
116
|
|
|
|
|
|
|
incoming_content_filter_matches => { |
|
117
|
|
|
|
|
|
|
report_def_id => 'mga_content_filters', |
|
118
|
|
|
|
|
|
|
report_query_id => 'mga_content_filters_incoming_cf_matches', |
|
119
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
120
|
|
|
|
|
|
|
}, |
|
121
|
|
|
|
|
|
|
outgoing_content_filter_matches => { |
|
122
|
|
|
|
|
|
|
report_def_id => 'mga_content_filters', |
|
123
|
|
|
|
|
|
|
report_query_id => 'mga_content_filters_outgoing_cf_matches', |
|
124
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
125
|
|
|
|
|
|
|
}, |
|
126
|
|
|
|
|
|
|
content_filter_detail => { |
|
127
|
|
|
|
|
|
|
filter_type => 'outgoing', |
|
128
|
|
|
|
|
|
|
param => 'filter_name', |
|
129
|
|
|
|
|
|
|
report => 'content_filter_detail', |
|
130
|
|
|
|
|
|
|
report_def_id => 'mga_content_filter_detail', |
|
131
|
|
|
|
|
|
|
report_query_id => 'mga_content_filter_detail_content_filter_by_user', |
|
132
|
|
|
|
|
|
|
sortby => 'begin_timestamp' |
|
133
|
|
|
|
|
|
|
}, |
|
134
|
|
|
|
|
|
|
outgoing_delivery_status => { |
|
135
|
|
|
|
|
|
|
report_def_id => 'mga_outgoing_delivery_status', |
|
136
|
|
|
|
|
|
|
report_query_id => 'mga_outgoing_delivery_status_status_table', |
|
137
|
|
|
|
|
|
|
sortby => 'destination_domain' |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# profile_type=all |
|
141
|
|
|
|
|
|
|
# format=csv |
|
142
|
|
|
|
|
|
|
# report_query_id=mga_system_capacity_average_messages_workqueue |
|
143
|
|
|
|
|
|
|
# date_range=current_day |
|
144
|
|
|
|
|
|
|
# report_def_id=mga_system_capacity |
|
145
|
|
|
|
|
|
|
# mga_system_capacity_average_messages_workqueue' |
|
146
|
|
|
|
|
|
|
); |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub new { |
|
149
|
0
|
|
|
0
|
1
|
|
my($class, %args) = @_; |
|
150
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
|
151
|
0
|
0
|
|
|
|
|
defined $args{server} ? $self->{server} = $args{server} : croak 'Constructor failed: server not defined'; |
|
152
|
0
|
0
|
|
|
|
|
defined $args{username} ? $self->{username} = $args{username} : croak 'Constructor failed: username not defined'; |
|
153
|
0
|
0
|
|
|
|
|
defined $args{password} ? $self->{password} = $args{password} : croak 'Constructor failed: password not defined'; |
|
154
|
0
|
|
0
|
|
|
|
$self->{proto} = ($args{proto} or 'https'); |
|
155
|
0
|
|
|
|
|
|
$self->{ua} = LWP::UserAgent->new ( ssl_opts => { verify_hostname => 0 } ); |
|
156
|
0
|
|
|
|
|
|
$self->{uri} = $self->{proto}.'://'.$self->{username}.':'.$self->{password}.'@'.$self->{server}.'/monitor/reports/'; |
|
157
|
0
|
|
|
|
|
|
return $self |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
{ |
|
161
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1205
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
foreach my $m (keys %M_MAP) { |
|
164
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::__' . $m } = sub { |
|
165
|
0
|
|
|
0
|
|
|
my ($self,$args) = @_; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
return ( exists $M_MAP{$m}{param} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
? $self->__request("$M_MAP{$m}{report}?format=csv&date_range=$args->{date_range}" |
|
170
|
|
|
|
|
|
|
. "&report_query_id=$M_MAP{$m}{report_query_id}" |
|
171
|
|
|
|
|
|
|
. "&report_def_id=$M_MAP{$m}{report_def_id}" |
|
172
|
|
|
|
|
|
|
. "&filter_type=outgoing&filter_name=$args->{filter_name}") |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
: $self->__request("report?format=csv&date_range=$args->{date_range}" |
|
175
|
|
|
|
|
|
|
. "&report_query_id=$M_MAP{$m}{report_query_id}" |
|
176
|
|
|
|
|
|
|
. "&report_def_id=$M_MAP{$m}{report_def_id}&profile_type=all") |
|
177
|
|
|
|
|
|
|
) |
|
178
|
|
|
|
|
|
|
}; |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
foreach my $range (@RANGES) { |
|
181
|
|
|
|
|
|
|
my $p = ($m =~ /summary/ ? '__parse_summary' : '__parse_statistics'); |
|
182
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $m . '_' . $range } = sub { |
|
183
|
0
|
|
|
0
|
|
|
my ($self,$args) = @_; |
|
184
|
0
|
|
|
|
|
|
$args->{date_range} = $range; |
|
185
|
0
|
|
|
|
|
|
my $f = '__'.$m; |
|
186
|
0
|
|
|
|
|
|
return $p->($self->$f($args), $M_MAP{$m}{sortby}) |
|
187
|
|
|
|
|
|
|
}; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $m . '_' . $range . '_raw' } = sub { |
|
190
|
0
|
|
|
0
|
|
|
my ($self,$args) = @_; |
|
191
|
0
|
|
|
|
|
|
$args->{date_range} = $range; |
|
192
|
0
|
|
|
|
|
|
my $f = '__'.$m; |
|
193
|
0
|
|
|
|
|
|
return $self->$f($args) |
|
194
|
|
|
|
|
|
|
}; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub __request { |
|
200
|
0
|
|
|
0
|
|
|
my($self,$uri) = @_; |
|
201
|
0
|
|
|
|
|
|
my $res = $self->{ua}->get($self->{uri}.$uri); |
|
202
|
0
|
0
|
|
|
|
|
$res->is_success and return $res->content; |
|
203
|
0
|
|
|
|
|
|
$self->{error} = 'Unable to retrieve content: ' . $res->status_line; |
|
204
|
0
|
|
|
|
|
|
return 0 |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub __parse_statistics { |
|
208
|
0
|
|
|
0
|
|
|
my ($d, $s) = @_; |
|
209
|
0
|
|
|
|
|
|
my @d = split /\n/, $d; |
|
210
|
0
|
|
|
|
|
|
my %res; |
|
211
|
0
|
|
|
|
|
|
my @headers = map { s/ /_/g; s/\s*$//g; lc $_ } (split /,/, shift @d); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
my ($index) = grep { $headers[$_] eq $s } 0..$#headers; |
|
|
0
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
foreach (@d) { |
|
215
|
0
|
|
|
|
|
|
my $c = 0; |
|
216
|
0
|
|
|
|
|
|
my @cols = split /,/; |
|
217
|
0
|
|
|
|
|
|
$cols[-1] =~ s/\s*$//; |
|
218
|
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
foreach (@cols) { |
|
220
|
0
|
0
|
|
|
|
|
if (not defined $res{$cols[$index]}{$headers[$c]}) { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
$res{$cols[$index]}{$headers[$c]} = $_ |
|
222
|
|
|
|
|
|
|
} |
|
223
|
|
|
|
|
|
|
elsif ( $headers[$c] =~ /end_(timestamp|date)/ ) { |
|
224
|
0
|
|
|
|
|
|
$res{$cols[$index]}{$headers[$c]} = (sort { $b cmp $a } ($_, $res{$cols[$index]}{$headers[$c]}))[0] |
|
|
0
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
elsif ( $headers[$c] =~ /begin_(timestamp|date)/ ) { |
|
227
|
0
|
|
|
|
|
|
$res{$cols[$index]}{$headers[$c]} = (sort { $a cmp $b } ($_, $res{$cols[$index]}{$headers[$c]}))[0] |
|
|
0
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
elsif ( $headers[$c] =~ /(sender_domain|orig_value|internal_user)/ ) { |
|
230
|
0
|
|
|
|
|
|
$res{$cols[$index]}{$headers[$c]} = $_ |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
elsif ( $headers[$c] =~ /virus_type/ ) { |
|
233
|
0
|
|
|
|
|
|
$res{$cols[$index]}{$headers[$c]} .= ",$_" |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
else { |
|
236
|
0
|
|
|
|
|
|
$res{$cols[$index]}{$headers[$c]} += $_ |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
$c++ |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
0
|
|
|
|
|
|
return %res |
|
244
|
|
|
|
|
|
|
} |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub __parse_summary { |
|
247
|
0
|
|
|
0
|
|
|
my $d = shift; |
|
248
|
0
|
|
|
|
|
|
my @d = split /\n/, $d; |
|
249
|
0
|
|
|
|
|
|
my %res; |
|
250
|
0
|
|
|
|
|
|
my @headers = map { s/ /_/g; s/\s*$//g; lc $_ } (split /,/, $d[0]); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
|
my @percent = split /,/, $d[1]; $percent[-1] =~ s/\s*$//g; |
|
|
0
|
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
my @count = split /,/, $d[2]; $count[-1] =~ s/\s*$//g; |
|
|
0
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
my $c = 0; |
|
255
|
0
|
|
|
|
|
|
foreach my $h (@headers) { |
|
256
|
0
|
|
|
|
|
|
$percent[$c] =~ s/--/100/; |
|
257
|
0
|
|
|
|
|
|
$res{$h}{'percent'}= $percent[$c]; |
|
258
|
0
|
|
|
|
|
|
$res{$h}{'count'} = $count[$c]; |
|
259
|
0
|
|
|
|
|
|
$c++ |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
return %res |
|
263
|
|
|
|
|
|
|
} |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
1; |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
__END__ |