line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tail::Stat::Plugin::cvsupd; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Tail::Stat::Plugin::cvsupd - Statistics collector for CVSupd server |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1081
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
10
|
1
|
|
|
1
|
|
5
|
use warnings qw(all); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
tstatd cvsupd cvsupd.log |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 LOG FORMATS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Plugin search cvsupd logs for records of three types: |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item C |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
+1088 root@host.domain.com [CSUP_1_0/17.0] |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item C |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=1088 [2597Kin+1797Kout] ports-all/cvs |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item C |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
-1088 [2597Kin+1797Kout] Finished successfully |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=back |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 STATISTICS |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 Overall statistics |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=over |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item C |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Total number of received clients connections. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item C> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Total number of connections received with client I. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item C |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Total number of requsted collections. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item C> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Total number of updates of I. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=item C |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Total traffic received. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item C |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Total traffic sent. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item C> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Total number of disconnects with I. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
1
|
|
|
1
|
|
5
|
use base qw(Tail::Stat::Plugin); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
67
|
|
79
|
1
|
|
|
1
|
|
5
|
use List::Util qw(sum); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
539
|
|
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
1
|
|
sub regex { qr{ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
(?: |
84
|
|
|
|
|
|
|
(\+) # operation [0] |
85
|
|
|
|
|
|
|
(\d+) # connection [1] |
86
|
|
|
|
|
|
|
\s+ |
87
|
|
|
|
|
|
|
(\S+) # user [2] |
88
|
|
|
|
|
|
|
\@ |
89
|
|
|
|
|
|
|
(\S+) # host [3] |
90
|
|
|
|
|
|
|
\s+ |
91
|
|
|
|
|
|
|
\[([^\]]+)\] # version [4] |
92
|
|
|
|
|
|
|
| |
93
|
|
|
|
|
|
|
(=) # operation [5] |
94
|
|
|
|
|
|
|
(\d+) # connection [6] |
95
|
|
|
|
|
|
|
\s+ |
96
|
|
|
|
|
|
|
\[(\d+)Kin\+(\d+)Kout\] # traffic [7],[8] |
97
|
|
|
|
|
|
|
\s+ |
98
|
|
|
|
|
|
|
(\S+) # collection [9] |
99
|
|
|
|
|
|
|
| |
100
|
|
|
|
|
|
|
(-) # operation [10] |
101
|
|
|
|
|
|
|
(\d+) # connection [11] |
102
|
|
|
|
|
|
|
\s+ |
103
|
|
|
|
|
|
|
\[(\d+)Kin\+(\d+)Kout\] # traffic [12],[13] |
104
|
|
|
|
|
|
|
\s+ |
105
|
|
|
|
|
|
|
(.+) # status [14] |
106
|
|
|
|
|
|
|
) |
107
|
|
|
|
|
|
|
$ |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
}x } |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub process_data { |
113
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
114
|
0
|
|
|
|
|
|
my ($ref,$pub,$prv,$win) = @_; |
115
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
|
|
|
if ( $ref->[0] ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# connect |
118
|
0
|
|
|
|
|
|
$pub->{ clients }++; |
119
|
0
|
|
|
|
|
|
$win->{ clients }++; |
120
|
0
|
|
|
|
|
|
$pub->{ 'client:' . $ref->[4] }++; |
121
|
|
|
|
|
|
|
} elsif ( $ref->[5] ) { |
122
|
|
|
|
|
|
|
# collection |
123
|
0
|
|
|
|
|
|
$pub->{ collections }++; |
124
|
0
|
|
|
|
|
|
$win->{ collections }++; |
125
|
0
|
|
|
|
|
|
$ref->[9] =~ s{:}{_}g; |
126
|
0
|
|
|
|
|
|
$pub->{ 'collection:' . $ref->[9] }++; |
127
|
|
|
|
|
|
|
} elsif ( $ref->[10] ) { |
128
|
|
|
|
|
|
|
# disconnect |
129
|
0
|
|
|
|
|
|
$pub->{ bytes_in } += 1024 * $ref->[12]; |
130
|
0
|
|
|
|
|
|
$pub->{ bytes_out } += 1024 * $ref->[13]; |
131
|
0
|
|
|
|
|
|
$win->{ bytes_in } += 1024 * $ref->[12]; |
132
|
0
|
|
|
|
|
|
$win->{ bytes_out } += 1024 * $ref->[13]; |
133
|
0
|
|
|
|
|
|
$ref->[14] =~ s{:}{_}g; |
134
|
0
|
|
|
|
|
|
$pub->{ 'status:' . $ref->[14] }++; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub process_window { |
140
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
my ($pub,$prv,$wins) = @_; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
for my $m ( qw( clients collections bytes_in bytes_out ) ) { |
144
|
0
|
|
0
|
|
|
|
$pub->{'last_' . $m } = sum ( map { $_->{ $m } || 0 } @$wins ) || 0; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub stats_zone { |
150
|
0
|
|
|
0
|
1
|
|
my ($self,$zone,$pub,$prv,$wins) = @_; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# required keys defaults |
153
|
0
|
|
|
|
|
|
my %out = ( ( map { $_ => 0 } qw( |
|
0
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
clients |
155
|
|
|
|
|
|
|
collections |
156
|
|
|
|
|
|
|
bytes_in |
157
|
|
|
|
|
|
|
bytes_out |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
last_clients |
160
|
|
|
|
|
|
|
last_collections |
161
|
|
|
|
|
|
|
last_bytes_in |
162
|
|
|
|
|
|
|
last_bytes_out |
163
|
|
|
|
|
|
|
) ), %$pub ); |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
map { $_ . ': ' . $out{ $_ } } sort keys %out; |
|
0
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHOR |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Oleg A. Mamontov, C<< >> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 COPYRIGHT |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
177
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
178
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
1; |
185
|
|
|
|
|
|
|
|