#!/usr/bin/perl ## Read below before using. # modified: 12/24/2002 - fixed bug with displaying initial page # Last modified: 12/30/2002 - modified for RAQ4 # This script was written for the RAQ4 server to display a combined # report of all the webalizer reports (ie. show all the hits/visits/pages # to all your servers on 1 page vs. logging into each domain and picking # off the values). # DISCLAIMER: Use this script at your own risk! We are not responsible for any # damages that might be caused as a result of using this script.. # THIS MIGHT EVEN VOID YOUR WARRANTY # ... don't worry, we had to state this to cover ourselves. # # This script was written by BuildaCOM.com on October 25, 2002 for an HP SA1100 # # Place this script under: # # /home/sites//web (where is the correct site you want to access # # and call it by: # http:///cgi-bin/summary_raq4.pl (where = site#) # # You should see a Table Appear, click on the report you want to see. # * Make sure cgi is turned on. # ** If your not running this on an HP SA1100 make sure: # -PATH to perl is correct # -CGI.pm is installed # -$dir is defined and structured properly # # This script has been tested on linux 6.2 on an RAQ4 (server appliance) # however this script should work well with most versions of webalizer on most # appliance servers (with few modifications if any - simply search for #-# # in this script and verify things are setup correctly (there should be no # need to do this if your running this on an hp RAQ4). # Feel free to email support@buildacom.com if you have any questions. # * and certainly send us any bugs that you might find. # # If your looking for custom reports of your web traffic feel free to # enquire about our services. Visit us at http://buildacom.com ## # -- HP SA1100 HINTS -- # (again - we're not responsible if you break anything) # Q: ever wonder why webalizer lost the history on your sites? # A: if you snoop around the following script and add the '-p' option # this will preserve the webalizer history for up to 12 months. Otherwise # when your logs rotate it wipes out the previous history. ## ## Last but not least, all we ask is if you make enhancements to this script ## it would be nice to share them with us, and please do not modify the credit ## mentioned to those who made webalizer and this script possible. ## Special Thanks to Brad Barret and all those involved for creating webalizer ## webalizer can be dowloaded at http://www.mrunix.net/webalizer/ use CGI qw (:standard); $show=param("show"); print "Content-type: text/html\n\n"; print "\n"; #print "SHOW: $show"; $app=0; $c=1; #-# The $dir variable is the top directory of all your webalizer reports # ie. $dir/site1, $dir/site2 ... $dir/siteN should containt the webalizer # reports. #$dir="/usr/ins/intel/gui/htdocs/secure-data/webalizer-domains"; # HP SA1100 Config $dir="/home/sites"; # RAQ Config #-# If you have to play with this section then don't bother using this script. # # The below sections defines daily1 as this daily and daily12 as 12 dailys ago # $dt_thisyear=`date +%Y`; $dt_thisdaily=`date +%m`; $year_=$dt_thisyear; $daily_=$dt_thisdaily; $daily="daily"; $year="year"; $date_="date"; for ($mc = 1; $mc <= 12; $mc++) { $total="total.$mc"; ${total}=0; $m=$daily.$mc; $y=$year.$mc; $d=$date_.$mc; if ($daily_ == "0") { $daily_=12; $year_--; } $w=length($daily_); if ( $daily_ <= "9" && $w == "1") { ${$m}="0".$daily_; } else { ${$m}=$daily_; } ${$y}=$year_; ${$d}=$year_.$daily_; ${$d}=~s/ //g; $daily_--; } print "\n"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Daily Avg.HitsPagesFilesVisits
"; print "\n"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Monthly TotalsSitesKBytesVisitsPagesFilesHits
"; #if ( $show =~ "" ) # { # print "Working"; # $show="Hits per Hour"; # } if ( !$show ) { print "\n"; print "\n"; print "

\n"; print "Click on Above Stat to display Summary for all instances"; print "
\n"; } else { print "\n"; print "\n"; print "
\n"; print "Displaying: $show"; print "
\n"; # } print "\n"; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; opendir (sites,$dir); foreach $site (readdir(sites)) { $indx="$dir/$site/web/stats/index.html"; $h="$dir/$site/web/stats"; # Added for RAQ 4 $i=0; if ( -f $indx && $site !~ "^site" && $site !~ "home" ) { if ( $c == "1" ) { $color="#f0f0f0"; $c="-1"; } else { $color="#d0d0d0"; $c="1"; } #print "
$indx\n"; $app++; #print "
IND: $indx"; open(ind,"<$indx") || die "$indx???"; while() { $this_daily_total=$_; $i++; #print "
$this_daily_ttal"; if($this_daily_total =~ ">Monthly Totals<") { #-# Some ugly parsing - what the heck, it works. $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total=; $this_daily_total =~ s/.*-1">//; $this_daily_total =~ s/<.*$//; $this_machine_total=$this_machine_total+$this_daily_total; $total=$total+$this_daily_total; print "
"; for ($mt=1;$mt<=12;$mt++) { $yd="year$mt"; $md="daily$mt"; $uf="usage_".${$yd}.${$md}; #print ""; #-#$u="$dir/$site/$uf.html"; # HP SA1100 $u="$h/$uf.html"; # RAQ4 $u=~s/\n//g; #print "
U: $u"; if ( -f $u ) { $i=0; open(usg,"<$u"); while() { $d_total=$_; $i++; #-# Trying to figure out what's next? -don't bother, it's a killer. if ($d_total =~ $show ) { $d_total=; $d_total=~ s/.*//; $d_total=~ s/<.*$//; print ""; #$t_machine_total="machine_daily_total$mt"; $t="total$mt"; #print "T: $t"; #${$t_machine_total}=${$t_machine_total}+$daily_total; ${$t}=${$t}+$d_total; #$machine_daily_total=$machine_daily_total+$daily_total; #print ""; } } close(usg); } else { print ""; } } print "\n"; } } close(ind); } } close (sites); #print "\n"; print "
#Machine$daily1/$year1$daily2/$year2$daily3/$year3$daily4/$year4$daily5/$year5$daily6/$year6$daily7/$year7$daily8/$year8$daily9/$year9$daily10/$year10$daily11/$year11$daily12/$year12
$app$site$uf$d_total   \n\n$uf\n\n
 Total$total1 $total2 $total3 $total4 $total5 $total6 $total7 $total8 $total9 $total10 $total11 $total12 
\n"; } print "
Summary powered by BuildaCOM.com\n"; print "
Download this script at http://buildacom.com/webalizer/\n"; print "
Download webalizer at http://www.mrunix.net/webalizer/\n"; print "\n"; print "\n";