Regexp::Log::RealServer - A regular expression parser for RealServer


Regexp-Log-RealServer documentation Contained in the Regexp-Log-RealServer distribution.

Index


Code Index:

NAME

Top

Regexp::Log::RealServer - A regular expression parser for RealServer log format.

SYNOPSIS

Top

    my $foo = Regexp::Log::Common->new(
        format  => 'custom %date %cs_uri_stem',
        capture => [qw( date request )],
    );

    # the format() and capture() methods can be used to set or get
    $foo->format('custom %date %cs_uri_stem %c_rate %c_status');
    $foo->capture(qw( date cs_uri_stem ));

    # this is necessary to know in which order
    # we will receive the captured fields from the regexp
    my @fields = $foo->capture;

    # the all-powerful capturing regexp :-)
    my $re = $foo->regexp;

    while (<>) {
        my %data;
        @data{@fields} = /$re/;    # no need for /o, it's a compiled regexp

        # now munge the fields
        ...
    }

DESCRIPTION

Top

Regexp::Log::RealServer uses Regexp::Log as a base class, to generate regular expressions for performing the usual data munging tasks on log files that cannot be simply split().

This specific module enables the computation of regular expressions for parsing the log files created by RealServer.

For more information on how to use this module, please see Regexp::Log.

ABSTRACT

Top

Regexp::Log::RealServer enables simple parsing of log files created by RealServer.

LOG FORMAT

Top

RealServer Log Format

    my $foo = Regexp::Log::RealServer->new( format  => ':common' );

The RealServer Log Format is made up of several fields, each delimited by a single space.

* Fields:
  c_ip date c_dns cs_uri_stem c_starttime x_duration c_rate c_status
  c_playerid c_playerversion c_playerlanguage cs_user_agent cs_referer
  c_hostexe c_hostexever c_os c_osversion c_cpu filelength filesize
  avgbandwidth protocol transport audiocodec videocodec channelURL
  sc_bytes c_bytes s_pkts_sent c_pkts_received c_pkts_lost_client
  c_pkts_lost_net c_pkts_lost_cont_net c_resendreqs
  c_pkts_recovered_ECC c_pkts_recovered_resent c_buffercount
  c_totalbuffertime c_quality s_ip s_dns s_totalclients s_cpu_util

BUGS, PATCHES & FIXES

Top

This is a very early release of this module, so maybe you will find some bugs there, report them to me (including a patch if possible) and I will try to correct it as soon as possible.

The regular expresions generated are not specially efficient.

SEE ALSO

Top

Regexp::Log, Regexp::Log::Common, Regexp::Log::WMS

AUTHOR

Top

Salvador Fandiño <sfandino@yahoo.com>.

Based on Regexp::Log::Common by Barbie <barbie@cpan.org>.

COPYRIGHT AND LICENSE

Top


Regexp-Log-RealServer documentation Contained in the Regexp-Log-RealServer distribution.
package Regexp::Log::RealServer;

use strict;
use base qw( Regexp::Log );
use vars qw( $VERSION %DEFAULT %FORMAT %REGEXP );

$VERSION = 0.02;

# default values
%DEFAULT = ( format => (q(%c_ip %date %c_dns %cs_uri_stem %c_starttime %x_duration %c_rate ).
			q(%c_status %c_playerid %c_playerversion %c_playerlanguage ).
			q(%cs_user_agent %cs_referer %c_hostexe %c_hostexever %c_os %c_osversion ).
			q(%c_cpu %filelength %filesize %avgbandwidth %protocol %transport ).
			q(%audiocodec %videocodec %channelURL %sc_bytes %c_bytes %s_pkts_sent ).
			q(%c_pkts_received %c_pkts_lost_client %c_pkts_lost_net ).
			q(%c_pkts_lost_cont_net %c_resendreqs %c_pkts_recovered_ECC ).
			q(%c_pkts_recovered_resent %c_buffercount %c_totalbuffertime %c_quality ).
			q(%s_ip %s_dns %s_totalclients %s_cpu_util)),

	     capture => [qw(c_ip date c_dns cs_uri_stem c_starttime x_duration c_rate
			    c_status c_playerid c_playerversion c_playerlanguage cs_user_agent
			    cs_referer c_hostexe c_hostexever c_os c_osversion c_cpu filelength
			    filesize avgbandwidth protocol transport audiocodec videocodec
			    channelURL sc_bytes c_bytes s_pkts_sent c_pkts_received
			    c_pkts_lost_client c_pkts_lost_net c_pkts_lost_cont_net c_resendreqs
			    c_pkts_recovered_ECC c_pkts_recovered_resent c_buffercount
			    c_totalbuffertime c_quality s_ip s_dns s_totalclients s_cpu_util)]);

