From b4face5b45fe03a45d2b79918e5d09c1244711bf Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sat, 30 Nov 2013 17:34:52 +0000 Subject: Polish totals index page --- diff --git a/awstatstotal b/awstatstotal index 0de9160..3474623 100755 --- a/awstatstotal +++ b/awstatstotal @@ -19,6 +19,7 @@ use File::Find; use LWP::Simple; use Net::Domain; use Number::Format; +use List::Util qw(max); use vars qw/ $PROGRESS_BAR_WIDTH @@ -26,12 +27,14 @@ use vars qw/ $max_count $max_bytes @sites + $hostfqdn /; -$PROGRESS_BAR_WIDTH = 300; +$PROGRESS_BAR_WIDTH = 200; $FORMAT = new Number::Format(); $max_count = 0; $max_bytes = 0; +$hostfqdn = $ENV{"FQDN"} || Net::Domain::hostfqdn; sub get_conf_string { my ($lines, $name) = @_; @@ -73,10 +76,10 @@ sub parse_site { close(DB); } - $max_count = $total_pages if $total_pages > $max_count; - $max_count = $total_hits if $total_hits > $max_count; - $max_bytes = $total_bandwidth if $total_bandwidth > $max_bytes; - push @sites, [Net::Domain::hostfqdn, $domain, $total_pages, $total_hits, $total_bandwidth]; + $max_count = max($max_count, $total_pages); + $max_count = max($max_count, $total_hits); + $max_bytes = max($max_bytes, $total_bandwidth); + push @sites, [$hostfqdn, $domain, $total_pages, $total_hits, $total_bandwidth]; } if (@ARGV < 2) { @@ -100,8 +103,8 @@ if ($cmd =~ /dump/i) { foreach my $dump (@ARGV) { my @dump; if ($dump =~ /^(http|ftp)/) { - @dump = LWP::Simple::get($dump); - } else { + @dump = split(/\n/, LWP::Simple::get($dump)); + } else { open(DUMP, $dump); @dump = ; } @@ -117,44 +120,86 @@ foreach my $dump (@ARGV) { } print < - + + Sugar Labs Servers Statistics + + + +
+ Web   ·   + Wiki   ·   + Activities   ·   + Blog   ·   + Lists   ·   + Chat   ·   + Meeting   ·   + Bugs   ·   + Git   ·   + Translate   ·   + Archive   ·   + People   ·   + Donate +
+
+ + + + + + + + + + EOF -foreach (sort { $b->[4] <=> $a->[4] } @sites) { +foreach (sort { $b->[2] <=> $a->[2] } @sites) { my ($fqdn, $domain, $pages, $hits, $bandwidth) = @$_; - $pages_bar = int($PROGRESS_BAR_WIDTH * $pages / $max_count); - $hits_bar = int($PROGRESS_BAR_WIDTH * $hits / $max_count); - $bandwidth_bar = int($PROGRESS_BAR_WIDTH * $bandwidth / $max_bytes); + $pages_bar = max(2, int($PROGRESS_BAR_WIDTH * $pages / $max_count)); + $hits_bar = max(2, int($PROGRESS_BAR_WIDTH * $hits / $max_count)); + $bandwidth_bar = max(2, int($PROGRESS_BAR_WIDTH * $bandwidth / $max_bytes)); $pages = $FORMAT->format_number($pages); $hits = $FORMAT->format_number($hits); $bandwidth = $FORMAT->format_bytes($bandwidth); print < - - - - - - - - - - - - - + + + + + + + EOF } print < -
 PagesHitsBandwidth 
 PagesHitsBandwidth 
$domain$pages$hits$bandwidth -
-
- -
$domain$pages$hits$bandwidth +
+
+ +
+ + +
+ Powered by + AWStats +
+ EOF -- cgit v0.9.1