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