PageRenderTime 70ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/calamaris-2.59/calamaris

#
Perl | 3372 lines | 3218 code | 38 blank | 116 comment | 136 complexity | 8d9cb1a84b53ca09ed88d6b075ab5133 MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. #!/usr/bin/perl -w
  2. #
  3. # $Id: calamaris,v 2.59 2004/06/06 16:26:14 cord Exp $
  4. #
  5. # DESCRIPTION: calamaris - statistic package for diverse Proxy-Cache-Servers
  6. #
  7. # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Cord Beermann
  8. #
  9. # URL: http://Calamaris.Cord.de/
  10. # Announcement-Mailing-list: send Mail with 'subscribe' in the Mail-Body to
  11. # Calamaris-announce-request@Cord.de
  12. #
  13. # AUTHOR: Cord Beermann <Cord@Wunder-Nett.org>
  14. #
  15. # Thanks to these contributors, bug reporters, and feature requesters:
  16. # John Heaton <John@MCC.ac.uk>
  17. # Andreas Lamprecht <Andreas.Lamprecht@siemens.at>
  18. # Kenny Ng <kennyng@cyberway.com.sg>
  19. # Claus Langhans <langhans@rz.uni-frankfurt.de>
  20. # Andreas Jung <ajung@sz-sb.de>
  21. # Ernst Heiri <heiri@switch.ch>
  22. # Shamil R. Yahin <SSHY@cclib.nsu.ru>
  23. # Thoralf Freitag <Thoralf.Freitag@isst.fhg.de>
  24. # Marco Paganini <paganini@paganini.net>
  25. # Michael Riedel <mr@fto.de>
  26. # Kris Boulez <krbou@pgsgent.be>
  27. # Mark Visser <mark@snt.utwente.nl>
  28. # Gary Palmer <gjp@erols.com>
  29. # Stefan Watermann <stefan@metronet.de>
  30. # Roar Smith <Roar.Smith@Ericsson.Dk>
  31. # Bernd Lienau <lienau@tli.de>
  32. # Gary Lindstrom <gplindstrom@exodus.nnc.edu>
  33. # Jost Krieger <Jost.Krieger@ruhr-uni-bochum.de>
  34. # Gerd Michael Hoffmann <Hoffmann@dvgw.de>
  35. # Gerold Meerkoetter <gerold@noc.fh-lippe.de>
  36. # Iain Lea <iain@bricbrac.de>
  37. # Emmanuel Adeline <emmanuel.adeline@mail.dotcom.fr>
  38. # John Line <webadm@info.cam.ac.uk>
  39. # Christos Cheretakis <xalkina@otenet.gr>
  40. # Ryan Donnelly <rmd@doit.wisc.edu>
  41. # Richard Vaughan <richard_vaughan@timewarp.co.uk>
  42. # Jonas Luster <jonas@nethammer.qad.org>
  43. # Clare Lahiff <Clare.Lahiff@anu.edu.au>
  44. # Toni Andjelkovic <toni@telecom.at>
  45. # Chris Teakle <ccteakle@its.uq.edu.au>
  46. # Dancer Vesperman <dancer@zeor.simegen.com>
  47. # Vincent ? <vincent@aib.net>
  48. # Elrond ? <Elrond@Wunder-Nett.org>
  49. # Holger Marzen <holger@marzen.de>
  50. # Panagiotis Christias <P.Christias@noc.ntua.gr>
  51. # Patrik Rak <patrik@ash.ein.cz>
  52. # Steve Snyder <swsnyder@insightbb.com>
  53. # Michael Copeland <michael.copeland@bell.ca>
  54. # Warren Brown <wbrown@inktomi.com>
  55. # Andy Nik <nik@che.nsk.su>
  56. # Frank Roechter <frank@fhd.de>
  57. # Antonio Casado Rodríguez <acasado@ualm.es>
  58. # Pavol Adamec <pavol_adamec@tempest.sk>
  59. # Ram Cherukuri <ram@edgix.com>
  60. # Marco Koch <MK@electricpaper.de>
  61. # Stephen Welker <stephen.welker@nemostar.com.au>
  62. # Christian Niederdorfer <christian.niederdorfer@infineon.com>
  63. # Klaus Brinkmeyer <Klaus_Brinkmeyer@inasys.de>
  64. # Filip ? <mechanix@digibel.org>
  65. # Matt Hubbard <m.hubbard@ic.ac.uk>
  66. # James Crocker <jcrocker@menasha.com>
  67. # Enrico Ardizzoni <enrico@unife.it>
  68. # Shawn Switenky <S.Switenky@telesat.ca>
  69. # Jarkko Saloranta <jjs@kpo.fi>
  70. # Jigar Rasalawala <jrasalawala@fourelle.com>
  71. # Philipp Frauenfelder <philipp.frauenfelder@swissonline.ch>
  72. # Alexey Markov <markov@crpi.ru>
  73. # Mark Güthling <privat@mague-pcservice.de>
  74. # Sergey Zarubin <serge-home@yandex.ru>
  75. # Helge Oldach <calamaris@oldach.net>
  76. # Michael R. Schwarzbach <spg@fs.tum.de>
  77. # Radu - Eosif Mihailescu <rmihailescu@lumina.ro>
  78. # Michael Pophal <michael.pophal@nefkom.net>
  79. # Steffen Sledz <sledz@zone42.org>
  80. # Kenytt Avery <kavery@willingminds.com>
  81. # SO Kwok Tsun <ktso@cuhk.edu.hk>
  82. # Chris Knight <chris@aims.com.au>
  83. # ycdtosa ? <ycdtosa@eupla.unizar.es>
  84. # Peter W. Osel <pwo@Infineon.COM>
  85. # Pawel Worach <pawel.worach@nordea.com>
  86. # This program is free software; you can redistribute it and/or modify it
  87. # under the terms of the GNU General Public License as published by the Free
  88. # Software Foundation; either version 2 of the License, or (at your option)
  89. # any later version.
  90. # (If you modify and want to publish it under the name 'Calamaris', please ask
  91. # me. I don't want to confuse the 'audience' with many different versions of
  92. # the same name and/or Version number. (This is not part of the license, it
  93. # is only a favour i asked of you.))
  94. # This program is distributed in the hope that it will be useful, but WITHOUT
  95. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  96. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  97. # more details.
  98. # You should have received a copy of the GNU General Public License along with
  99. # this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  100. # Place - Suite 330, Boston, MA 02111-1307, USA.
  101. # A Perl script is "correct" if it gets the job done before your boss fires
  102. # you.
  103. # -- 'Programming Perl Second Edition'
  104. # by Larry Wall, Tom Christiansen & Randal L. Schwartz
  105. # If you have to remove this, read the README!
  106. require 5.002;
  107. use vars qw($opt_3 $opt_a $opt_b $opt_c $opt_C $opt_d $opt_D $opt_f $opt_F
  108. $opt_h $opt_H $opt_i $opt_I $opt_l $opt_L $opt_m $opt_M $opt_n
  109. $opt_N $opt_o $opt_O $opt_p $opt_P $opt_r $opt_R $opt_s $opt_S
  110. $opt_t $opt_T $opt_u $opt_U $opt_v $opt_V $opt_w $opt_W $opt_z);
  111. use Getopt::Std;
  112. use Sys::Hostname;
  113. getopts('3ab:cCd:D:f:F:hH:i:I:l:LmM:nN:o:Op:P:r:R:sS:t:T:uU:vVwWz');
  114. if ( $opt_b and $opt_b < 1 ) {
  115. print STDERR "$0: wrong value at -b -option: \"$opt_b\"\n\n";
  116. $usage_err = 1;
  117. } else {
  118. $| = 1;
  119. }
  120. if ($opt_U) {
  121. unless ( $opt_U =~ m#^[KMGT]$# ) {
  122. print STDERR "$0: wrong value at -U -option: \"$opt_U\"\n\n";
  123. $usage_err = 1;
  124. }
  125. } else {
  126. $opt_U = '';
  127. }
  128. if ($opt_D) {
  129. if ( $opt_D <= 1 ) {
  130. print STDERR "$0: wrong value at -D -option: \"$opt_D\"\n\n";
  131. $usage_err = 1;
  132. }
  133. }
  134. if ($opt_H) {
  135. if ( $opt_H eq '1' or $opt_H eq 'lookup' ) {
  136. $host_name = hostname() . ' ';
  137. } else {
  138. $host_name = $opt_H . ' ';
  139. }
  140. } else {
  141. $host_name = '';
  142. }
  143. if ( $opt_N and $opt_N != -1 and $opt_N < 2 ) {
  144. print STDERR "$0: wrong value at -N -option: \"$opt_N\"\n\n";
  145. $usage_err = 1;
  146. }
  147. if ($opt_I) {
  148. use Time::Local;
  149. ( $interval_begin, $interval_end ) = split ( '-', $opt_I );
  150. if ($interval_begin > $interval_end) {
  151. print STDERR "$0: wrong value at -I -option: \"$opt_I\". Interval begin newer than interval end!\n\n";
  152. $usage_err = 1;
  153. }
  154. if ( $interval_begin =~ m#^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$# ) {
  155. $interval_begin = timegm( $6, $5, $4, $3, $2 - 1, $1 - 1900 );
  156. } elsif ( $interval_begin eq '' ) {
  157. $interval_begin = 0;
  158. } else {
  159. print STDERR "$0: wrong value at -I -option: \"$opt_I\"\n\n";
  160. $usage_err = 1;
  161. }
  162. if ( $interval_end =~ m#^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$# ) {
  163. $interval_end = timegm( $6, $5, $4, $3, $2 - 1, $1 - 1900 );
  164. } elsif ( $interval_end eq '' ) {
  165. $interval_end = 9999999999;
  166. } else {
  167. print STDERR "$0: wrong value at -I -option: \"$opt_I\"\n\n";
  168. $usage_err = 1;
  169. }
  170. }
  171. if ($opt_F) {
  172. foreach $output ( split ( /\s*,\s*/, $opt_F ) ) {
  173. if ( $output eq 'mail' ) {
  174. $outtype_mail = 1;
  175. } elsif ( $output eq 'html' ) {
  176. $outtype_html = 1;
  177. } elsif ( $output eq 'html-embed' ) {
  178. $outtype_htmlembed = 1;
  179. } elsif ( $output eq 'unformatted' ) {
  180. $outtype_unformatted = 1;
  181. } else {
  182. print STDERR "$0: unknown output-format: $output\n\n";
  183. $usage_err = 1;
  184. }
  185. }
  186. }
  187. # remove this at end of 2003
  188. if ($opt_3) {
  189. print STDERR "$0: obsoleted option -3: use -N3 instead\n\n";
  190. $usage_err = 1;
  191. }
  192. # remove at end of 2004
  193. if ( defined $opt_f and $opt_f =~ m#^squid-(mime|smartfilter)$# ) {
  194. print STDERR "$0: obsoleted input format '$opt_f':
  195. use -f 'squid-extended' instead\n\n";
  196. $usage_err = 1;
  197. }
  198. # change at end of 2003
  199. # remove at end of 2004
  200. if ( defined $opt_w ) {
  201. print STDERR "$0: obsoleted output format switch -w:
  202. use -F 'html' instead\n\n";
  203. $outtype_html = 1;
  204. $output_warn = 1;
  205. }
  206. # change at end of 2003
  207. # remove at end of 2004
  208. if ( defined $opt_W ) {
  209. print STDERR "$0: obsoleted output format switch -W:
  210. use -F 'html-embed' instead\n\n";
  211. $outtype_htmlembed = 1;
  212. $output_warn = 1;
  213. }
  214. # change at end of 2003
  215. # remove at end of 2004
  216. if ( defined $opt_m ) {
  217. print STDERR "$0: obsoleted output format switch -m:
  218. use -F 'mail' instead\n\n";
  219. $outtype_mail = 1;
  220. $output_warn = 1;
  221. }
  222. $sortorder = '';
  223. $sortorder = '_size' if ($opt_O);
  224. if ($opt_a) {
  225. $opt_s = 1;
  226. $opt_P = 60 unless $opt_P;
  227. $opt_d = 20 unless $opt_d;
  228. $opt_r = 20 unless $opt_r;
  229. $opt_t = 20 unless $opt_t;
  230. $opt_D = 10 unless $opt_D;
  231. }
  232. $opt_N = 2 unless $opt_N;
  233. $opt_T = 0 unless $opt_T;
  234. $opt_r = $opt_R unless $opt_r;
  235. $P = $opt_P ? "$opt_P minute" : '60 minute';
  236. if ( defined($opt_P) and ($opt_P%60) == 0 ) { $P = $opt_P/60 . " hour" };
  237. if ( defined($opt_P) and ($opt_P%1440) == 0 ) { $P = $opt_P/1440 . " day" };
  238. if ( $opt_N == -1 or $opt_N > 2 ) {
  239. if ( $opt_N == 3 ) {
  240. $N = '3rd';
  241. } elsif ( $opt_N == -1 ) {
  242. $N = 'all';
  243. } else {
  244. $N = $opt_N . 'th';
  245. }
  246. } else {
  247. $N = '2nd';
  248. }
  249. @reports = (
  250. 'Summary', 'Incoming request peak per protocol',
  251. 'Incoming transfer volume per protocol',
  252. 'Incoming requests by method', 'Incoming UDP-requests by status',
  253. 'Incoming TCP-requests by status', 'Outgoing requests by status',
  254. 'Outgoing requests by destination',
  255. "Request-destinations by ${N}-level-domain",
  256. 'Request-destinations by toplevel-domain', 'TCP-Request-protocol',
  257. 'Requested content-type', 'Requested extensions',
  258. 'Incoming UDP-requests by host', 'Incoming TCP-requests by host',
  259. 'Distribution Histogram', "Performance in $P steps"
  260. );
  261. $VERSION='Calamaris $Revision: 2.59 $';
  262. $COPYRIGHT =
  263. 'Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Cord Beermann.
  264. Calamaris comes with ABSOLUTELY NO WARRANTY. It is free software, and you are
  265. welcome to redistribute it under certain conditions. See source for details.
  266. Calamaris-Homepage: http://Calamaris.Cord.de/';
  267. $USAGE = 'Usage: cat log | ' . $0 . ' [switches]
  268. Reports:
  269. -a all (extracts all reports available,
  270. -a equals -D 10 -d 20 -P 60 -r 20 -s -t 20)
  271. -d n domain (show n Top-level and n second-level destinations,
  272. -1 = unlimited)
  273. -p type peak (measure peak requests)
  274. old = make old request-peak mesurement
  275. new = make new request&byte-peak measurement
  276. (both slow Calamaris significantly down.)
  277. -P n Performance (show throughput data for every n minutes)
  278. -r n requester (show n Requesters, -1 = unlimited)
  279. -R n targets for requester (show n targets for every Requester,
  280. -1 = unlimited), implies -r (*)
  281. -s status (show verbose status reports)
  282. -t n type (show n content-type, n extensions and requested protocols,
  283. -1 = unlimited)
  284. -D n Distribution Histogram (shows size-based distribution of requested
  285. objects, smaller numbers result in more verbose reports.
  286. choose 2, 10 or 100 for useful output. (You can also play
  287. with this ;-))
  288. Input:
  289. -z zero (no input via stdin)
  290. -f type format (sets the type of input logfiles)
  291. auto = tries to guess the input format
  292. (This is the Default)
  293. squid = Native-Logfile derived from Squid V1.1.beta26-V2.x
  294. squid-extended = Native-Logfile with log_mime_hdrs enabled
  295. derived from Squid V1.1.beta26-V2.x (*)
  296. or Cisco Content Engines (*)
  297. or Squid with SmartFilter-patch (*)
  298. squid-old = Native-Logfile derived from Squid
  299. V1.1.alpha1-V1.1.beta25
  300. nc = Squid-style Logfiles derived from NetCache V?? (<5.x)
  301. its = Logfiles derived from Inktomi Traffic Server
  302. elff = Extended Logfile Format (i.e Compaq Tasksmart, Novell
  303. Internet Caching System, NetCache 5.x)
  304. nse = Netscape Extended-1/2 Logfile Format
  305. Output: (Default is plain formatted text)
  306. -F type Format (output format (comma-seperated list))
  307. mail = mail format
  308. html = HTML format
  309. html-embed = HTML format without HTML-headers
  310. unformatted = plain unformatted output
  311. -l string logo (add this string to the head of the report. works only in
  312. combination with -F html)
  313. -M string Meta (includes the given strings in html-<head>. works only in
  314. combination with -F html)
  315. -H name Host-name (a name for the Output, -H \'lookup\' issues a lookup for
  316. the current host)
  317. -O Order (changes the sort order in the reports to request size,
  318. default is sorting by number of requests)
  319. -N n N-level (change all 2nd-level-reports to N-level-reports. N can be
  320. any number from 2 up. -1 means full report.)
  321. -U string Unit (define the Unit for the Byte-values, else it will be auto)
  322. K(ilo), M(ega), G(iga), T(era)
  323. -S list Show (Shows only the defined reports (comma-seperated list) in the
  324. specified order.) The following numbers are defined:
  325. ';
  326. foreach ( 0 .. $#reports ) {
  327. $USAGE .= "\t\t$_\t$reports[$_]\n";
  328. }
  329. $USAGE .=
  330. ' (Note: only putting out one report does not speed up Calamaris
  331. as the internal operations were done based on the
  332. report-switches. Default: Reports are displayed based on
  333. activated reports.)
  334. Caching:
  335. -i file input-file (input-datafile for caching, to add many files separate
  336. them with a \':\')
  337. -o file output-file (output-datafile for caching, can be the same as -i)
  338. Misc:
  339. -n no-lookup (don\'t look IP-Numbers up)
  340. -T n Time (adjust the Performance-Report in minutes)
  341. -c case (switch to case-insensitive (useful for extensions-report))
  342. -u user (use ident information if available) (*)
  343. -I t-t Interval (defines which time-interval should be parsed)
  344. t has to be the format yyyymmddhhmmss
  345. omitting the beginning or ending is allowed.
  346. -b n benchmark (prints a hash-sign (#) to stderr for each n lines
  347. processed)
  348. -v verbose (print information what Calamaris is doing. Useful for
  349. debugging.)
  350. -L Loop (dumps the generated internal loop to STDERR for debugging.)
  351. -C copyright (prints the copyright)
  352. -h help (prints out this message)
  353. -V Version (prints version-info)
  354. (*) These options break the privacy of your users. Please read the README
  355. on this.';
  356. print "$USAGE\n\n" if $opt_h;
  357. print "$VERSION\n\n" if $opt_V;
  358. print "$COPYRIGHT\n\n" if $opt_C or $opt_h or $opt_V;
  359. exit 0 if $opt_h or $opt_C or $opt_V;
  360. if ($usage_err) {
  361. print STDERR "run '$0 -h' for help.\n\n";
  362. exit 1;
  363. }
  364. # initialize variables
  365. $counter = $hier = $hier_direct = $hier_direct_size = $hier_direct_time =
  366. $hier_parent = $hier_parent_size = $hier_parent_time = $hier_sibling =
  367. $hier_sibling_size = $hier_sibling_time = $hier_size = $hier_time =
  368. $invalid = $peak_all_min = $peak_all_min_time = $peak_all_sec =
  369. $peak_all_sec_time = $peak_all_hour = $peak_all_hour_time = $peak_tcp_min =
  370. $peak_tcp_min_time = $peak_tcp_sec = $peak_tcp_sec_time = $peak_tcp_hour =
  371. $peak_tcp_hour_time = $peak_udp_min = $peak_udp_min_time = $peak_udp_sec =
  372. $peak_udp_sec_time = $peak_udp_hour = $peak_udp_hour_time = $size =
  373. $skipped = $tcp = $tcp_hit = $tcp_hit_size = $tcp_hit_time = $tcp_miss =
  374. $tcp_miss_none = $tcp_miss_none_size = $tcp_miss_none_time =
  375. $tcp_miss_size = $tcp_miss_time = $tcp_size = $tcp_time = $time =
  376. $time_end = $time_run = $udp = $udp_hit = $udp_hit_size = $udp_hit_time =
  377. $udp_miss = $udp_miss_size = $udp_miss_time = $udp_size = $udp_time = 0;
  378. $time_begin = 9999999999;
  379. @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
  380. ### Read Cache.
  381. if ($opt_i) {
  382. foreach $file ( split ':', $opt_i ) {
  383. open( CACHE, "$file" ) or die ("$0: can't open $file for reading: $!\n");
  384. while (<CACHE>) {
  385. chomp;
  386. @cache = split '?';
  387. $x = shift (@cache);
  388. next unless ($x);
  389. if ( $x eq 'A' and $#cache == 39 ) {
  390. $time_begin = $cache[0] if $cache[0] < $time_begin;
  391. $time_end = $cache[1] if $cache[1] > $time_end;
  392. $counter += $cache[2];
  393. $size += $cache[3];
  394. $time += $cache[4];
  395. $invalid += $cache[5];
  396. $time_run += $cache[6];
  397. $udp += $cache[7];
  398. $udp_size += $cache[8];
  399. $udp_time += $cache[9];
  400. $udp_hit += $cache[10];
  401. $udp_hit_size += $cache[11];
  402. $udp_hit_time += $cache[12];
  403. $udp_miss += $cache[13];
  404. $udp_miss_size += $cache[14];
  405. $udp_miss_time += $cache[15];
  406. $tcp += $cache[16];
  407. $tcp_size += $cache[17];
  408. $tcp_time += $cache[18];
  409. $tcp_hit += $cache[19];
  410. $tcp_hit_size += $cache[20];
  411. $tcp_hit_time += $cache[21];
  412. $tcp_miss += $cache[22];
  413. $tcp_miss_size += $cache[23];
  414. $tcp_miss_time += $cache[24];
  415. $tcp_miss_none += $cache[25];
  416. $tcp_miss_none_size += $cache[26];
  417. $tcp_miss_none_time += $cache[27];
  418. $hier += $cache[28];
  419. $hier_size += $cache[29];
  420. $hier_time += $cache[30];
  421. $hier_direct += $cache[31];
  422. $hier_direct_size += $cache[32];
  423. $hier_direct_time += $cache[33];
  424. $hier_sibling += $cache[34];
  425. $hier_sibling_size += $cache[35];
  426. $hier_sibling_time += $cache[36];
  427. $hier_parent += $cache[37];
  428. $hier_parent_size += $cache[38];
  429. $hier_parent_time += $cache[39];
  430. } elsif ( $x eq 'B' and $#cache == 17 ) {
  431. unless ( $peak_udp_sec == 0 ) {
  432. warn("multiple cache files.\n") if $opt_v;
  433. $peak_warn = 'Peak values are possibly wrong!';
  434. }
  435. if ( $peak_udp_sec < $cache[0] ) {
  436. $peak_udp_sec = $cache[0];
  437. $peak_udp_sec_time = $cache[1];
  438. }
  439. if ( $peak_udp_min < $cache[2] ) {
  440. $peak_udp_min = $cache[2];
  441. $peak_udp_min_time = $cache[3];
  442. }
  443. $peak_udp_hour{ $cache[5] } = 0
  444. unless defined $peak_udp_hour{ $cache[5] };
  445. $peak_udp_hour{ $cache[5] } += $cache[4];
  446. if ( $peak_tcp_sec < $cache[6] ) {
  447. $peak_tcp_sec = $cache[6];
  448. $peak_tcp_sec_time = $cache[7];
  449. }
  450. if ( $peak_tcp_min < $cache[8] ) {
  451. $peak_tcp_min = $cache[8];
  452. $peak_tcp_min_time = $cache[9];
  453. }
  454. $peak_tcp_hour{ $cache[11] } = 0
  455. unless defined $peak_tcp_hour{ $cache[11] };
  456. $peak_tcp_hour{ $cache[11] } += $cache[10];
  457. if ( $peak_all_sec < $cache[12] ) {
  458. $peak_all_sec = $cache[12];
  459. $peak_all_sec_time = $cache[13];
  460. }
  461. if ( $peak_all_min < $cache[14] ) {
  462. $peak_all_min = $cache[14];
  463. $peak_all_min_time = $cache[15];
  464. }
  465. $peak_all_hour{ $cache[17] } = 0
  466. unless defined $peak_all_hour{ $cache[17] };
  467. $peak_all_hour{ $cache[17] } += $cache[16];
  468. } elsif ( $x eq 'B' and $#cache == 23 ) {
  469. unless ( $peak_udp_sec == 0 ) {
  470. warn("multiple cache files.\n") if $opt_v;
  471. $peak_warn = 'Peak values are possibly wrong!';
  472. }
  473. if ( $peak_udp_sec < $cache[0] ) {
  474. $peak_udp_sec = $cache[0];
  475. $peak_udp_sec_time = $cache[1];
  476. }
  477. if ( $peak_udp_min < $cache[2] ) {
  478. $peak_udp_min = $cache[2];
  479. $peak_udp_min_time = $cache[3];
  480. }
  481. $peak_udp_hour{ $cache[5] } = 0
  482. unless defined $peak_udp_hour{ $cache[5] };
  483. $peak_udp_hour{ $cache[5] } += $cache[4];
  484. $peak_udp_hour_size{ $cache[7] } = 0
  485. unless defined $peak_udp_hour_size{ $cache[7] };
  486. $peak_udp_hour_size{ $cache[7] } += $cache[6];
  487. if ( $peak_tcp_sec < $cache[8] ) {
  488. $peak_tcp_sec = $cache[8];
  489. $peak_tcp_sec_time = $cache[9];
  490. }
  491. if ( $peak_tcp_min < $cache[10] ) {
  492. $peak_tcp_min = $cache[10];
  493. $peak_tcp_min_time = $cache[11];
  494. }
  495. $peak_tcp_hour{ $cache[13] } = 0
  496. unless defined $peak_tcp_hour{ $cache[13] };
  497. $peak_tcp_hour{ $cache[13] } += $cache[12];
  498. $peak_tcp_hour_size{ $cache[15] } = 0
  499. unless defined $peak_tcp_hour_size{ $cache[15] };
  500. $peak_tcp_hour_size{ $cache[15] } += $cache[14];
  501. if ( $peak_all_sec < $cache[16] ) {
  502. $peak_all_sec = $cache[16];
  503. $peak_all_sec_time = $cache[17];
  504. }
  505. if ( $peak_all_min < $cache[18] ) {
  506. $peak_all_min = $cache[18];
  507. $peak_all_min_time = $cache[19];
  508. }
  509. $peak_all_hour{ $cache[21] } = 0
  510. unless defined $peak_all_hour{ $cache[21] };
  511. $peak_all_hour{ $cache[21] } += $cache[20];
  512. $peak_all_hour_size{ $cache[23] } = 0
  513. unless defined $peak_all_hour_size{ $cache[23] };
  514. $peak_all_hour_size{ $cache[23] } += $cache[22];
  515. } elsif ( $x eq 'C' and $#cache == 3 ) {
  516. $y = shift (@cache);
  517. $method{$y} = $method_size{$y} = $method_time{$y} = 0
  518. unless defined $method{$y};
  519. $method{$y} += $cache[0];
  520. $method_size{$y} += $cache[1];
  521. $method_time{$y} += $cache[2];
  522. } elsif ( $x eq 'D' and $#cache == 3 ) {
  523. $y = shift (@cache);
  524. $udp_hit{$y} = $udp_hit_size{$y} = $udp_hit_time{$y} = 0
  525. unless defined $udp_hit{$y};
  526. $udp_hit{$y} += $cache[0];
  527. $udp_hit_size{$y} += $cache[1];
  528. $udp_hit_time{$y} += $cache[2];
  529. } elsif ( $x eq 'E' and $#cache == 3 ) {
  530. $y = shift (@cache);
  531. $udp_miss{$y} = $udp_miss_size{$y} = $udp_miss_time{$y} = 0
  532. unless defined $udp_miss{$y};
  533. $udp_miss{$y} += $cache[0];
  534. $udp_miss_size{$y} += $cache[1];
  535. $udp_miss_time{$y} += $cache[2];
  536. } elsif ( $x eq 'F' and $#cache == 3 ) {
  537. $y = shift (@cache);
  538. $tcp_hit{$y} = $tcp_hit_size{$y} = $tcp_hit_time{$y} = 0
  539. unless defined $tcp_hit{$y};
  540. $tcp_hit{$y} += $cache[0];
  541. $tcp_hit_size{$y} += $cache[1];
  542. $tcp_hit_time{$y} += $cache[2];
  543. } elsif ( $x eq 'G' and $#cache == 3 ) {
  544. $y = shift (@cache);
  545. $tcp_miss{$y} = $tcp_miss_size{$y} = $tcp_miss_time{$y} = 0
  546. unless defined $tcp_miss{$y};
  547. $tcp_miss{$y} += $cache[0];
  548. $tcp_miss_size{$y} += $cache[1];
  549. $tcp_miss_time{$y} += $cache[2];
  550. } elsif ( $x eq 'H' and $#cache == 3 ) {
  551. $y = shift (@cache);
  552. $tcp_miss_none{$y} = $tcp_miss_none_size{$y} =
  553. $tcp_miss_none_time{$y} = 0
  554. unless defined $tcp_miss_none{$y};
  555. $tcp_miss_none{$y} += $cache[0];
  556. $tcp_miss_none_size{$y} += $cache[1];
  557. $tcp_miss_none_time{$y} += $cache[2];
  558. } elsif ( $x eq 'I' and $#cache == 3 ) {
  559. $y = shift (@cache);
  560. $hier_direct{$y} = $hier_direct_size{$y} = $hier_direct_time{$y} = 0
  561. unless defined $hier_direct{$y};
  562. $hier_direct{$y} += $cache[0];
  563. $hier_direct_size{$y} += $cache[1];
  564. $hier_direct_time{$y} += $cache[2];
  565. } elsif ( $x eq 'J' and $#cache == 3 ) {
  566. $y = shift (@cache);
  567. $hier_sibling{$y} = $hier_sibling_size{$y} = $hier_sibling_time{$y} =
  568. 0
  569. unless defined $hier_sibling{$y};
  570. $hier_sibling{$y} += $cache[0];
  571. $hier_sibling_size{$y} += $cache[1];
  572. $hier_sibling_time{$y} += $cache[2];
  573. } elsif ( $x eq 'K' and $#cache == 3 ) {
  574. $y = shift (@cache);
  575. $hier_parent{$y} = $hier_parent_size{$y} = $hier_parent_time{$y} = 0
  576. unless defined $hier_parent{$y};
  577. $hier_parent{$y} += $cache[0];
  578. $hier_parent_size{$y} += $cache[1];
  579. $hier_parent_time{$y} += $cache[2];
  580. } elsif ( $x eq 'L' and $#cache == 3 ) {
  581. $y = shift (@cache);
  582. $hier_neighbor{$y} = $hier_neighbor_size{$y} =
  583. $hier_neighbor_time{$y} = 0
  584. unless defined $hier_neighbor{$y};
  585. $hier_neighbor{$y} += $cache[0];
  586. $hier_neighbor_size{$y} += $cache[1];
  587. $hier_neighbor_time{$y} += $cache[2];
  588. } elsif ( $x eq 'M' and $#cache == 4 ) {
  589. $y = shift (@cache);
  590. $z = shift (@cache);
  591. $hier_neighbor_status{$y}{$z} = $hier_neighbor_status_size{$y}{$z} =
  592. $hier_neighbor_status_time{$y}{$z} = 0
  593. unless defined $hier_neighbor_status{$y}{$z};
  594. $hier_neighbor_status{$y}{$z} += $cache[0];
  595. $hier_neighbor_status_size{$y}{$z} += $cache[1];
  596. $hier_neighbor_status_time{$y}{$z} += $cache[2];
  597. } elsif ( $x eq 'N' and $#cache == 3 ) {
  598. $y = shift (@cache);
  599. $tcp_urlhost{$y} = $tcp_urlhost_size{$y} = $tcp_hit_urlhost{$y} = 0
  600. unless defined $tcp_urlhost{$y};
  601. $tcp_urlhost{$y} += $cache[0];
  602. $tcp_urlhost_size{$y} += $cache[1];
  603. $tcp_hit_urlhost{$y} += $cache[2];
  604. } elsif ( $x eq 'O' and $#cache == 3 ) {
  605. $y = shift (@cache);
  606. $tcp_urltld{$y} = $tcp_urltld_size{$y} = $tcp_hit_urltld{$y} = 0
  607. unless defined $tcp_urltld{$y};
  608. $tcp_urltld{$y} += $cache[0];
  609. $tcp_urltld_size{$y} += $cache[1];
  610. $tcp_hit_urltld{$y} += $cache[2];
  611. } elsif ( $x eq 'P' and $#cache == 3 ) {
  612. $y = shift (@cache);
  613. $tcp_urlprot{$y} = $tcp_urlprot_size{$y} = $tcp_hit_urlprot{$y} = 0
  614. unless defined $tcp_urlprot{$y};
  615. $tcp_urlprot{$y} += $cache[0];
  616. $tcp_urlprot_size{$y} += $cache[1];
  617. $tcp_hit_urlprot{$y} += $cache[2];
  618. } elsif ( $x eq 'Q' and $#cache == 3 ) {
  619. $y = shift (@cache);
  620. $tcp_content{$y} = $tcp_content_size{$y} = $tcp_hit_content{$y} = 0
  621. unless defined $tcp_content{$y};
  622. $tcp_content{$y} += $cache[0];
  623. $tcp_content_size{$y} += $cache[1];
  624. $tcp_hit_content{$y} += $cache[2];
  625. } elsif ( $x eq 'R' and $#cache == 3 ) {
  626. $y = shift (@cache);
  627. $tcp_urlext{$y} = $tcp_urlext_size{$y} = $tcp_hit_urlext{$y} = 0
  628. unless defined $tcp_urlext{$y};
  629. $tcp_urlext{$y} += $cache[0];
  630. $tcp_urlext_size{$y} += $cache[1];
  631. $tcp_hit_urlext{$y} += $cache[2];
  632. } elsif ( $x eq 'S' and $#cache == 5 ) {
  633. $y = shift (@cache);
  634. $udp_requester{$y} = $udp_requester_size{$y} =
  635. $udp_requester_time{$y} = $udp_hit_requester{$y} =
  636. $udp_hit_requester_size{$y} = 0
  637. unless defined $udp_requester{$y};
  638. $udp_requester{$y} += $cache[0];
  639. $udp_requester_size{$y} += $cache[1];
  640. $udp_requester_time{$y} += $cache[2];
  641. $udp_hit_requester{$y} += $cache[3];
  642. $udp_hit_requester_size{$y} += $cache[4];
  643. } elsif ( $x eq 'T' and $#cache == 5 ) {
  644. $y = shift (@cache);
  645. $tcp_requester{$y} = $tcp_requester_size{$y} =
  646. $tcp_requester_time{$y} = $tcp_hit_requester{$y} =
  647. $tcp_hit_requester_size{$y} = 0
  648. unless defined $tcp_requester{$y};
  649. $tcp_requester{$y} += $cache[0];
  650. $tcp_requester_size{$y} += $cache[1];
  651. $tcp_requester_time{$y} += $cache[2];
  652. $tcp_hit_requester{$y} += $cache[3];
  653. $tcp_hit_requester_size{$y} += $cache[4];
  654. } elsif ( $x eq 'U' and $#cache == 13 ) {
  655. $y = shift (@cache);
  656. ( $perf_counter{$y}, $perf_size{$y}, $perf_time{$y},
  657. $perf_tcp_hit_size{$y}, $perf_tcp_hit_time{$y},
  658. $perf_tcp_miss_size{$y}, $perf_tcp_miss_time{$y},
  659. $perf_hier_direct_size{$y}, $perf_hier_direct_time{$y},
  660. $perf_hier_sibling_size{$y}, $perf_hier_sibling_time{$y},
  661. $perf_hier_parent_size{$y}, $perf_hier_parent_time{$y} )
  662. = @cache;
  663. # This is for a stupid bug I brought in... it should save older Cache-Files,
  664. # and put them in so that we can work with them.. remove at end of 2003
  665. } elsif ( $x eq 'U' and $#cache == 12 ) {
  666. $cache_warn1 = 'The Performance data misses the Cache-Hits-value';
  667. $y = shift (@cache);
  668. ( $perf_counter{$y}, $perf_size{$y}, $perf_time{$y},
  669. $perf_tcp_hit_size{$y}, $perf_tcp_miss_size{$y},
  670. $perf_tcp_miss_time{$y}, $perf_hier_direct_size{$y},
  671. $perf_hier_direct_time{$y}, $perf_hier_sibling_size{$y},
  672. $perf_hier_sibling_time{$y}, $perf_hier_parent_size{$y},
  673. $perf_hier_parent_time{$y} )
  674. = @cache;
  675. # stupid, yes...
  676. # I set this to 0/.000001 so removezerotime prints a - in the report.
  677. $perf_tcp_hit_size{$y} = 0;
  678. $perf_tcp_hit_time{$y} = .000001;
  679. # End of stupid bug-workaround
  680. } elsif ( $x eq 'V' and $#cache == 6 ) {
  681. $y = shift (@cache);
  682. $z = shift (@cache);
  683. $udp_requester_urlhost{$y}{$z} = $udp_requester_urlhost_size{$y}{$z} =
  684. $udp_requester_urlhost_time{$y}{$z} =
  685. $udp_hit_requester_urlhost{$y}{$z} =
  686. $udp_hit_requester_urlhost_size{$y}{$z} = 0
  687. unless defined $udp_requester_urlhost{$y}{$z};
  688. $udp_requester_urlhost{$y}{$z} += $cache[0];
  689. $udp_requester_urlhost_size{$y}{$z} += $cache[1];
  690. $udp_requester_urlhost_time{$y}{$z} += $cache[2];
  691. $udp_hit_requester_urlhost{$y}{$z} += $cache[3];
  692. $udp_hit_requester_urlhost_size{$y}{$z} += $cache[4];
  693. # Start of Bug-fix - remove this at end of 2003
  694. } elsif ( $x eq 'V' and $#cache == 5 ) {
  695. $cache_warn2 = 'The UDP-Requester-Report misses the other-value';
  696. $y = '<other>' unless ($y);
  697. $z = shift (@cache);
  698. $udp_requester_urlhost{$y}{$z} = $udp_requester_urlhost_size{$y}{$z} =
  699. $udp_requester_urlhost_time{$y}{$z} =
  700. $udp_hit_requester_urlhost{$y}{$z} =
  701. $udp_hit_requester_urlhost_size{$y}{$z} = 0
  702. unless defined $udp_requester_urlhost{$y}{$z};
  703. $udp_requester_urlhost{$y}{$z} += $cache[0];
  704. $udp_requester_urlhost_size{$y}{$z} += $cache[1];
  705. $udp_requester_urlhost_time{$y}{$z} += $cache[2];
  706. $udp_hit_requester_urlhost{$y}{$z} += $cache[3];
  707. $udp_hit_requester_urlhost_size{$y}{$z} += $cache[4];
  708. # End of Bug-fix
  709. } elsif ( $x eq 'W' and $#cache == 6 ) {
  710. $y = shift (@cache);
  711. $z = shift (@cache);
  712. $tcp_requester_urlhost{$y}{$z} = $tcp_requester_urlhost_size{$y}{$z} =
  713. $tcp_requester_urlhost_time{$y}{$z} =
  714. $tcp_hit_requester_urlhost{$y}{$z} =
  715. $tcp_hit_requester_urlhost_size{$y}{$z} = 0
  716. unless defined $tcp_requester_urlhost{$y}{$z};
  717. $tcp_requester_urlhost{$y}{$z} += $cache[0];
  718. $tcp_requester_urlhost_size{$y}{$z} += $cache[1];
  719. $tcp_requester_urlhost_time{$y}{$z} += $cache[2];
  720. $tcp_hit_requester_urlhost{$y}{$z} += $cache[3];
  721. $tcp_hit_requester_urlhost_size{$y}{$z} += $cache[4];
  722. # Start of Bugfix - remove at end of 2003
  723. } elsif ( $x eq 'W' and $#cache == 5 ) {
  724. $cache_warn3 = 'The TCP-Requester-Report misses the other-value';
  725. $y = '<other>' unless ($y);
  726. $z = shift (@cache);
  727. $tcp_requester_urlhost{$y}{$z} = $tcp_requester_urlhost_size{$y}{$z} =
  728. $tcp_requester_urlhost_time{$y}{$z} =
  729. $tcp_hit_requester_urlhost{$y}{$z} =
  730. $tcp_hit_requester_urlhost_size{$y}{$z} = 0
  731. unless defined $tcp_requester_urlhost{$y}{$z};
  732. $tcp_requester_urlhost{$y}{$z} += $cache[0];
  733. $tcp_requester_urlhost_size{$y}{$z} += $cache[1];
  734. $tcp_requester_urlhost_time{$y}{$z} += $cache[2];
  735. $tcp_hit_requester_urlhost{$y}{$z} += $cache[3];
  736. $tcp_hit_requester_urlhost_size{$y}{$z} += $cache[4];
  737. # End of Bugfix
  738. } elsif ( $x eq 'X' and $#cache == 5 ) {
  739. $y = shift (@cache);
  740. $tcp_distribution{$y} = $tcp_distribution_size{$y} =
  741. $tcp_distribution_time{$y} = $tcp_hit_distribution{$y} =
  742. $tcp_hit_distribution_size{$y} = 0
  743. unless defined $tcp_distribution{$y};
  744. $tcp_distribution{$y} += $cache[0];
  745. $tcp_distribution_size{$y} += $cache[1];
  746. $tcp_distribution_time{$y} += $cache[2];
  747. $tcp_hit_distribution{$y} += $cache[3];
  748. $tcp_hit_distribution_size{$y} += $cache[4];
  749. } else {
  750. print STDERR "can't parse cache-line: \"$x @cache\"\n";
  751. }
  752. }
  753. close(CACHE);
  754. }
  755. }
  756. unless ($opt_z) {
  757. while ( defined( $line = <> ) ) {
  758. if ( not defined $opt_f or $opt_f eq 'auto' ) {
  759. if ( $line =~
  760. m#^\d+\.\d+\s+\d+\s+[\w\-\.:]+\s+\w+/\d+\s+\d+\s+\w+\s+\S+\s+\S+\s+\w+/\S+\s+\S+$#
  761. )
  762. {
  763. $opt_f = 'squid';
  764. print STDERR "guessing... using '-f squid'\n" if ($opt_v);
  765. last;
  766. } elsif ( $line =~
  767. m#^\d+\s+\d+\s+[\w\-\.:]+\s+\w+/\d+\s+\d+\s+\w+\s+\S+\s+\S+\s+\w+/\S+\s+\S+$#
  768. )
  769. {
  770. $opt_f = 'its';
  771. print STDERR "guessing... using '-f its'\n" if ($opt_v);
  772. last;
  773. } elsif ( $line =~
  774. m#^\d+\.\d+\s+\d+\s+[\w\-\.:]+\s+\w+/\d+\s+\d+\s+\w+\s+\S+\s+\S+\s+\w+/\S+$#
  775. )
  776. {
  777. $opt_f = 'squid-old';
  778. print STDERR "guessing... using '-f squid-old'\n" if ($opt_v);
  779. last;
  780. } elsif ( $line =~
  781. m#^\d+\.\d+\s+\d+\s+[\w\-\.:]+\s+\w+/\d+\s+\d+\s+\w+\s+\S+\s+\S+\s+\w+/\S+\s+(\S|; c)+\s+\S+$#
  782. )
  783. {
  784. $opt_f = 'nc';
  785. print STDERR "guessing... using '-f nc'\n" if ($opt_v);
  786. last;
  787. } elsif ( $line =~ s/^\s*#\s*Fields:\s*// ) {
  788. $opt_f = 'elff';
  789. print STDERR "guessing... using '-f elff'\n" if ($opt_v);
  790. last;
  791. } elsif ( $line =~ s/^\s*format=\s*// ) {
  792. $opt_f = 'nse';
  793. print STDERR "guessing... using '-f nse'\n" if ($opt_v);
  794. last;
  795. } elsif ( $line =~
  796. m#^\d+\.\d+\s+\d+\s+[\w\-\.:]+\s+\w+/\-?\d+\s+\d+\s+\w+\s+\S+\s+\S+\s+\w+/\S+\s+\S+\s+#
  797. )
  798. {
  799. $opt_f = 'squid-extended';
  800. print STDERR "guessing... using '-f squid-extended'\n" if ($opt_v);
  801. last;
  802. } elsif ( $line =~
  803. m#^[\w\-\.:]+\s+\S+\s+\S+\s+\[.+\]\s+\"\w+\s+\S+\s+\S+\"\s+\d+\s+\d+\s+\S+(\s+\[.*\]\s+\[.*\])?$#
  804. )
  805. {
  806. print STDERR "$0: The first line of the input looks to me as if you
  807. switched 'emulate_httpd_log' to on. I can't parse that format. Please read
  808. the README on this.\n\n";
  809. exit(1);
  810. } elsif ( $line =~ m/^\s*(#|$)/ ) {
  811. print STDERR "skipping: $line\n" if ($opt_v);
  812. next;
  813. } else {
  814. print STDERR "$0: I don't know this input format. Please check the
  815. input. If you\'re sure that the following line is NOT corrupt and the error
  816. also occurs with the recent version of Calamaris (see the README for pointers
  817. and known bugs) then report it with the following line to
  818. <Calamaris-bug\@Cord.de>. Thank You.\n\n$line\n\n";
  819. exit(1);
  820. }
  821. } else {
  822. last;
  823. }
  824. }
  825. if ( not defined $opt_f or $opt_f eq 'auto' ) {
  826. print "\nno requests found\n";
  827. exit(0);
  828. }
  829. print STDERR "print a hash-sign for each $opt_b lines:\n" if ($opt_b);
  830. $loop = '
  831. for ( ; $line ; $line = <> ) {';
  832. if ( $opt_f eq 'squid' ) {
  833. $loop .= '
  834. ( $log_date, $log_reqtime, $log_requester, $log_status, $log_size,
  835. $log_method, $log_url, $log_ident, $log_hier, $log_content, $foo )
  836. = split ( /\s+/, $line );
  837. if ( not defined $foo
  838. or not defined $log_content
  839. or $foo ne \'\'
  840. or $log_content eq \'\'
  841. or $log_reqtime < 0
  842. or $log_date !~ m#^\d+\.\d{3}$# )
  843. {';
  844. } elsif ( $opt_f eq 'squid-extended' ) {
  845. $loop .= '
  846. $line =~ s/ \[[^\[\]]*\]//g;
  847. ( $log_date, $log_reqtime, $log_requester, $log_status, $log_size,
  848. $log_method, $log_url, $log_ident, $log_hier, $log_content)
  849. = split ( /\s+/, $line, 10 );
  850. chomp($log_content);
  851. if ( not defined $log_content
  852. or $log_content eq \'\'
  853. or $log_reqtime < 0
  854. or $log_date !~ m#^\d+\.\d{3}$# )
  855. {';
  856. } elsif ( $opt_f eq 'its' ) {
  857. $loop .= '
  858. ( $log_date, $log_reqtime, $log_requester, $log_status, $log_size,
  859. $log_method, $log_url, $log_ident, $log_hier, $log_content, $foo ) =
  860. split ( /\s+/, $line );
  861. if ( not defined $foo
  862. or not defined $log_content
  863. or $foo ne \'\'
  864. or $log_content eq \'\'
  865. or $log_reqtime < 0
  866. or $log_date !~ m#^\d+$# )
  867. {';
  868. } elsif ( $opt_f eq 'squid-old' ) {
  869. $loop .= '
  870. ( $log_date, $log_reqtime, $log_requester, $log_status, $log_size,
  871. $log_method, $log_url, $log_ident, $log_hier, $foo )
  872. = split ( /\s+/, $line );
  873. unless ( not defined $foo
  874. or not defined $log_hier
  875. or $foo ne \'\'
  876. or $log_hier eq \'\'
  877. or $log_reqtime < 0
  878. or $log_date !~ m#^\d+\.\d{3}$# )
  879. {';
  880. } elsif ( $opt_f eq 'nc' ) {
  881. $loop .= '
  882. $line =~ s#\; c#\;_c#og; # Hack to handle buggy logfiles of NetCache V3.2.x
  883. ( $log_date, $log_reqtime, $log_requester, $log_status, $log_size,
  884. $log_method, $log_url, $log_ident, $log_hier, $log_content, $log_abort,
  885. $foo )
  886. = split ( /\s+/, $line );
  887. if ( not defined $foo or not defined $log_abort or $foo ne \'\' or
  888. $log_abort eq \'\' or $log_reqtime < 0 or
  889. $log_date !~ m#^\d+\.\d{3}$# )
  890. {';
  891. } elsif ( $opt_f eq 'elff' ) {
  892. @fields = split ( /\s+/, $line );
  893. $loop .= '
  894. use Time::Local;
  895. if ( $line =~
  896. m#^';
  897. foreach (@fields) {
  898. $tmpline1 .= '\s+' if ($tmpline1);
  899. if ( $_ eq 'date' ) {
  900. $tmpline1 .= '(\d+)-(\d+)-(\d+)';
  901. $tmpline2 .= '
  902. $log_year = $' . ++$offset . ';
  903. $log_month = $' . ++$offset . ';
  904. $log_day = $' . ++$offset . ';';
  905. } elsif ( $_ eq 'time' ) {
  906. $tmpline1 .= '(\d+):(\d+):(\d+)';
  907. $tmpline2 .= '
  908. $log_hour = $' . ++$offset . ';
  909. $log_min = $' . ++$offset . ';
  910. $log_sec = $' . ++$offset . ';';
  911. } elsif ( $_ eq 'x-timestamp' ) {
  912. $tmpline1 .= '(\d+\.\d+)';
  913. $tmpline2 .= '
  914. $log_date = $' . ++$offset . ';';
  915. $log_date = 0;
  916. } elsif ( $_ eq 'c-ip' ) {
  917. $tmpline1 .= '([\w\-\.:]+)';
  918. $tmpline2 .= '
  919. $log_requester = $' . ++$offset . ';';
  920. } elsif ( $_ eq 'cs-authname'
  921. or $_ eq 'x-remote-id'
  922. or $_ eq 'x-username'
  923. or $_ eq 'cs-username' )
  924. {
  925. $tmpline1 .= '(\S+)';
  926. $tmpline2 .= '
  927. $log_ident = $' . ++$offset . ';';
  928. } elsif ( $_ eq 's-ip' or $_ eq 's-sitename' ) {
  929. $tmpline1 .= '[\w\-\.]+';
  930. } elsif ( $_ eq 'cs-method' ) {
  931. $tmpline1 .= '([\w\-]+)';
  932. $tmpline2 .= '
  933. $log_method = $' . ++$offset . ';';
  934. } elsif ( $_ eq 'cs-uri' ) {
  935. $tmpline1 .= '(\S+)';
  936. $tmpline2 .= '
  937. $log_url = $' . ++$offset . ';';
  938. } elsif ( $_ eq 'cs-uri-stem'
  939. or $_ eq 'cs-uri-query'
  940. or $_ eq 'x-note' )
  941. {
  942. $tmpline1 .= '\S+';
  943. } elsif ( $_ eq 'c-version' ) {
  944. $tmpline1 .= '\w+/[\d\.]+';
  945. } elsif ( $_ eq 'sc-status' ) {
  946. $tmpline1 .= '(\d+)';
  947. $tmpline2 .= '
  948. $log_code = $' . ++$offset . ';';
  949. } elsif ( $_ eq 'sc-bytes' or $_ eq 'bytes' ) {
  950. $tmpline1 .= '(\d+)';
  951. $tmpline2 .= '
  952. $log_size = $' . ++$offset . ';';
  953. } elsif ( $_ eq 'cs-bytes' ) {
  954. $tmpline1 .= '\d+';
  955. } elsif ( $_ eq 'x-elapsed-milliseconds' ) {
  956. $tmpline1 .= '(\d+)';
  957. $tmpline2 .= '
  958. $log_reqtime = $' . ++$offset . ';';
  959. } elsif ( $_ eq 'time-taken' ) {
  960. $tmpline1 .= '([\d\.]+)';
  961. $tmpline2 .= '
  962. $log_reqtime = $' . ++$offset . ' * 1000;';
  963. } elsif ( $_ eq 'cs(User-Agent)'
  964. or $_ eq 'cs(Cookie)'
  965. or $_ eq 'cs(Referer)'
  966. or $_ eq 'sc(Referer)'
  967. or $_ eq 'cs(X-Forwarded-For)'
  968. or $_ eq 'x-hiername' )
  969. {
  970. $tmpline1 .= '(\"[^\"]*\"|-)';
  971. $tmpline2 .= '
  972. ++$offset;';
  973. } elsif ( $_ eq 'cached' ) {
  974. $tmpline1 .= '(\d+)';
  975. $tmpline2 .= '
  976. $log_cached = $' . ++$offset . ';';
  977. } elsif ( $_ eq 'x-transaction' ) {
  978. $tmpline1 .= '(\w+\/[\d\-]+)';
  979. $tmpline2 .= '
  980. $log_status = $' . ++$offset . ';';
  981. $log_status = 0;
  982. } elsif ( $_ eq 'x-fill-proxy-ip' ) {
  983. $tmpline1 .= '([\w\-\.]+)';
  984. $tmpline2 .= '
  985. $log_proxy_ip = $' . ++$offset . ';';
  986. } elsif ( $_ eq 'x-origin-ip' ) {
  987. $tmpline1 .= '([\w\-\.]+)';
  988. $tmpline2 .= '
  989. $log_origin_ip = $' . ++$offset . ';';
  990. } elsif ( $_ eq 'x-hiercode' ) {
  991. $tmpline1 .= '([\w\-\.\/]+)';
  992. $tmpline2 .= '
  993. $log_hier = $' . ++$offset . ';';
  994. $log_hier = 0;
  995. } elsif ( $_ eq 'rs(Content-Type)' ) {
  996. $tmpline1 .= '\"[^\"]*\"';
  997. } else {
  998. print STDERR "$0: I don't know this input format. Please check the
  999. input. If you\'re sure that the following is NOT corrupt and the error also
  1000. occurs with the recent version of Calamaris (see the README for pointers and
  1001. known bugs) then report it with the following line to <Calamaris-bug\@Cord.de>.
  1002. Thank You.\n\n$_\n\n";
  1003. exit(1);
  1004. }
  1005. }
  1006. foreach $pattern ( qw(date time c-ip cs-method cs-uri sc-status sc-bytes
  1007. time-taken cached x-fill-proxy-ip x-origin-ip)
  1008. )
  1009. {
  1010. unless ( grep $pattern, @fields ) {
  1011. print STDERR "$0: Your input file format is missing at least the field
  1012. \'$pattern\'. I can\'t parse it. Sorry. If you think that this field isn't
  1013. important to you, please report this error to <Calamaris-bug\@Cord.de>.
  1014. Thank You.\n\n";
  1015. exit(1);
  1016. }
  1017. }
  1018. foreach $pattern (qw(cs-authname)) {
  1019. unless ( grep $pattern, @fields ) {
  1020. if ( $pattern eq 'cs-authname' ) {
  1021. $tmpline2 .= '
  1022. $log_ident = "-";';
  1023. }
  1024. }
  1025. }
  1026. $loop .= $tmpline1 . '.?$#
  1027. )
  1028. {' . $tmpline2;
  1029. $loop .= '
  1030. $log_date = timegm(
  1031. $log_sec, $log_min, $log_hour, $log_day, $log_month - 1,
  1032. $log_year - 1900
  1033. );' unless defined $log_date;
  1034. $loop .= '
  1035. $log_status = "$log_cached/$log_code";' unless defined $log_status;
  1036. $loop .= '
  1037. if ( $log_origin_ip ne \'-\' ) {
  1038. $log_hier = "DIRECT/$log_origin_ip";
  1039. } elsif ( $log_proxy_ip ne \'-\' ) {
  1040. if ( $log_cached eq \'0\' ) {
  1041. $log_hier = "PARENT_MISS/$log_proxy_ip";
  1042. } else {
  1043. $log_hier = "PARENT_HIT/$log_proxy_ip";
  1044. }
  1045. } else {
  1046. $log_hier = "NONE/-";
  1047. }' unless defined $log_hier;
  1048. $loop .= '
  1049. } else {';
  1050. while ( defined( $line = <> ) ) {
  1051. last unless $line =~ /^\s*#/;
  1052. }
  1053. } elsif ( $opt_f eq 'nse' ) {
  1054. $line =~ s#^format=##og;
  1055. @fields = split ( /\s+/, $line );
  1056. $loop .= '
  1057. use Time::Local;
  1058. if ( $line =~
  1059. m#^';
  1060. foreach (@fields) {
  1061. $tmpline1 .= '\s+' if ($tmpline1);
  1062. if ( $_ eq '[%SYSDATE%]' ) {
  1063. $tmpline1 .= '\[(\d+)/(\w+)/(\d+):(\d+):(\d+):(\d+)\s+\S+\]';
  1064. $tmpline2 .= '
  1065. $log_day = $' . ++$offset . ';
  1066. $log_month = $' . ++$offset . ';
  1067. $log_year = $' . ++$offset . ';
  1068. $log_hour = $' . ++$offset . ';
  1069. $log_min = $' . ++$offset . ';
  1070. $log_sec = $' . ++$offset . ';';
  1071. } elsif ( $_ eq '%Ses->client.ip%' ) {
  1072. $tmpline1 .= '([\w\-\.:]+)';
  1073. $tmpline2 .= '
  1074. $log_requester = $' . ++$offset . ';';
  1075. } elsif ( $_ eq '%Req->vars.pauth-user%' ) {
  1076. $tmpline1 .= '(\S+)';
  1077. $tmpline2 .= '
  1078. $log_ident = $' . ++$offset . ';';
  1079. } elsif ( $_ eq '%Req->vars.remote-status%'
  1080. or $_ eq '%Req->vars.r2p-cl%'
  1081. or $_ eq '%Req->vars.cli-status%'
  1082. or $_ eq '%Req->vars.svr-status%'
  1083. or $_ eq '%Req->vars.cch-status%' )
  1084. {
  1085. $tmpline1 .= '[\w\-\.]+';
  1086. } elsif ( $_ eq '"%Req->reqpb.proxy-request%"' ) {
  1087. $tmpline1 .= '\"(\w+)\s+([^\"]+)\s+\S+\"';
  1088. $tmpline2 .= '
  1089. $log_method = $' . ++$offset . ';
  1090. $log_url = $' . ++$offset . ';';
  1091. } elsif ( $_ eq '%Req->srvhdrs.clf-status%' ) {
  1092. $tmpline1 .= '([\d\-]+)';
  1093. $tmpline2 .= '
  1094. $log_code = $' . ++$offset . ';';
  1095. } elsif ( $_ eq '%Req->vars.p2c-cl%' ) {
  1096. $tmpline1 .= '([\d\-]+)';
  1097. $tmpline2 .= '
  1098. $log_size = $' . ++$offset . ';';
  1099. } elsif ( $_ eq '%Req->headers.content-length%'
  1100. or $_ eq '%Req->vars.p2r-cl%'
  1101. or $_ eq '%Req->vars.c2p-hl%'
  1102. or $_ eq '%Req->vars.p2c-hl%'
  1103. or $_ eq '%Req->vars.p2r-hl%'
  1104. or $_ eq '%Req->vars.r2p-hl%' )
  1105. {
  1106. $tmpline1 .= '[\d\-]+';
  1107. } elsif ( $_ eq '%Req->vars.xfer-time%' ) {
  1108. $tmpline1 .= '([\d\.]+)';
  1109. $tmpline2 .= '
  1110. $log_reqtime = $' . ++$offset . ' * 1000;';
  1111. } elsif ( $_ eq '%route%' ) {
  1112. $tmpline1 .= '(\d+)';
  1113. $tmpline2 .= '
  1114. $log_cached = $' . ++$offset . ';';
  1115. } elsif ( $_ eq '%Req->vars.actual-route%' ) {
  1116. $tmpline1 .= '(\S+)';
  1117. $tmpline2 .= '
  1118. $log_hier = $' . ++$offset . ';
  1119. if ( $log_hier =~ m#[\(\)]# ) {
  1120. $log_hier =~ s#^(\w+)(\((\S+)\))?$#$1/$3#;
  1121. $log_status = \'TCP_MISS/-\';
  1122. } elsif ( $log_hier =~ m#-# ) {
  1123. $log_hier = $log_hier . \'/-\';
  1124. $log_status = \'TCP_HIT/-\';
  1125. } else {
  1126. $log_hier = $log_hier . \'/-\';
  1127. $log_status = \'TCP_MISS/-\';
  1128. }';
  1129. } elsif ( $_ eq '-' ) {
  1130. $tmpline1 .= '-';
  1131. } else {
  1132. print STDERR "$0: I don't know this input format. Please check the
  1133. input. If you\'re sure that the following is NOT corrupt and the error also
  1134. occurs with the recent version of Calamaris (see the README for pointers and
  1135. known bugs) then report it with the following line to <Calamaris-bug\@Cord.de>.
  1136. Thank You.\n\n$_\n\n";
  1137. exit(1);
  1138. }
  1139. }
  1140. foreach $pattern ( qw(%Ses->client.ip% [%SYSDATE%]
  1141. %Req->reqpb.proxy-request% %Req->srvhdrs.clf-status%
  1142. %Req->vars.p2c-cl% %Req->vars.xfer-time%)
  1143. )
  1144. {
  1145. unless ( grep $pattern, @fields ) {
  1146. print STDERR "$0: Your input file format is missing at least the field
  1147. \'$pattern\'. I can\'t parse it. Sorry. If you think that this field isn't
  1148. important to you, please report this error to <Calamaris-bug\@Cord.de>.
  1149. Thank You.\n\n";
  1150. exit(1);
  1151. }
  1152. }
  1153. foreach $pattern (qw(%Req->vars.pauth-user% %Req->vars.actual-route%)) {
  1154. unless ( grep /$pattern/, @fields ) {
  1155. if ( $pattern eq '%Req->vars.pauth-user%' ) {
  1156. $tmpline2 .= '
  1157. $log_ident = "-";';
  1158. } elsif ( $pattern eq '%Req->vars.actual-route%' ) {
  1159. $tmpline2 .= '
  1160. $log_hier = \'-/-\';
  1161. $log_status = \'-/-\';';
  1162. }
  1163. }
  1164. }
  1165. $loop .= $tmpline1 . '.?$#
  1166. )
  1167. {' . $tmpline2 . '
  1168. $monthcount = -1;
  1169. foreach $month (@months) {
  1170. $monthcount++;
  1171. last if ( $month eq $log_month );
  1172. }
  1173. $log_date = timegm(
  1174. $log_sec, $log_min, $log_hour, $log_day, $monthcount,
  1175. $log_year - 1900
  1176. );
  1177. } else {';
  1178. while ( defined( $line = <> ) ) {
  1179. last unless $line =~ /^\s*#/;
  1180. }
  1181. } else {
  1182. print STDERR "$0: unknown value at -f -option: \"$opt_f\"\n\n$USAGE\n\n";
  1183. exit 1;
  1184. }
  1185. $loop .= '
  1186. chomp($line);';
  1187. $loop .= '
  1188. warn(\'invalid line: "\' . $line . "\"\n");' if $opt_v;
  1189. $loop .= '
  1190. $invalid++;
  1191. next;
  1192. }';
  1193. $loop .= '
  1194. if (($log_date < $interval_begin) or ($log_date > $interval_end)) {
  1195. $skipped++;
  1196. next;
  1197. }
  1198. ' if $opt_I;
  1199. $loop .= '
  1200. $log_reqtime = .1 if $log_reqtime == 0;
  1201. ( $log_hitfail, $log_code ) = split \'/\', $log_status;
  1202. $log_size = 0 if ( $log_size eq \'-\' );
  1203. $log_url =~ s/\?.*$/?/;
  1204. @url = split m#[/\\\]#o, $log_url;
  1205. ( $urlprot, $urlhost, $urlext ) = (@url)[ 0, 2, $#url ];
  1206. $urlext = \'.<none>\' if $#url <= 2;
  1207. if ( $#url <= -1 ) {
  1208. $urlext = \'.<error>\';
  1209. $urlprot = $urlhost = \'<error>\';
  1210. }
  1211. $urlext = \'.<dynamic>\'
  1212. if ( $urlext =~ m#[\?;&\$,!@=|%]#o or $log_method eq \'POST\' );
  1213. unless ( defined $urlhost ) {
  1214. $urlhost = $urlprot;';
  1215. $loop .= '
  1216. $log_content = '
  1217. unless $opt_f eq 'squid-old'
  1218. or $opt_f eq 'elff'
  1219. or $opt_f eq 'nse';
  1220. $loop .= '
  1221. $urlprot = \'<secure>\';
  1222. $urlext = \'.<secure>\';
  1223. }
  1224. $urlhost =~ s#^.*@##o;
  1225. $urlhost =~ s#[:\?].*$##o;
  1226. $urlhost =~ tr/A-Z/a-z/;
  1227. @urlext = split \'\.\', $urlext;
  1228. $urlext = (@urlext)[$#urlext];
  1229. $urlext = \'<none>\' if $#urlext <= 0;';
  1230. $loop .= '
  1231. $urlext =~ tr/A-Z/a-z/;' if $opt_c;
  1232. $loop .= '
  1233. if ( $urlhost =~ m#^(([0-9][0-9]{0,2}\.){3})[0-9][0-9]{0,2}$#o ) {';
  1234. $loop .= '
  1235. $urlhost = $1 . \'*\';' unless $opt_N == -1;
  1236. $loop .= '
  1237. $urltld = \'<unresolved>\';
  1238. } elsif ( $urlhost =~ m#^(.*\.([^\.]+\.)?)?([^\.]+\.([^\.]+))\.?$#o ) {
  1239. @list = split \'\.\', $urlhost;
  1240. $urltld = pop @list;';
  1241. if ( $opt_N != -1 ) {
  1242. $loop .= '
  1243. $urlhost = $urltld;';
  1244. for ( $i = $opt_N ; $i != 1 ; $i-- ) {
  1245. $loop .= '
  1246. $urlhost = pop (@list) . \'.\' . $urlhost if $#list >= 0;';
  1247. }
  1248. $loop .= '
  1249. $urlhost = pop (@list) . \'.\' . $urlhost
  1250. if ( $urltld =~
  1251. m#^(a[rtu]|br|c[no]|hk|i[dlm]|jp|kr|l[by]|m[oxy]|nz|p[elnry]|sg|t[hrw]|u[aks]|ve|yu|za)$#o
  1252. and $#list >= 0 );
  1253. $urlhost = \'*.\' . $urlhost if $#list >= 0;
  1254. $urltld = \'*.\' . $urltld;';
  1255. }
  1256. $loop .= '
  1257. } elsif ( $urlhost =~ m#([!a-z0-9\.\-]|\.\.)#o ) {
  1258. $urlhost = $urltld = $urlext = $urlprot = \'<error>\';
  1259. } else {
  1260. $urltld = $urlhost;
  1261. }';
  1262. if ($opt_n) {
  1263. $loop .= '
  1264. $requester = $log_requester;';
  1265. } else {
  1266. $loop .= '
  1267. $requester = getfqdn($log_requester);';
  1268. }
  1269. $loop .= '
  1270. $requester = $log_ident . \'@\' . $requester if $log_ident ne \'-\';'
  1271. if $opt_u;
  1272. $loop .= '
  1273. ( $log_hier_method, $log_hier_host ) = ( split \'/\', $log_hier )[ 0, 1 ];';
  1274. $loop .= '
  1275. $log_content = \'<unknown>\' if $log_content eq \'-\';
  1276. $log_content =~ tr/A-Z/a-z/;
  1277. $log_content = '
  1278. unless $opt_f eq 'squid-old'
  1279. or $opt_f eq 'elff'
  1280. or $opt_f eq 'nse';
  1281. $loop .= '
  1282. $urlhost = $urltld = $urlext = $urlprot = \'<error>\'
  1283. if ( $log_code =~ m#^[45]#o );';
  1284. $loop .= "
  1285. print STDERR '#' if (0 == (\$counter % $opt_b));" if $opt_b;
  1286. $loop .= '
  1287. $counter++;
  1288. $size += $log_size;
  1289. $time += $log_reqtime;
  1290. $method{$log_method} = $method_size{$log_method} =
  1291. $method_time{$log_method} = 0
  1292. unless defined $method{$log_method};
  1293. $method{$log_method}++;
  1294. $method_size{$log_method} += $log_size;
  1295. $method_time{$log_method} += $log_reqtime;
  1296. $time_begin = $log_date if $log_date < $time_begin;
  1297. $time_end = $log_date if $log_date > $time_end;';
  1298. if ( defined $opt_p ) {
  1299. $loop .= '
  1300. if ( defined(@peak_all) ) {
  1301. if ( $log_date < $peak_all[$#peak_all] ) {
  1302. $peak_warn =
  1303. \'Peak values are most likely wrong due to unsorted input!\';
  1304. undef(@peak_all);
  1305. undef(@peak_udp);
  1306. undef(@peak_tcp);
  1307. $peak_all_min_pointer = $peak_all_sec_pointer = $peak_tcp_min_pointer =
  1308. $peak_tcp_sec_pointer = $peak_udp_min_pointer =
  1309. $peak_udp_sec_pointer = 0;
  1310. chomp($line);
  1311. warn( \'unsorted input: "\' . $line . "\"\n" ) if $opt_v;
  1312. }
  1313. }';
  1314. if ( $opt_p eq 'old' ) {
  1315. $loop .= '
  1316. $peak_all_sec_pointer++;
  1317. $peak_all_min_pointer++;
  1318. unshift ( @peak_all, $log_date );
  1319. $peak_all_sec_pointer--
  1320. while $peak_all[ $peak_all_sec_pointer - 1 ] < ( $log_date - 1 );
  1321. $peak_all_min_pointer--
  1322. while $peak_all[ $peak_all_min_pointer - 1 ] < ( $log_date - 60 );
  1323. pop (@peak_all) while $peak_all[$#peak_all] < ( $log_date - 3600 );
  1324. if ( $peak_all_hour < @peak_all ) {
  1325. $peak_all_hour = @peak_all;
  1326. $peak_all_hour_time = $log_date - 3600;
  1327. }
  1328. if ( $peak_all_min < $peak_all_min_pointer ) {
  1329. $peak_all_min = $peak_all_min_pointer;
  1330. $peak_all_min_time = $log_date - 60;
  1331. }
  1332. if ( $peak_all_sec < $peak_all_sec_pointer ) {
  1333. $peak_all_sec = $peak_all_sec_pointer;
  1334. $peak_all_sec_time = $log_date - 1;
  1335. }';
  1336. } elsif ( $opt_p eq 'new' ) {
  1337. $loop .= '
  1338. $date_hour = int( ( $log_date - ( $log_reqtime / 1000 ) ) / 3600 ) * 3600;
  1339. foreach $i ( ( $date_hour / 3600 ) .. int( $log_date / 3600 ) ) {
  1340. $peak_all_hour{ $i * 3600 } = $peak_all_hour_size{ $i * 3600 } = 0
  1341. unless defined $peak_all_hour{ $i * 3600 };
  1342. $peak_all_hour{ $i * 3600 }++;
  1343. $peak_all_hour_size{ $i * 3600 } +=
  1344. $log_size / int( $log_reqtime / 3600000 + 1 );
  1345. }
  1346. $peak_all_sec_pointer++;
  1347. unshift ( @peak_all, $log_date );
  1348. $peak_all_sec_pointer--
  1349. while $peak_all[ $peak_all_sec_pointer - 1 ] < ( $log_date - 1 );
  1350. pop (@peak_all) while $peak_all[$#peak_all] < ( $log_date - 60 );
  1351. if ( $peak_all_min < @peak_all ) {
  1352. $peak_all_min = @peak_all;
  1353. $peak_all_min_time = $log_date - 60;
  1354. }
  1355. if ( $peak_all_sec < $peak_all_sec_pointer ) {
  1356. $peak_all_sec = $peak_all_sec_pointer;
  1357. $peak_all_sec_time = $log_date - 1;
  1358. }';
  1359. } else {
  1360. print STDERR
  1361. "$0: unknown value at -p -option: \"$opt_p\"\n\n$USAGE\n\n";
  1362. exit 1;
  1363. }
  1364. }
  1365. $loop .= '
  1366. if ( ( $log_method =~ m#^ICP_#o ) or ( $log_status =~ m#^ICP#o ) ) {
  1367. $udp++;
  1368. $udp_size += $log_size;
  1369. $udp_time += $log_reqtime;';
  1370. $loop .= '
  1371. $udp_requester{$requester} = $udp_requester_size{$requester} =
  1372. $udp_requester_time{$requester} = $udp_hit_requester{$requester} =
  1373. $udp_hit_requester_size{$requester} = 0
  1374. unless defined $udp_requester{$requester};
  1375. $udp_requester{$requester}++;
  1376. $udp_requester_size{$requester} += $log_size;
  1377. $udp_requester_time{$requester} += $log_reqtime;' if ($opt_r);
  1378. $loop .= '
  1379. $udp_requester_urlhost{$requester}{$urlhost} =
  1380. $udp_requester_urlhost_size{$requester}{$urlhost} =
  1381. $udp_requester_urlhost_time{$requester}{$urlhost} =
  1382. $udp_hit_requester_urlhost{$requester}{$urlhost} =
  1383. $udp_hit_requester_urlhost_size{$requester}{$urlhost} = 0
  1384. unless defined $udp_requester_urlhost{$requester}{$urlhost};
  1385. $udp_requester_urlhost{$requester}{$urlhost}++;
  1386. $udp_requester_urlhost_size{$requester}{$urlhost} += $log_size;
  1387. $udp_requester_urlhost_time{$requester}{$urlhost} += $log_reqtime;'
  1388. if ($opt_R);
  1389. if ( not defined $opt_p ) {
  1390. } elsif ( $opt_p eq 'old' ) {
  1391. $loop .= '
  1392. $peak_udp_sec_pointer++;
  1393. $peak_udp_min_pointer++;
  1394. unshift ( @peak_udp, $log_date );
  1395. $peak_udp_sec_pointer--
  1396. while $peak_udp[ $peak_udp_sec_pointer - 1 ] < ( $log_date - 1 );
  1397. $peak_udp_min_pointer--
  1398. while $peak_udp[ $peak_udp_min_pointer - 1 ] < ( $log_date - 60 );
  1399. pop @peak_udp while $peak_udp[$#peak_udp] < ( $log_date - 3600 );
  1400. if ( $peak_udp_hour < @peak_udp ) {
  1401. $p

Large files files are truncated, but you can click here to view the full file