3 #=======================================================================
5 # File ID: 94b18e7a-5d36-11df-9276-90e6ba3022ac
6 # Finner drops (ikke sukkertøy, men pauser) i Apache-logger.
9 # ©opyleft 2004– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License, see end of file for legal stuff.
11 #=======================================================================
20 our ($opt_h, $opt_l) =
22 getopts
('hl:') || die("Option error. Use -h for help.\n");
27 $progname =~ s
#^.*/(.*?)$#$1#;
31 # 194.248.216.3 - - [13/Aug/2001:16:04:37 +0200] "GET
34 'Jan'=>0, 'Feb'=>1, 'Mar'=>2, 'Apr'=>3, 'May'=>4, 'Jun'=>5,
35 'Jul'=>6, 'Aug'=>7, 'Sep'=>8, 'Oct'=>9, 'Nov'=>10, 'Dec'=>11
42 # access_log-regexp {{{
56 :(\d\d
):(\d\d
):(\d\d
) # Klokka
62 my ($Day, $Mon, $Year, $Hour, $Min, $Sec, $zone_hour, $zone_min) =
63 ( $1, $2, $3, $4, $5, $6, $7, $8);
64 my $num_mon = $mnd_hash{$Mon};
65 my $Secs = timegm
($Sec, $Min, $Hour, $Day, $num_mon, $Year);
66 $Secs -= ($zone_hour*3600); # Vi driter i minuttene for å få opp farta.
67 my $Pause = $Secs - $last_sec;
68 if ($last_sec && ($Pause >= $opt_l)) {
69 $num_mon++; # Å inn i svarteste hælvete hvor jeg hater det inkonsekvente pisset der!!!!!!!!!!!!!!!!
71 "%04u-%02u-%02uT%02u:%02u:%02uZ %4u %s\n",
72 $Year, $num_mon, $Day, $Hour, $Min, $Sec,
73 $Pause, sec_to_hms
($Pause)
78 print(STDERR
"Ukjent linje $.\n");
85 my ($Day, $Hour, $Min, $Sec) = (0, 0, 0, 0);
87 $Day = int($secs/86400);
90 $Hour = int($secs/3600);
91 $secs -= $Hour * 3600;
98 return(($Day ?
"$Day:" : "") . sprintf("%02u:%02u:%02u", $Hour, $Min, $Sec));
103 # Send the help message to stdout {{{
108 Usage: $progname [options] [file [...]]
110 Scans Apache access logs and prints out time periods with no connections.
115 -l x Show only pauses longer than x seconds.
124 # Plain Old Documentation (POD) {{{
130 access_log-drops — find pauses in Apache logs
134 access_log-drops [options] [file [...]]
146 Print a brief help summary.
150 Only list pauses longer than I<x> seconds.
160 Made by Øyvind A. Holm S<E<lt>sunny _AT_ sunbase.orgE<gt>>.
164 Copyleft © Øyvind A. Holm <sunny@sunbase.org>
165 This is free software; see the file F<COPYING> for legalese stuff.
169 This program is free software; you can redistribute it and/or modify it
170 under the terms of the GNU General Public License as published by the
171 Free Software Foundation; either version 2 of the License, or (at your
172 option) any later version.
174 This program is distributed in the hope that it will be useful, but
175 WITHOUT ANY WARRANTY; without even the implied warranty of
176 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
177 See the GNU General Public License for more details.
179 You should have received a copy of the GNU General Public License along
180 with this program; if not, write to the Free Software Foundation, Inc.,
181 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
189 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :