File Coverage

blib/lib/Regexp/Log/WMS.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Regexp::Log::WMS;
2              
3 1     1   22885 use strict;
  1         2  
  1         32  
4 1     1   5 use base qw( Regexp::Log );
  1         2  
  1         837  
5 1     1   1519 use vars qw( $VERSION %DEFAULT %FORMAT %REGEXP );
  1         5  
  1         321  
6              
7             $VERSION = 0.02;
8              
9              
10             =head1 NAME
11              
12             Regexp::Log::WMS - A regular expression parser for WMS
13             log format.
14              
15             =head1 SYNOPSIS
16              
17             my $foo = Regexp::Log::Common->new(
18             format => 'custom %date %cs_uri_stem',
19             capture => [qw( date request )],
20             );
21              
22             # the format() and capture() methods can be used to set or get
23             $foo->format('custom %date %cs_uri_stem %c_rate %c_status');
24             $foo->capture(qw( date cs_uri_stem ));
25              
26             # this is necessary to know in which order
27             # we will receive the captured fields from the regexp
28             my @fields = $foo->capture;
29              
30             # the all-powerful capturing regexp :-)
31             my $re = $foo->regexp;
32              
33             while (<>) {
34             my %data;
35             @data{@fields} = /$re/; # no need for /o, it's a compiled regexp
36              
37             # now munge the fields
38             ...
39             }
40              
41             =head1 DESCRIPTION
42              
43             Regexp::Log::WMS uses Regexp::Log as a base class, to generate regular
44             expressions for performing the usual data munging tasks on log files that
45             cannot be simply split().
46              
47             This specific module enables the computation of regular expressions for
48             parsing the log files created by WMS.
49              
50             For more information on how to use this module, please see Regexp::Log.
51              
52             =head1 ABSTRACT
53              
54             Regexp::Log::WMS enables simple parsing of log files created by WMS.
55              
56             =cut
57              
58              
59             # default values
60             %DEFAULT = ( format => ( '%c_ip %date %c_dns %cs_uri_stem %c_starttime '.
61             '%x_duration %c_rate %c_status %c_playerid %c_playerversion '.
62             '%c_playerlanguage %cs_user_agent %cs_referer %c_hostexe '.
63             '%c_hostexever %c_os %c_osversion %c_cpu %filelength %filesize '.
64             '%avgbandwidth %protocol %transport %audiocodec %videocodec '.
65             '%channelURL %sc_bytes %c_bytes %s_pkts_sent %c_pkts_received '.
66             '%c_pkts_lost_client %c_pkts_lost_net %c_pkts_lost_cont_net '.
67             '%c_resendreqs %c_pkts_recovered_ECC %c_pkts_recovered_resent '.
68             '%c_buffercount %c_totalbuffertime %c_quality %s_ip %s_dns '.
69             '%s_totalclients %s_cpu_util'),
70              
71             capture => [qw(c_ip date c_dns cs_uri_stem
72             c_starttime x_duration c_rate c_status c_playerid
73             c_playerversion c_playerlanguage cs_user_agent cs_referer
74             c_hostexe c_hostexever c_os c_osversion c_cpu filelength
75             filesize avgbandwidth protocol transport audiocodec
76             videocodec channelURL sc_bytes c_bytes s_pkts_sent
77             c_pkts_received c_pkts_lost_client c_pkts_lost_net
78             c_pkts_lost_cont_net c_resendreqs c_pkts_recovered_ECC
79             c_pkts_recovered_resent c_buffercount c_totalbuffertime
80             c_quality s_ip s_dns s_totalclients s_cpu_util)] );
81              
82              
83             # predefined format strings
84             %FORMAT = (
85             ':default' => $DEFAULT{format},
86             ':common' => $DEFAULT{format},
87             );
88              
89             # the regexps that match the various fields
90             %REGEXP = ( '%c_ip' => '(?#=c_ip)\S+(?#!c_ip)',
91             '%date' => '(?#=date)\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?#!date)',
92             '%c_dns' => '(?#=c_dns).*?(?#!c_dns)',
93             '%cs_uri_stem' => '(?#=cs_uri_stem).*?(?#!cs_uri_stem)',
94             '%c_starttime' => '(?#=c_starttime).*?(?#!c_starttime)',
95             '%x_duration' => '(?#=x_duration).*?(?#!x_duration)',
96             '%c_rate' => '(?#=c_rate).*?(?#!c_rate)',
97             '%c_status' => '(?#=c_status).*?(?#!c_status)',
98             '%c_playerid' => '(?#=c_playerid).*?(?#!c_playerid)',
99             '%c_playerversion' => '(?#=c_playerversion).*?(?#!c_playerversion)',
100             '%c_playerlanguage' => '(?#=c_playerlanguage).*?(?#!c_playerlanguage)',
101             '%cs_user_agent' => '(?#=cs_user_agent).*?(?#!cs_user_agent)',
102             '%cs_referer' => '(?#=cs_referer).*?(?#!cs_referer)',
103             '%c_hostexe' => '(?#=c_hostexe).*?(?#!c_hostexe)',
104             '%c_hostexever' => '(?#=c_hostexever).*?(?#!c_hostexever)',
105             '%c_os' => '(?#=c_os).*?(?#!c_os)',
106             '%c_osversion' => '(?#=c_osversion).*?(?#!c_osversion)',
107             '%c_cpu' => '(?#=c_cpu).*?(?#!c_cpu)',
108             '%filelength' => '(?#=filelength).*?(?#!filelength)',
109             '%filesize' => '(?#=filesize).*?(?#!filesize)',
110             '%avgbandwidth' => '(?#=avgbandwidth).*?(?#!avgbandwidth)',
111             '%protocol' => '(?#=protocol).*?(?#!protocol)',
112             '%transport' => '(?#=transport).*?(?#!transport)',
113             '%audiocodec' => '(?#=audiocodec).*?(?#!audiocodec)',
114             '%videocodec' => '(?#=videocodec).*?(?#!videocodec)',
115             '%channelURL' => '(?#=channelURL).*?(?#!channelURL)',
116             '%sc_bytes' => '(?#=sc_bytes).*?(?#!sc_bytes)',
117             '%c_bytes' => '(?#=c_bytes).*?(?#!c_bytes)',
118             '%s_pkts_sent' => '(?#=s_pkts_sent).*?(?#!s_pkts_sent)',
119             '%c_pkts_received' => '(?#=c_pkts_received).*?(?#!c_pkts_received)',
120             '%c_pkts_lost_client' => '(?#=c_pkts_lost_client).*?(?#!c_pkts_lost_client)',
121             '%c_pkts_lost_net' => '(?#=c_pkts_lost_net).*?(?#!c_pkts_lost_net)',
122             '%c_pkts_lost_cont_net' => '(?#=c_pkts_lost_cont_net).*?(?#!c_pkts_lost_cont_net)',
123             '%c_resendreqs' => '(?#=c_resendreqs).*?(?#!c_resendreqs)',
124             '%c_pkts_recovered_ECC' => '(?#=c_pkts_recovered_ECC).*?(?#!c_pkts_recovered_ECC)',
125             '%c_pkts_recovered_resent' => '(?#=c_pkts_recovered_resent).*?(?#!c_pkts_recovered_resent)',
126             '%c_buffercount' => '(?#=c_buffercount).*?(?#!c_buffercount)',
127             '%c_totalbuffertime' => '(?#=c_totalbuffertime).*?(?#!c_totalbuffertime)',
128             '%c_quality' => '(?#=c_quality).*?(?#!c_quality)',
129             '%s_ip' => '(?#=s_ip).*?(?#!s_ip)',
130             '%s_dns' => '(?#=s_dns).*?(?#!s_dns)',
131             '%s_totalclients' => '(?#=s_totalclients).*?(?#!s_totalclients)',
132             '%s_cpu_util' => '(?#=s_cpu_util).*?(?#!s_cpu_util)' );
133              
134              
135             1;
136              
137             __END__