test-ly-files: Display symlink creation, add `-v` to `ln`
[sunny256-utils.git] / access_log2epstat
bloba070bda91b91a3f8b0a062597eaa58f88c4483dd
1 #!/usr/bin/env perl
3 #====================================================================
4 # access_log2epstat
5 # File ID: af31d840-5d36-11df-aa67-90e6ba3022ac
6 # Konverterer access_log fra Apache til fil som passer til epstat(1).
7 # Langt og trasig navn, men nøye då.
8 #====================================================================
10 use strict;
11 use warnings;
12 use Time::Local;
14 # 194.248.216.3 - - [13/Aug/2001:16:04:37 +0200] "GET
16 my %mnd_hash = (
17 'Jan'=>0, 'Feb'=>1, 'Mar'=>2, 'Apr'=>3, 'May'=>4, 'Jun'=>5,
18 'Jul'=>6, 'Aug'=>7, 'Sep'=>8, 'Oct'=>9, 'Nov'=>10, 'Dec'=>11
21 while (<>) {
22 if (m!
23 \S+ # IP
24 \s+
25 \S+
26 \s+
27 \S+
28 \s+
30 (\d+) # Dato
32 (\S+) # Mnd
34 (\d{4}) # År
35 :(\d\d):(\d\d):(\d\d) # Klokka
36 \s+
37 ([+\-]\d\d)(\d\d)
39 ) {
40 my ($Day, $Mon, $Year, $Hour, $Min, $Sec, $zone_hour, $zone_min) =
41 ( $1, $2, $3, $4, $5, $6, $7, $8);
42 my $num_mon = $mnd_hash{$Mon};
43 my $Secs = timegm($Sec, $Min, $Hour, $Day, $num_mon, $Year);
44 $Secs -= ($zone_hour*3600); # Vi driter i minuttene fir å få opp farta.
45 print("$Secs\n");
46 } else {
47 print(STDERR "Ukjent linje $.\n");
51 __END__