| 1 | package Tail::Stat::Plugin::icecast; | ||||||||||||
| 2 | |||||||||||||
| 3 | =head1 NAME | ||||||||||||
| 4 | |||||||||||||
| 5 | Tail::Stat::Plugin::icecast - Statistics collector for Icecast streaming server | ||||||||||||
| 6 | |||||||||||||
| 7 | =cut | ||||||||||||
| 8 | |||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 1 | ▶ | use warnings 'all'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | |||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||
| 14 | |||||||||||||
| 15 | tstatd icecast error.log | ||||||||||||
| 16 | |||||||||||||
| 17 | |||||||||||||
| 18 | =head1 LOG FORMATS | ||||||||||||
| 19 | |||||||||||||
| 20 | Plugin search icecast error logs for records like: | ||||||||||||
| 21 | |||||||||||||
| 22 | =over | ||||||||||||
| 23 | |||||||||||||
| 24 | =item C<listener count> | ||||||||||||
| 25 | |||||||||||||
| 26 | INFO source/source_main listener count on /mv128.mp3 now 73 | ||||||||||||
| 27 | |||||||||||||
| 28 | =back | ||||||||||||
| 29 | |||||||||||||
| 30 | |||||||||||||
| 31 | =head1 STATISTICS | ||||||||||||
| 32 | |||||||||||||
| 33 | =head2 Overall statistics | ||||||||||||
| 34 | |||||||||||||
| 35 | =over | ||||||||||||
| 36 | |||||||||||||
| 37 | =item C<online:I<stream>> | ||||||||||||
| 38 | |||||||||||||
| 39 | Current number of connected clients. | ||||||||||||
| 40 | |||||||||||||
| 41 | =item C<enter:I<stream>> | ||||||||||||
| 42 | |||||||||||||
| 43 | Total number of clients connects. | ||||||||||||
| 44 | |||||||||||||
| 45 | =item C<leave:I<stream>> | ||||||||||||
| 46 | |||||||||||||
| 47 | Total number of clients disconnects. | ||||||||||||
| 48 | |||||||||||||
| 49 | =back | ||||||||||||
| 50 | |||||||||||||
| 51 | =cut | ||||||||||||
| 52 | |||||||||||||
| 53 | |||||||||||||
| 54 | 1 | ▶ | use base 'Tail::Stat::Plugin'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 55 | |||||||||||||
| 56 | |||||||||||||
| 57 | 1 | ▶ | sub regex { qr{ | ||||||||||
|
Subroutine
regex: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 58 | |||||||||||||
| 59 | (?: | ||||||||||||
| 60 | INFO # just a marker | ||||||||||||
| 61 | \s+ | ||||||||||||
| 62 | source/source_main # is it same for all servers? | ||||||||||||
| 63 | \s+ | ||||||||||||
| 64 | listener\scount\son | ||||||||||||
| 65 | \s+ | ||||||||||||
| 66 | /(\S+) # stream [0] | ||||||||||||
| 67 | \s+ | ||||||||||||
| 68 | now | ||||||||||||
| 69 | \s+ | ||||||||||||
| 70 | (\d+) # users [1] | ||||||||||||
| 71 | ) | ||||||||||||
| 72 | $ | ||||||||||||
| 73 | |||||||||||||
| 74 | }x } | ||||||||||||
| 75 | |||||||||||||
| 76 | |||||||||||||
| 77 | sub process_data { | ||||||||||||
| 78 | 850 | ▶ | my $self = shift; | ||||||||||
|
Subroutine
process_data: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 79 | 850 | my ($ref,$pub,$prv,$win) = @_; | |||||||||||
| 80 | |||||||||||||
| 81 | 850 | ▶ | my $was = $pub->{ 'online:' . $ref->[0] } || 0; | ||||||||||
|
Condition100%2/2
$$pub{'online:' . $ref->[0]} || 0
MC/DC100%1/1
$$pub{'online:' . $ref->[0]} || 0
$$pub{'online:' . $ref->[0]}
Truth table100%2/2
A
A= $$pub{'online:' . $ref->[0]}
| |||||||||||||
| 82 | 850 | $pub->{ 'online:' . $ref->[0] } = $ref->[1]; | |||||||||||
| 83 | |||||||||||||
| 84 | 850 | ▶ | return $pub->{ 'enter:' . $ref->[0] } += $ref->[1] - $was | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 85 | if $ref->[1] > $was; | ||||||||||||
| 86 | 411 | ▶ | return $pub->{ 'leave:' . $ref->[0] } += $was - $ref->[1] | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 87 | if $ref->[1] < $was; | ||||||||||||
| 88 | } | ||||||||||||
| 89 | |||||||||||||
| 90 | |||||||||||||
| 91 | =head1 AUTHOR | ||||||||||||
| 92 | |||||||||||||
| 93 | Oleg A. Mamontov, C<< <oleg@mamontov.net> >> | ||||||||||||
| 94 | |||||||||||||
| 95 | |||||||||||||
| 96 | =head1 COPYRIGHT | ||||||||||||
| 97 | |||||||||||||
| 98 | This program is free software; you can redistribute it and/or modify it | ||||||||||||
| 99 | under the terms of either: the GNU General Public License as published | ||||||||||||
| 100 | by the Free Software Foundation; or the Artistic License. | ||||||||||||
| 101 | |||||||||||||
| 102 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||
| 103 | |||||||||||||
| 104 | =cut | ||||||||||||
| 105 | |||||||||||||
| 106 | 1 | 1; | |||||||||||
| 107 | |||||||||||||