# predefined format strings
%FORMAT = (
	':default'  => $DEFAULT{format},
	':common'   => $DEFAULT{format},
);

# the regexps that match the various fields
%REGEXP = ( '%c_ip' => '(?#=c_ip)\S+(?#!c_ip)',
	    '%date' => '(?#=date)\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?#!date)',
	    '%c_dns' => '(?#=c_dns).*?(?#!c_dns)',
	    '%cs_uri_stem' => '(?#=cs_uri_stem).*?(?#!cs_uri_stem)',
	    '%c_starttime' => '(?#=c_starttime).*?(?#!c_starttime)',
	    '%x_duration' => '(?#=x_duration).*?(?#!x_duration)',
	    '%c_rate' => '(?#=c_rate).*?(?#!c_rate)',
	    '%c_status' => '(?#=c_status).*?(?#!c_status)',
	    '%c_playerid' => '(?#=c_playerid).*?(?#!c_playerid)',
	    '%c_playerversion' => '(?#=c_playerversion).*?(?#!c_playerversion)',
	    '%c_playerlanguage' => '(?#=c_playerlanguage).*?(?#!c_playerlanguage)',
	    '%cs_user_agent' => '(?#=cs_user_agent).*?(?#!cs_user_agent)',
	    '%cs_referer' => '(?#=cs_referer).*?(?#!cs_referer)',
	    '%c_hostexe' => '(?#=c_hostexe).*?(?#!c_hostexe)',
	    '%c_hostexever' => '(?#=c_hostexever).*?(?#!c_hostexever)',
	    '%c_os' => '(?#=c_os).*?(?#!c_os)',
	    '%c_osversion' => '(?#=c_osversion).*?(?#!c_osversion)',
	    '%c_cpu' => '(?#=c_cpu).*?(?#!c_cpu)',
	    '%filelength' => '(?#=filelength).*?(?#!filelength)',
	    '%filesize' => '(?#=filesize).*?(?#!filesize)',
	    '%avgbandwidth' => '(?#=avgbandwidth).*?(?#!avgbandwidth)',
	    '%protocol' => '(?#=protocol).*?(?#!protocol)',
	    '%transport' => '(?#=transport).*?(?#!transport)',
	    '%audiocodec' => '(?#=audiocodec).*?(?#!audiocodec)',
	    '%videocodec' => '(?#=videocodec).*?(?#!videocodec)',
	    '%channelURL' => '(?#=channelURL).*?(?#!channelURL)',
	    '%sc_bytes' => '(?#=sc_bytes).*?(?#!sc_bytes)',
	    '%c_bytes' => '(?#=c_bytes).*?(?#!c_bytes)',
	    '%s_pkts_sent' => '(?#=s_pkts_sent).*?(?#!s_pkts_sent)',
	    '%c_pkts_received' => '(?#=c_pkts_received).*?(?#!c_pkts_received)',
	    '%c_pkts_lost_client' => '(?#=c_pkts_lost_client).*?(?#!c_pkts_lost_client)',
	    '%c_pkts_lost_net' => '(?#=c_pkts_lost_net).*?(?#!c_pkts_lost_net)',
	    '%c_pkts_lost_cont_net' => '(?#=c_pkts_lost_cont_net).*?(?#!c_pkts_lost_cont_net)',
	    '%c_resendreqs' => '(?#=c_resendreqs).*?(?#!c_resendreqs)',
	    '%c_pkts_recovered_ECC' => '(?#=c_pkts_recovered_ECC).*?(?#!c_pkts_recovered_ECC)',
	    '%c_pkts_recovered_resent' => '(?#=c_pkts_recovered_resent).*?(?#!c_pkts_recovered_resent)',
	    '%c_buffercount' => '(?#=c_buffercount).*?(?#!c_buffercount)',
	    '%c_totalbuffertime' => '(?#=c_totalbuffertime).*?(?#!c_totalbuffertime)',
	    '%c_quality' => '(?#=c_quality).*?(?#!c_quality)',
	    '%s_ip' => '(?#=s_ip).*?(?#!s_ip)',
	    '%s_dns' => '(?#=s_dns).*?(?#!s_dns)',
	    '%s_totalclients' => '(?#=s_totalclients).*?(?#!s_totalclients)',
	    '%s_cpu_util' => '(?#=s_cpu_util).*?(?#!s_cpu_util)');


1;

__END__