line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Opentracker::Stats::Mode::Scrape; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
29542
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
21
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
|
|
6
|
use parent qw/ |
7
|
|
|
|
|
|
|
WWW::Opentracker::Stats::Mode |
8
|
|
|
|
|
|
|
Class::Accessor::Fast |
9
|
1
|
|
|
1
|
|
905
|
/; |
|
1
|
|
|
|
|
357
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->_format('txt'); |
13
|
|
|
|
|
|
|
__PACKAGE__->_mode('scrp'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/_stats/); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
WWW::Opentracker::Stats::Mode::Scrape |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Parses the scrape statistics from opentracker. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 parse_stats |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Args: $self, $payload |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Decodes the plain text data retrieved from the scrape statistics of opentracker. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The payload looks like this (no indentation): |
35
|
|
|
|
|
|
|
19 |
36
|
|
|
|
|
|
|
0 |
37
|
|
|
|
|
|
|
33275 seconds (9 hours) |
38
|
|
|
|
|
|
|
opentracker scrape stats, 1 scrape/s (tcp and udp) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub parse_stats { |
43
|
1
|
|
|
1
|
1
|
3
|
my ($self, $payload) = @_; |
44
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
15
|
my ($tcp_scrapes, $udp_scrapes, $seconds, $scrapes_per_sec) |
46
|
|
|
|
|
|
|
= $payload =~ m{\A |
47
|
|
|
|
|
|
|
(\d+) \s |
48
|
|
|
|
|
|
|
(\d+) \s |
49
|
|
|
|
|
|
|
(\d+) \s seconds \s \( \d+ \s hours \) \s |
50
|
|
|
|
|
|
|
opentracker \s scrape \s stats , \s |
51
|
|
|
|
|
|
|
(\d+) \s scrape/s \s |
52
|
|
|
|
|
|
|
}xms |
53
|
|
|
|
|
|
|
or die "Unable to parse payload: $payload"; |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
8
|
my %stats = ( |
56
|
|
|
|
|
|
|
'tcp_scrapes' => $tcp_scrapes, |
57
|
|
|
|
|
|
|
'udp_scrapes' => $udp_scrapes, |
58
|
|
|
|
|
|
|
'uptime' => $seconds, |
59
|
|
|
|
|
|
|
'scrapes_per_sec' => $scrapes_per_sec, |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
9
|
return \%stats; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SEE ALSO |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 AUTHOR |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Knut-Olav Hoven, Eknutolav@gmail.comE |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Copyright (C) 2009 by Knut-Olav Hoven |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
79
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
80
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
|