X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=tools%2Fprivoxy-log-parser.pl;h=5a1ebca8af45e4aa23d41ee3d7d739193d1d1345;hp=9178d1467ff4b514cbc513c4d9a6b9963512b315;hb=fd57abaf17b528b7ede87bdc2f40ad751de2f968;hpb=6f2a281485ba2613ac6a0b68271d78912d27c903 diff --git a/tools/privoxy-log-parser.pl b/tools/privoxy-log-parser.pl index 9178d146..5a1ebca8 100755 --- a/tools/privoxy-log-parser.pl +++ b/tools/privoxy-log-parser.pl @@ -23,7 +23,7 @@ # hash key as input. # - Add --compress and --decompress options. # -# Copyright (c) 2007-2017 Fabian Keil +# Copyright (c) 2007-2020 Fabian Keil # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -43,7 +43,7 @@ use warnings; use Getopt::Long; use constant { - PRIVOXY_LOG_PARSER_VERSION => '0.9', + PRIVOXY_LOG_PARSER_VERSION => '0.9.1', # Feel free to mess with these ... DEFAULT_BACKGROUND => 'black', # Choose registered colour (like 'black') DEFAULT_TEXT_COLOUR => 'white', # Choose registered colour (like 'black') @@ -2009,6 +2009,8 @@ sub gather_loglevel_clf_stats ($) { $resource =~ m@(?:http[s]://)([^/]+)/?@; $stats{'hosts'}{$1}++; } + $stats{'content-size-total'} += $size; + $stats{'status-code'}{$status_code}++; } sub gather_loglevel_request_stats ($$) { @@ -2024,7 +2026,6 @@ sub gather_loglevel_crunch_stats ($$) { my $thread = shift; our %stats; - $stats{requests}++; $stats{crunches}++; if ($c =~ m/^Redirected:/) { @@ -2138,6 +2139,7 @@ sub init_stats () { 'reused-connections' => 0, 'server-keep-alive' => 0, 'closed-client-connections' => 0, + 'content-size-total' => 0, ); $stats{'client-requests-on-connection'}{1} = 0; } @@ -2202,7 +2204,9 @@ sub print_stats () { get_percentage($stats{requests}, $stats{'empty-responses-on-reused-connections'}) . ")\n"; print "Client connections: " . $stats{'closed-client-connections'} . "\n"; - + if ($stats{'content-size-total'}) { + print "Bytes transfered excluding headers: " . $stats{'content-size-total'} . "\n"; + } my $lines_printed = 0; print "Client requests per connection distribution:\n"; foreach my $client_requests (sort { @@ -2233,7 +2237,15 @@ sub print_stats () { } print "Client HTTP versions:\n"; foreach my $http_version (sort {$stats{'http-version'}{$b} <=> $stats{'http-version'}{$a}} keys %{$stats{'http-version'}}) { - printf "%d : %s\n", $stats{'http-version'}{$http_version}, $http_version; + printf "%8d : %-8s\n", $stats{'http-version'}{$http_version}, $http_version; + } + if (exists $stats{'status-code'}) { + print "HTTP status codes:\n"; + foreach my $status_code (sort {$stats{'status-code'}{$b} <=> $stats{'status-code'}{$a}} keys %{$stats{'status-code'}}) { + printf "%8d : %-8d\n", $stats{'status-code'}{$status_code}, $status_code; + } + } else { + print "Status code distribution unknown. No CLF message parsed yet. Is 'debug 512' enabled?\n"; } if ($cli_options{'url-statistics-threshold'} == 0) {