-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinroute-report.pl
1861 lines (1620 loc) · 54.3 KB
/
winroute-report.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/perl -w
#
#$Id: winroute-report.pl, v 1.64, 2012/07/19 12:28 camilohe Exp camilohe$
#
# Copyright (c)2011 Camilo E. Hidalgo Estevez <[email protected]>. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the GNU General Public License
##
## Winroute Top Users, Pages reporting script.
##
## Description:
## This script will parse the specified Winroute logfile and generate an HTML
## report with top users/pages by visits/size.
##
## Author:
## Dave Hope - http://davehope.co.uk (Author of top-sites-size.pl)
## Sava Chankov ( Author of squid-report.pl )
##
## Known Issues:
## + Requests to the webserver on the proxy give weird results?
##
## Changelog:
## 1.0.0 Initial fork of top-sites-size.pl v1.2
## 1.0.1
## + Changed code to parse winroute log format.
## + Removed content type checks (content-type field is not available).
## 1.0.2
## + Fixed issue with accessing on ports other than 80 (handle :port in page url).
## + Fixed problem with https:// entries in log.
## 1.1.0
## + Added users reports.
## + Re-orderd optional arguments (report, top -> top, report).
## + Updated POD documentation.
## 1.1.1
## + Improved debugging support.
## + Fixed issue with invalid (non alpha-numeric) user names.
## + Fixed issue with invalid (non numeric) http sizes.
## 1.2.0
## + Added hosts (IPs) reports.
## 1.2.1
## + Added HTTP codes reports.
## 1.3.0
## + Added HTTP codes x Pages reports.
## 1.3.1
## + Added Users x Pages reports.
## + Added Pages x Users reports.
## 1.3.2
## + Added Hosts (IPs)/Pages reports.
## 1.4.0
## + Added Pages x Hosts reports.
## + Added Pages x Codes reports.
## 1.4.1
## + Added Available Reports.
## 1.5.0
## + Added filtering out items below mininum hits/size.
## 1.5.1
## + Fixed some bugs.
## + Raised cfgNumberToShow to 50, cfgMinHits to 100 and cfgMinSize to 100 KB.
## 1.6.0
## + Reordered reports.
## + Added Users x Codes reports.
## + Added Hosts x Codes reports.
## + Added Codes x Users reports.
## + Added Codes x Hosts reports.
## + Added filtering out second level items below mininum hits/size.
## 1.6.2
## + Added Methods reports.
## + Better perldoc
## 1.6.3
## + Added Types reports.
## 1.6.4
## + Replaced sites by pages and a few minor changes.
##
## License:
## This program is free software; you can redistribute it and/or modify it
## under the GNU General Public License.
##
## This script is based on 'top-sites-size.pl' v1.2 by Dave Hope which can be
## found at http://davehope.co.uk and 'squid-report.pl' v1.2 by Sava Chankov and
## has been adjusted for my specific requirements.
##
## The original script can be found here:
## http://backpan.perl.org/authors/id/S/SA/SAVA/squid-report.pl
##
use strict;
##
# Configuration.
##
my $cfgNumberToShow = 100; # show top 100 only
my $cfgMinHits = 100; # require at least 100 hits to show
my $cfgMinSize = 100 * 1024; # require at least 100 KB to show
my $cfgOutput = "winroute-report.html";
# debug anyone? -- from 0 to 9
my $debug = 0;
my $ver = "1.63";
##
# Stop editing here unless you know what you're doing.
##
my $cfgDate = localtime; # gmtime;
my ($ip, $minus, $user, $datetime, $timezone, $http_method, $url, $http_ver, $http_code, $http_size, $plus);
my ($SortMethod, $row, $page_url, %pages, $dir, $file, $ItemsLeft, $SubItemsLeft);
my (%users, $user_name, %hosts, $host_ip, %codes, $code, $method, $type);
my (%pagesxusers, %pagesxcodes, %pagesxhosts, %usersxpages, %usersxcodes, %hostsxpages, %hostsxcodes);
my (%codesxpages, %codesxusers, %codesxhosts, %methods, %types, %typesxusers, %typesxhosts);
$dir = $ARGV[0];
if (!$dir) {print_usage();}
if ($dir =~ m/[\/\-]\?/ ) {print_usage();}
if ($dir =~ m/[\/\-][hH]/ ) {print_usage();}
if ($dir =~ m/[\/\-][vV]/ ) {print_version();}
$cfgNumberToShow = $ARGV[1] unless !$ARGV[1] ;
print "cfgNumberToShow: $cfgNumberToShow \n" if ($debug) ;
$cfgOutput = $dir . ".html";
$cfgOutput = $ARGV[2] unless !$ARGV[2];
print "cfgOutput: $cfgOutput \n" if ($debug) ;
opendir(DIR, $dir) or die "Can't open directory $dir!\n";
# initialize line counters
my $lines = 0;
my $bad_lines = 0;
# start timer
my $start_run = time();
##
# Iterate through lines in each file found in $dir
##
while( defined( $file = readdir(DIR) ) )
{
# Skip files not matching http.log[.xyz]
if ($file !~ m/^http\.log\.?\d*$/)
{
print "Skipping file $dir/$file\n" if ($debug);
next;
};
open(LOG, "<$dir/$file") or die "Can't open file $dir/$file!\n";
print "Parsing file $dir/$file\n" if ($debug);
while(<LOG>)
{
# just for readability
$row = $_;
# count line
$lines++;
# sample line from kerio winroute http log
# 192.168.206.15 - Admin [16/Feb/2011:17:19:57 -0500] "GET http://z.about.com/6/g/ruby/b/rss2.xml HTTP/1.1" 200 10870 +3
# parse winroute log line by splitting on white space, not the best way but it works for our purposes.
($ip, $minus, $user, $datetime, $timezone, $http_method, $url, $http_ver, $http_code, $http_size, $plus) = split(/\s+/, $row);
print "$ip, $minus, $user, $datetime, $timezone, $http_method, $url, $http_ver, $http_code, $http_size, $plus\n" if ($debug>7);
print "$row\n" if ($debug>8);
# Remove https://, http://, ftp://
## $url =~ s/https:\/\///;
## $url =~ s/http:\/\///;
## $url =~ s/ftp:\/\///;
# Remove www.
# $url =~ s/www.//;
# Remove trailing slash
## $url =~ s/\/$//;
# If the url is empty (just in case, really! It has to occur in my logs yet ;-)
# then don't add it to the list.
if (!$url )
{
print " Empty url:$url\n" if ($debug>1);
print " Row: $row\n" if ($debug>3);
$bad_lines++;
next;
};
# If the user is invalid (which occurs occasionally in my logs, no idea why),
# then don't add it to the list.
if ($user !~ m/^[a-zA-Z-]+$/)
{
print " Bad user:$user\n" if ($debug>1);
print " IP: $ip, Page: $page_url, Code: $http_code, Size: $http_size\n" if ($debug>2);
print " Row: $row\n" if ($debug>3);
$bad_lines++;
next;
}
# If the size is non numeric (which also occurs occasionally in my logs, no idea
# why), then don't add it to the list.
if ($http_size !~ m/^[0-9]+$/ )
{
print " Bad size:$http_size\n" if ($debug>1);
print " IP: $ip, Page: $page_url, Code: $http_code, Size: $http_size\n" if ($debug>2);
print " Row: $row\n" if ($debug>3);
$bad_lines++;
next;
}
# Get the site base url, e.g. what is between the second and the third slash in
# http://wc.cmc.com.cu:3000/WorldClient.dll?View=Logout
## ($site_url) = ($url =~ m{ ([A-Za-z0-9\.\-\:]+) }x );
# Match what is between the second slash and the first question mark or non allowed
# character or to the end -- I think ;-)
## ($page_url) = ($url =~ m{ ([A-Za-z0-9\.\-\:\/\_\%]+) }x );
## ($page_url) = ($url =~ m{ ([A-Za-z0-9\.\-\:\/\_\%\?\&\+\;]+) }x );
# Remove leading " from http method
$http_method =~ s/\"//;
## $page_url = "$http_method $url";
$page_url = $url;
($type) = ($url =~ m{ (\.[A-Za-z0-9]+)$ }x );
$type = "n/a" unless ($type);
print " Type:$type\n" if ($debug>2);
# Count method.
if (!$methods{$http_method})
{
$methods{$http_method}->{count} = 0;
print " Found method:$http_method\n" if ($debug>1);
}
$methods{$http_method}->{count}++;
# Update method size.
if (!$methods{$http_method}->{size})
{
$methods{$http_method}->{size} = 0;
}
$methods{$http_method}->{size} += $http_size;
# Count type.
if (!$types{$type})
{
$types{$type}->{count} = 0;
print " Found type:$type\n" if ($debug>1);
}
$types{$type}->{count}++;
# Update type size.
if (!$types{$type}->{size})
{
$types{$type}->{size} = 0;
}
$types{$type}->{size} += $http_size;
# Count type/user.
if (!$typesxusers{$type}{$user})
{
$typesxusers{$type}{$user}->{count} = 0;
print " Found type/user:$type/$user\n" if ($debug>1);
}
$typesxusers{$type}{$user}->{count}++;
# Update type/user size.
if (!$typesxusers{$type}{$user}->{size})
{
$typesxusers{$type}{$user}->{size} = 0;
}
$typesxusers{$type}{$user}->{size} += $http_size;
# Count type/host.
if (!$typesxhosts{$type}{$ip})
{
$typesxhosts{$type}{$ip}->{count} = 0;
print " Found type/host:$type/$ip\n" if ($debug>1);
}
$typesxhosts{$type}{$ip}->{count}++;
# Update type/host size.
if (!$typesxhosts{$type}{$ip}->{size})
{
$typesxhosts{$type}{$ip}->{size} = 0;
}
$typesxhosts{$type}{$ip}->{size} += $http_size;
# If hash already contains an entry for the exact page url.
if ($pages{$page_url})
{
$pages{$page_url}->{count}++;
}
# If no matching entry exists, create one.
else
{
$pages{$page_url}->{count} = 1;
print " Found page:$page_url\n" if ($debug>1);
}
# Update size of content for webpage regardless of content-type.
if (!$pages{$page_url}->{size})
{
$pages{$page_url}->{size} = 0;
}
$pages{$page_url}->{size} = $pages{$page_url}->{size} + $http_size;
# If hash already contains an entry for the exact page url/user.
if ($pagesxusers{$page_url}{$user})
{
$pagesxusers{$page_url}{$user}->{count}++;
}
# If no matching entry exists, create one.
else
{
$pagesxusers{$page_url}{$user}->{count} = 1;
print " Found page/user:$page_url/$user\n" if ($debug>1);
}
# Update size of content for webpage/user regardless of content-type.
if (!$pagesxusers{$page_url}{$user}->{size})
{
$pagesxusers{$page_url}{$user}->{size} = 0;
}
$pagesxusers{$page_url}{$user}->{size} = $pagesxusers{$page_url}{$user}->{size} + $http_size;
# If hash already contains an entry for the exact page url/code.
if ($pagesxcodes{$page_url}{$http_code})
{
$pagesxcodes{$page_url}{$http_code}->{count}++;
}
# If no matching entry exists, create one.
else
{
$pagesxcodes{$page_url}{$http_code}->{count} = 1;
print " Found page/code:$page_url/$http_code\n" if ($debug>1);
}
# Update size of content for webpage/code regardless of content-type.
if (!$pagesxcodes{$page_url}{$http_code}->{size})
{
$pagesxcodes{$page_url}{$http_code}->{size} = 0;
}
$pagesxcodes{$page_url}{$http_code}->{size} = $pagesxcodes{$page_url}{$http_code}->{size} + $http_size;
# If hash already contains an entry for the exact page url/host.
if ($pagesxhosts{$page_url}{$ip})
{
$pagesxhosts{$page_url}{$ip}->{count}++;
}
# If no matching entry exists, create one.
else
{
$pagesxhosts{$page_url}{$ip}->{count} = 1;
print " Found page/host:$page_url/$ip\n" if ($debug>1);
}
# Update size of content for webpage/code regardless of content-type.
if (!$pagesxhosts{$page_url}{$ip}->{size})
{
$pagesxhosts{$page_url}{$ip}->{size} = 0;
}
$pagesxhosts{$page_url}{$ip}->{size} = $pagesxhosts{$page_url}{$ip}->{size} + $http_size;
# If hash already contains an entry for the user.
if ($users{$user})
{
$users{$user}->{count}++;
}
# If no matching entry exists, create one.
else
{
$users{$user}->{count} = 1;
print " Found user:$user\n" if ($debug);
}
# Update size for user.
if (!$users{$user}->{size})
{
$users{$user}->{size} = 0;
}
$users{$user}->{size} = $users{$user}->{size} + $http_size;
# If hash already contains an entry for the user/page.
if ($usersxpages{$user}{$page_url})
{
$usersxpages{$user}{$page_url}->{count}++;
}
# If no matching entry exists, create one.
else
{
$usersxpages{$user}{$page_url}->{count} = 1;
print " Found user/page:$user/$page_url\n" if ($debug);
}
# Update size for user/page.
if (!$usersxpages{$user}{$page_url}->{size})
{
$usersxpages{$user}{$page_url}->{size} = 0;
}
$usersxpages{$user}{$page_url}->{size} = $usersxpages{$user}{$page_url}->{size} + $http_size;
# If hash already contains an entry for the user/code.
if ($usersxcodes{$user}{$http_code})
{
$usersxcodes{$user}{$http_code}->{count}++;
}
# If no matching entry exists, create one.
else
{
$usersxcodes{$user}{$http_code}->{count} = 1;
print " Found user/code:$user/$http_code\n" if ($debug);
}
# Update size for user/code.
if (!$usersxcodes{$user}{$http_code}->{size})
{
$usersxcodes{$user}{$http_code}->{size} = 0;
}
$usersxcodes{$user}{$http_code}->{size} = $usersxcodes{$user}{$http_code}->{size} + $http_size;
# If hash already contains an entry for the host.
if ($hosts{$ip})
{
$hosts{$ip}->{count}++;
}
# If no matching entry exists, create one.
else
{
$hosts{$ip}->{count} = 1;
print " Found host:$ip\n" if ($debug>1);
}
# Update size for host.
if (!$hosts{$ip}->{size})
{
$hosts{$ip}->{size} = 0;
}
$hosts{$ip}->{size} = $hosts{$ip}->{size} + $http_size;
# If hash already contains an entry for the host/page.
if ($hostsxpages{$ip}{$page_url})
{
$hostsxpages{$ip}{$page_url}->{count}++;
}
# If no matching entry exists, create one.
else
{
$hostsxpages{$ip}{$page_url}->{count} = 1;
print " Found host/page:$ip/$page_url\n" if ($debug);
}
# Update size for host/page.
if (!$hostsxpages{$ip}{$page_url}->{size})
{
$hostsxpages{$ip}{$page_url}->{size} = 0;
}
$hostsxpages{$ip}{$page_url}->{size} = $hostsxpages{$ip}{$page_url}->{size} + $http_size;
# If hash already contains an entry for the host/code.
if ($hostsxcodes{$ip}{$http_code})
{
$hostsxcodes{$ip}{$http_code}->{count}++;
}
# If no matching entry exists, create one.
else
{
$hostsxcodes{$ip}{$http_code}->{count} = 1;
print " Found host/code:$ip/$http_code\n" if ($debug);
}
# Update size for host/code.
if (!$hostsxcodes{$ip}{$http_code}->{size})
{
$hostsxcodes{$ip}{$http_code}->{size} = 0;
}
$hostsxcodes{$ip}{$http_code}->{size} = $hostsxcodes{$ip}{$http_code}->{size} + $http_size;
# If hash already contains an entry for the code.
if ($codes{$http_code})
{
$codes{$http_code}->{count}++;
}
# If no matching entry exists, create one.
else
{
$codes{$http_code}->{count} = 1;
print " Found code:$http_code\n" if ($debug);
}
# Update size for code.
if (!$codes{$http_code}->{size})
{
$codes{$http_code}->{size} = 0;
}
$codes{$http_code}->{size} = $codes{$http_code}->{size} + $http_size;
# If hash already contains an entry for the code/page.
if ($codesxpages{$http_code}{$page_url})
{
$codesxpages{$http_code}{$page_url}->{count}++;
}
# If no matching entry exists, create one.
else
{
$codesxpages{$http_code}{$page_url}->{count} = 1;
print " Found code/page:$http_code/$page_url\n" if ($debug);
}
# Update size for code/page.
if (!$codesxpages{$http_code}{$page_url}->{size})
{
$codesxpages{$http_code}{$page_url}->{size} = 0;
}
$codesxpages{$http_code}{$page_url}->{size} = $codesxpages{$http_code}{$page_url}->{size} + $http_size;
# If hash already contains an entry for the code/user.
if ($codesxusers{$http_code}{$user})
{
$codesxusers{$http_code}{$user}->{count}++;
}
# If no matching entry exists, create one.
else
{
$codesxusers{$http_code}{$user}->{count} = 1;
print " Found code/user:$http_code/$user\n" if ($debug);
}
# Update size for code/page.
if (!$codesxusers{$http_code}{$user}->{size})
{
$codesxusers{$http_code}{$user}->{size} = 0;
}
$codesxusers{$http_code}{$user}->{size} = $codesxusers{$http_code}{$user}->{size} + $http_size;
# If hash already contains an entry for the code/host.
if ($codesxhosts{$http_code}{$ip})
{
$codesxhosts{$http_code}{$ip}->{count}++;
}
# If no matching entry exists, create one.
else
{
$codesxhosts{$http_code}{$ip}->{count} = 1;
print " Found code/host:$http_code/$ip\n" if ($debug);
}
# Update size for code/page.
if (!$codesxhosts{$http_code}{$ip}->{size})
{
$codesxhosts{$http_code}{$ip}->{size} = 0;
}
$codesxhosts{$http_code}{$ip}->{size} = $codesxhosts{$http_code}{$ip}->{size} + $http_size;
}
}
# print parsing stats
my $end_run = time();
my $run_time = $end_run - $start_run;
print "$lines lines processed in $run_time seconds\n";
print "$bad_lines invalid lines were skipped\n";
$start_run = time();
##
# Open output file
##
open(OUTPUT, ">$cfgOutput") || die("Cannot open output file $cfgOutput\n");
##
# Print header HTML
##
print OUTPUT <<END;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://gmpg.org/xfn/11">
<title>Winroute Top Users and Pages Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
<!--
body { font: normal 0.8em 'Trebuchet MS' }
ul { list-style-type: none }
ul a { position: absolute; left: 180px }
ul ul a { position: absolute; left: 220px }
#Generated { margin: 0; padding: 0; font-style:italic; border-bottom: 1px solid #cecece; }
#Footer { color: #cecece; line-height: 150%; border-top: 1px solid #cecece; padding: 0.4em }
-->
</style>
</head>
<body>
END
print OUTPUT <<END;
<h1>Winroute Top Users and Pages Report</h1>
<p id="Generated">Report generated on $cfgDate</p>
END
print OUTPUT <<END;
<h1>Available Reports</h1>
<ul>
<li>.<a href="#pages-hits">Top Pages by Visits</a></li>
<li>.<a href="#pages-size">Top Pages by Size</a></li>
<li>.<a href="#users-hits">Top Users by Visits</a></li>
<li>.<a href="#users-size">Top Users by Size</a></li>
<li>.<a href="#hosts-hits">Top Hosts by Visits</a></li>
<li>.<a href="#hosts-size">Top Hosts by Size</a></li>
<li>.<a href="#codes-hits">Top Codes by Visits</a></li>
<li>.<a href="#codes-size">Top Codes by Size</a></li>
<li>.<a href="#verbs-hits">Top Methods by Visits</a></li>
<li>.<a href="#verbs-size">Top Methods by Size</a></li>
<li>.<a href="#types-hits">Top Types by Visits</a></li>
<li>.<a href="#types-size">Top Types by Size</a></li>
<br/>
<li>.<a href="#pagesxusers-hits">Top Pages/Users by Visits</a></li>
<li>.<a href="#pagesxusers-size">Top Pages/Users by Size</a></li>
<li>.<a href="#pagesxhosts-hits">Top Pages/Hosts by Visits</a></li>
<li>.<a href="#pagesxhosts-size">Top Pages/Hosts by Size</a></li>
<li>.<a href="#pagesxcodes-hits">Top Pages/Codes by Visits</a></li>
<li>.<a href="#pagesxcodes-size">Top Pages/Codes by Size</a></li>
<li>.<a href="#usersxpages-hits">Top Users/Pages by Visits</a></li>
<li>.<a href="#usersxpages-size">Top Users/Pages by Size</a></li>
<li>.<a href="#usersxcodes-hits">Top Users/Codes by Visits</a></li>
<li>.<a href="#usersxcodes-size">Top Users/Codes by Size</a></li>
<li>.<a href="#hostsxpages-hits">Top Hosts/Pages by Visits</a></li>
<li>.<a href="#hostsxpages-size">Top Hosts/Pages by Size</a></li>
<li>.<a href="#hostsxcodes-hits">Top Hosts/Codes by Visits</a></li>
<li>.<a href="#hostsxcodes-size">Top Hosts/Codes by Size</a></li>
<li>.<a href="#codesxpages-hits">Top Codes/Pages by Visits</a></li>
<li>.<a href="#codesxpages-size">Top Codes/Pages by Size</a></li>
<li>.<a href="#codesxusers-hits">Top Codes/Users by Visits</a></li>
<li>.<a href="#codesxusers-size">Top Codes/Users by Size</a></li>
<li>.<a href="#codesxhosts-hits">Top Codes/Hosts by Visits</a></li>
<li>.<a href="#codesxhosts-size">Top Codes/Hosts by Size</a></li>
<li>.<a href="#typesxusers-hits">Top Types/Users by Visits</a></li>
<li>.<a href="#typesxusers-size">Top Types/Users by Size</a></li>
<li>.<a href="#typesxhosts-hits">Top Types/Hosts by Visits</a></li>
<li>.<a href="#typesxhosts-size">Top Types/Hosts by Size</a></li>
</ul>
END
print OUTPUT <<END;
<h1><a name="pages-hits">Top $cfgNumberToShow Pages by Visits</a></h1>
<ul>
END
##
# Iterate through pages sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_visits_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
print OUTPUT " <li>" . $pages{$page_url}->{count} . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a> (". format_size($pages{$page_url}->{size}) .")</li>\n" if ($pages{$page_url}->{count} > $cfgMinHits);
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="pages-size">Top $cfgNumberToShow Pages by Size</a></h1>
<ul>
END
##
# Iterate through pages sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_size_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
print OUTPUT " <li>" . format_size($pages{$page_url}->{size}) . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a> (". $pages{$page_url}->{count} .")</li>\n" if ($pages{$page_url}->{size} > $cfgMinSize);
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="users-hits">Top Users by Visits</a></h1>
<ul>
END
##
# Iterate through users sorted by visits.
##
$SortMethod = "users_by_visits_then_name";
foreach $user_name ( sort ($SortMethod keys (%users) ) )
{
print OUTPUT " <li>" . $users{$user_name}->{count} . "<a href=\"#" . $user_name . "\">" . $user_name . "</a> (". format_size($users{$user_name}->{size}) .")</li>\n" if ($users{$user_name}->{count} > $cfgMinHits);
}
print OUTPUT <<END;
</ul>
<h1><a name="users-size">Top Users by Size</a></h1>
<ul>
END
##
# Iterate through users sorted by size.
##
$SortMethod = "users_by_size_then_name";
foreach $user_name ( sort ($SortMethod keys (%users) ) )
{
print OUTPUT " <li>" . format_size($users{$user_name}->{size}) . "<a href=\"#" . $user_name . "\">" . $user_name . "</a> (". $users{$user_name}->{count} .")</li>\n" if ($users{$user_name}->{size} > $cfgMinSize);
}
print OUTPUT <<END;
</ul>
<h1><a name="hosts-hits">Top $cfgNumberToShow Hosts (IPs) by Visits</a></h1>
<ul>
END
##
# Iterate through hosts (IPs) sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "hosts_by_visits_then_name";
foreach $host_ip ( sort ($SortMethod keys (%hosts) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
print OUTPUT " <li>" . $hosts{$host_ip}->{count} . "<a href=\"#" . $host_ip . "\">" . $host_ip . "</a> (". format_size($hosts{$host_ip}->{size}) .")</li>\n" if ($hosts{$host_ip}->{count} > $cfgMinHits);
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="hosts-size">Top $cfgNumberToShow Hosts (IPs) by Size</a></h1>
<ul>
END
##
# Iterate through hosts (IPs) sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "hosts_by_size_then_name";
foreach $host_ip ( sort ($SortMethod keys (%hosts) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
print OUTPUT " <li>" . format_size($hosts{$host_ip}->{size}) . "<a href=\"#" . $host_ip . "\">" . $host_ip . "</a> (". $hosts{$host_ip}->{count} .")</li>\n" if ($hosts{$host_ip}->{size} > $cfgMinSize);
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="codes-hits">Top HTTP Codes by Visits</a></h1>
<ul>
END
##
# Iterate through codes sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "codes_by_visits_then_name";
foreach $code ( sort ($SortMethod keys (%codes) ) )
{
print OUTPUT " <li>" . $codes{$code}->{count} . "<a href=\"#" . $code . "\">" . $code . "</a> (". format_size($codes{$code}->{size}) .")</li>\n" if ($codes{$code}->{count} > $cfgMinHits);
}
print OUTPUT <<END;
</ul>
<h1><a name="codes-size">Top HTTP Codes by Size</a></h1>
<ul>
END
##
# Iterate through codes sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "codes_by_size_then_name";
foreach $code ( sort ($SortMethod keys (%codes) ) )
{
print OUTPUT " <li>" . format_size($codes{$code}->{size}) . "<a href=\"#" . $code . "\">" . $code . "</a> (". $codes{$code}->{count} .")</li>\n" if ($codes{$code}->{size} > $cfgMinSize);
}
print OUTPUT <<END;
</ul>
<h1><a name="verbs-hits">Top HTTP Methods by Visits</a></h1>
<ul>
END
##
# Iterate through methods sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "verbs_by_visits_then_name";
foreach $method ( sort ($SortMethod keys (%methods) ) )
{
print OUTPUT " <li>" . $methods{$method}->{count} . "<a href=\"#" . $method . "\">" . $method . "</a> (". format_size($methods{$method}->{size}) .")</li>\n" if ($methods{$method}->{count} > $cfgMinHits);
}
print OUTPUT <<END;
</ul>
<h1><a name="verbs-size">Top HTTP Methods by Size</a></h1>
<ul>
END
##
# Iterate through methods sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "verbs_by_size_then_name";
foreach $method ( sort ($SortMethod keys (%methods) ) )
{
print OUTPUT " <li>" . format_size($methods{$method}->{size}) . "<a href=\"#" . $method . "\">" . $method . "</a> (". $methods{$method}->{count} .")</li>\n" if ($methods{$method}->{size} > $cfgMinSize);
}
print OUTPUT <<END;
</ul>
<h1><a name="types-hits">Top File Types by Visits</a></h1>
<ul>
END
##
# Iterate through methods sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "types_by_visits_then_name";
foreach $type ( sort ($SortMethod keys (%types) ) )
{
print OUTPUT " <li>" . $types{$type}->{count} . "<a href=\"#" . $type . "\">" . $type . "</a> (". format_size($types{$type}->{size}) .")</li>\n" if ($types{$type}->{count} > $cfgMinHits);
}
print OUTPUT <<END;
</ul>
<h1><a name="types-size">Top File Types by Size</a></h1>
<ul>
END
##
# Iterate through methods sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "types_by_size_then_name";
foreach $type ( sort ($SortMethod keys (%types) ) )
{
print OUTPUT " <li>" . format_size($types{$type}->{size}) . "<a href=\"#" . $type . "\">" . $type . "</a> (". $types{$type}->{count} .")</li>\n" if ($types{$type}->{size} > $cfgMinSize);
}
print OUTPUT <<END;
</ul>
<h1><a name="pagesxusers-hits">Top $cfgNumberToShow Pages/Users by Visits</a></h1>
<ul>
END
##
# Iterate through pages/users sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_visits_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
next unless ($pages{$page_url}->{count} > $cfgMinHits);
print OUTPUT " <li>" . $pages{$page_url}->{count} . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a></li>\n";
print OUTPUT " <ul>\n";
foreach $user_name ( sort ( { $pagesxusers{$page_url}{$b}->{count} <=> $pagesxusers{$page_url}{$a}->{count} || $a cmp $b} keys ( %{ $pagesxusers{$page_url} } ) ) )
{
next unless $pagesxusers{$page_url}{$user_name}->{count} > $cfgMinHits;
print OUTPUT " <li>" . $pagesxusers{$page_url}{$user_name}->{count} . "<a href=\"#" . $user_name . "\">" . $user_name . "</a></li>\n";
}
print OUTPUT " </ul>\n";
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="pagesxusers-size">Top $cfgNumberToShow Pages/Users by Size</a></h1>
<ul>
END
##
# Iterate through pages/users sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_size_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
next unless ($pages{$page_url}->{size} > $cfgMinSize);
print OUTPUT " <li>" . format_size($pages{$page_url}->{size}) . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a></li>\n";
print OUTPUT " <ul>\n";
foreach $user_name ( sort ( { $pagesxusers{$page_url}{$b}->{size} <=> $pagesxusers{$page_url}{$a}->{size} || $a cmp $b} keys ( %{ $pagesxusers{$page_url} } ) ) )
{
next unless $pagesxusers{$page_url}{$user_name}->{size} > $cfgMinSize;
print OUTPUT " <li>" . format_size($pagesxusers{$page_url}{$user_name}->{size}) . "<a href=\"#" . $user_name . "\">" . $user_name . "</a></li>\n";
}
print OUTPUT " </ul>\n";
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="pagesxhosts-hits">Top $cfgNumberToShow Pages/Hosts (IPs) by Visits</a></h1>
<ul>
END
##
# Iterate through pages/hosts sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_visits_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
next unless ($pages{$page_url}->{count} > $cfgMinHits);
print OUTPUT " <li>" . $pages{$page_url}->{count} . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a></li>\n";
print OUTPUT " <ul>\n";
foreach $ip ( sort ( { $pagesxhosts{$page_url}{$b}->{count} <=> $pagesxhosts{$page_url}{$a}->{count} || $a cmp $b} keys ( %{ $pagesxhosts{$page_url} } ) ) )
{
next unless $pagesxhosts{$page_url}{$ip}->{count} > $cfgMinHits;
print OUTPUT " <li>" . $pagesxhosts{$page_url}{$ip}->{count} . "<a href=\"#" . $ip . "\">" . $ip . "</a></li>\n";
}
print OUTPUT " </ul>\n";
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="pagesxhosts-size">Top $cfgNumberToShow Pages/Hosts (IPs) by Size</a></h1>
<ul>
END
##
# Iterate through pages/hosts sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_size_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
next unless ($pages{$page_url}->{size} > $cfgMinSize);
print OUTPUT " <li>" . format_size($pages{$page_url}->{size}) . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a></li>\n";
print OUTPUT " <ul>\n";
foreach $ip ( sort ( { $pagesxhosts{$page_url}{$b}->{size} <=> $pagesxhosts{$page_url}{$a}->{size} || $a cmp $b} keys ( %{ $pagesxhosts{$page_url} } ) ) )
{
next unless $pagesxhosts{$page_url}{$ip}->{size} > $cfgMinSize;
print OUTPUT " <li>" . format_size($pagesxhosts{$page_url}{$ip}->{size}) . "<a href=\"#" . $ip . "\">" . $ip . "</a></li>\n";
}
print OUTPUT " </ul>\n";
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="pagesxcodes-hits">Top $cfgNumberToShow Pages/Codes by Visits</a></h1>
<ul>
END
##
# Iterate through pages/codes sorted by visits.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_visits_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
next unless ($pages{$page_url}->{count} > $cfgMinHits);
print OUTPUT " <li>" . $pages{$page_url}->{count} . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a></li>\n";
print OUTPUT " <ul>\n";
foreach $code ( sort ( { $pagesxcodes{$page_url}{$b}->{count} <=> $pagesxcodes{$page_url}{$a}->{count} || $a cmp $b} keys ( %{ $pagesxcodes{$page_url} } ) ) )
{
next unless $pagesxcodes{$page_url}{$code}->{count} > $cfgMinHits;
print OUTPUT " <li>" . $pagesxcodes{$page_url}{$code}->{count} . "<a href=\"#" . $code . "\">" . $code . "</a></li>\n";
}
print OUTPUT " </ul>\n";
$ItemsLeft--;
}
}
print OUTPUT <<END;
</ul>
<h1><a name="pagesxcodes-size">Top $cfgNumberToShow Pages/Codes by Size</a></h1>
<ul>
END
##
# Iterate through pages/codes sorted by size.
##
$ItemsLeft = $cfgNumberToShow;
$SortMethod = "pages_by_size_then_name";
foreach $page_url ( sort ($SortMethod keys (%pages) ) )
{
# Only show top x entries.
if ($ItemsLeft > 0)
{
next unless ($pages{$page_url}->{size} > $cfgMinSize);
print OUTPUT " <li>" . format_size($pages{$page_url}->{size}) . "<a href=\"http://" . $page_url . "/\">" . $page_url . "</a></li>\n";
print OUTPUT " <ul>\n";
foreach $code ( sort ( { $pagesxcodes{$page_url}{$b}->{size} <=> $pagesxcodes{$page_url}{$a}->{size} || $a cmp $b} keys ( %{ $pagesxcodes{$page_url} } ) ) )
{
next unless $pagesxcodes{$page_url}{$code}->{size} > $cfgMinSize;