]>
Commit | Line | Data |
---|---|---|
5b8ace12 AJ |
1 | #!/usr/bin/perl -w |
2 | ||
3 | # | |
4 | # This is a simple module which takes in a Squid format logfile line and breaks it up into | |
5 | # a perl hash. | |
6 | # | |
7 | # I'm not going to pretend this is 100% accurate just yet but its a start. | |
8 | # I'm hoping that by placing it into the public domain it (and the other stuff | |
9 | # I sneak in here) will be debugged and improved by others. | |
10 | # | |
11 | # Adrian Chadd <adrian@squid-cache.org> | |
12 | # | |
13 | # $Id: ParseLog.pm,v 1.1 2007/01/24 06:50:35 adrian Exp $ | |
14 | # | |
15 | ||
16 | use strict; | |
17 | ||
18 | package Squid::ParseLog; | |
19 | ||
20 | sub parse($) { | |
21 | my ($line) = @_; | |
22 | my (%t); | |
23 | chomp $line; | |
24 | ||
25 | $line =~ m/^(.*?) (\d+?) (.*?) (.*?)\/(\d+?) (\d+?) (.*?) (.*?) (.*?) (.*?)\/(.*?) (.*)$/; | |
26 | ||
27 | $t{"timestamp"} = $1; | |
28 | $t{"reqtime"} = $2; | |
29 | $t{"clientip"} = $3; | |
30 | $t{"code"} = $4; | |
31 | $t{"httpcode"} = $5; | |
32 | $t{"size"} = $6; | |
33 | $t{"method"} = $7; | |
34 | $t{"url"} = $8; | |
35 | $t{"username"} = $9; | |
36 | $t{"fwdcode"} = $10; | |
37 | $t{"fwdip"} = $11; | |
38 | $t{"mime"} = $12; | |
39 | ||
40 | return \%t; | |
41 | } | |
42 | ||
43 | 1; |