#!/usr/bin/perl ## ############################################################################## ## NAME ## nbrkstats.cgi - create HTML-output from harvest-broker statistic-file ## ## SYNOPSIS ## ./nbrkstats.cgi > /tmp/output.html or ## http://www.mybrokerhostname.de/Harvest/cgi-bin/nbrkstats.cgi ## ## INSTALLATION: ## - To use this script via www, ## * copy this script to ## /usr/local/harvest/cgi-bin ## or ## $PREFIX/harvest/cgi-bin ## * change some variables below "#### Config" ## * and run: ## http://localhost/Harvest/cgi-bin/nbrkstats.cgi ## ## - To use this script from command line ## * change some variables below "#### Config" ## * set $WWW=0 ## * create a configfile (nbrkstats.conf) ## * and run ## "./nbrkstats.cgi > /tmp/output.html" ## or put in crontab ## 0-59/5 * * * * root /PATH/TO/nbrkstats.cgi > /tmp/output.html ## ############################################################################## # # CONFIG-FILE: # To use this script from command line you have to create a config-file with # the following entries: # # broker=www.mybrokerhostname.de # case=yes or case=no # maxdetail=3 # ini_days=01 # ini_months=01 # ini_years=2000 # fin_days=31 # fin_months=12 # fin_years=2002 # cbox_week=ON or cbox_week=OFF # cbox_hour=ON or cbox_hour=OFF # cbox_day=ON or cbox_day=OFF # cbox_query=ON or cbox_query=OFF # # ############################################################################## # VERSION # Version 0.6, 06.05.2002, Guido Kerkewitz, gk@uni-duisburg.de # - added run from command line # - added config-file # - some minor changes # Version 0.5a, 25.04.2002, Guido Kerkewitz, gk@uni-duisburg.de # - fix overwriting of values in %statp # - fix formatting of rounded numbers # - fix double '/' in $logprefix # - insert debug-option # Version 0.5, 12.04.2002, Guido Kerkewitz, gk@uni-duisburg.de # - rewrite of BrokerStats.cgi 0.7 # - no cgi-lib.pl required, only two perl modules (CGI, Date::Manip) # ############################################################################## # OLD VERSIONS: # Program BrokerStats.cgi: harvest broker statistics # Version 0.6 Hermann Straus, Madrid February 1998 # Send comments to hstraus@cipres.upm.es # # Version 0.7 Kang-Jin Lee 30 January 2000 # Minor changes. ############################################################################## ############################################################################## #### Config - User configurable parameters ############################################################################## # Use from cgi-bin (WWW=1) or commandline (WWW=0) $WWW = '1'; # Configfile for command line run $CONFIGFILE = "./nbrkstats.conf"; # local hostname (for linux); chop($HOSTNAME=`/bin/hostname -f`); # WWW-/Harvest-Administrator: $ADMIN = "harvest\@mydomain.org"; # Optional HTML-Stylefile (may be empty: ''): $STYLEFILE = '/styles/style1.css'; # Colors: $COLOR_FRAME = "#000080"; $COLOR_TAB = "#FFFFFF"; # Your local broker names: @BROKER = qw(www.mybrokerhostname1.de www.mybrokerhostname.de); # Default brokerhost $BROKERDEF = "www.mybrokerhostname1.de"; # Default shown queries $MAXDETAILDEF = "3"; # Path to broker.out $logprefix = "/usr/local/harvest/brokers"; $brokerprefix = "http://${HOSTNAME}/Harvest/brokers"; $brokersuffix = "index.html"; # Default START/END date $DAYSINIDEF = '1'; $DAYSFINDEF = '31'; $MONTHSINIDEF = '01'; $MONTHSFINDEF = '12'; $YEARSINIDEF = '2000'; $YEARSFINDEF = '2005'; # special transformations for my own sites # Should be always '0' $gkspecial = '0'; ############################################################################## # Do not change after this line ############################################################################## ############################################################################## # MAIN use CGI qw/:standard :netscape *table/; # Use this if you have DateManip module installed: # #use Date::Manip; # # Otherwise use this: # Add the perl library path to the @INC path @P = split('/', $0); pop @P; $medir = join('/',@P); unshift(@INC, $medir); require 'Manip.pm'; # Initialize &init; $frame_name = path_info(); $frame_name =~ s!^/!!; # Prepare for command line run if ( ! $WWW ) { use CGI qw/-no_debug/; open (IN,"$CONFIGFILE") || die (print "ERROR: Configfile ($CONFIGFILE) couldn't be opened.\n"); restore_parameters(IN); close IN; $frame_name = 'brkbot'; } # Create the header of the html-page print header if ( $WWW ); # If no path information is provided, then we create # a side-by-side frame set if (!$frame_name) { print_frameset(); exit 0; } # If we get here, then we either create the query form # or we create the response. print start_html(-title=>'Broker statistic',-style=>{'src'=>$STYLEFILE}, -author=>"$MAIL", -meta=>{'keywords'=>'harvest broker statistic', 'copyright'=>"copyright 2002 $AUTHOR"} ); print_query() if $frame_name eq 'brktop'; print_response() if $frame_name eq 'brkbot'; print_contact() if $frame_name eq 'brkbot'; print_copy() ; print end_html(); ############################################################################## # Create the frameset sub print_frameset { my $script = url(); print title('Harvest Broker Statistics'), frameset({-rows=>'37%,63%'}, frame({-name=>'brktop',-src=>"$script/brktop"}), frame({-name=>'brkbot',-src=>"$script/brkbot"}) ); exit 0; } # end print_frameset ############################################################################## # Print the menu for selection sub print_query { my $script = url(); print '
', h1("Harvest Broker Statistics"), start_form(-action=>"$script/brkbot", -target=>"brkbot"), # outer table table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB"}, Tr({-align=>CENTER,-valign=>TOP}, [ td([ table({-border=>'0'}, caption('Query:'), Tr({-align=>LEFT,-valign=>CENTER}, [ td(['Broker to obtain statistics: ', table({-border=>'0'},Tr({-align=>LEFT,-valign=>CENTER}, [ td([ popup_menu(-name=>'broker', -default=>"$BROKERDEF",-values=>[@BROKER]) ]) ])), ]), td(['Count queries casesensitive: ', table({-border=>'0'},Tr({-align=>LEFT,-valign=>CENTER}, [ td([ popup_menu(-name=>'case', -default=>"$CASEDEF",-values=>[@CASE]) ]) ])), ]), td(['Show querys present at least: ', table({-border=>'0'},Tr({-align=>LEFT,-valign=>CENTER}, [ td([ popup_menu(-name=>'maxdetail', -default=>"$MAXDETAILDEF", -values=>[@MAXDETAIL]), 'times.' ]) ])), ]) ])), # end table table({-border=>'0'}, caption('Ranges of dates:'), Tr({-align=>CENTER,-valign=>CENTER}, [ th(['' , 'Day','Month','Year']), td(['Initial Date: ' , popup_menu(-name=>'ini_days', -default=>"$DAYSINIDEF", -values=>[@DAYS]), popup_menu(-name=>'ini_months', -default=>"$MONTHSINIDEF", -values=>[@MONTHS], -labels=>\%MONTHSLAB), popup_menu(-name=>'ini_years', -default=>"$YEARSINIDEF", -values=>[@YEARS]) ]), td(['Final Date: ' , popup_menu(-name=>'fin_days', -default=>"$DAYSFINDEF", -values=>[@DAYS]), popup_menu(-name=>'fin_months', -default=>"$MONTHSFINDEF", -values=>[@MONTHS], -labels=>\%MONTHSLAB), popup_menu(-name=>'fin_years', -default=>"$YEARSFINDEF", -values=>[@YEARS]), ]) ]) ), # end table table({-border=>'0'}, caption('Output:'), Tr({-align=>LEFT,-valign=>CENTER}, [ td(['Show Weekday: ', table({-border=>'0'},Tr({-align=>LEFT,-valign=>CENTER}, [ td([ checkbox(-name=>'cbox_week', -checked=>1, -value=>'ON', -label=>''), ]), ])), ]), td(['Show Hour: ', table({-border=>'0'},Tr({-align=>LEFT,-valign=>CENTER}, [ td([ checkbox(-name=>'cbox_hour', -checked=>1, -value=>'ON', -label=>''), ]), ])), ]), td(['Show Day: ', table({-border=>'0'},Tr({-align=>LEFT,-valign=>CENTER}, [ td([ checkbox(-name=>'cbox_day', -checked=>1, -value=>'ON', -label=>''), ]), ])), ]), td(['Show Query: ', table({-border=>'0'},Tr({-align=>LEFT,-valign=>CENTER}, [ td([ checkbox(-name=>'cbox_query', -checked=>1, -value=>'ON', -label=>''), ]), ])), ]), ])), # end table ]), ]) ), # end table ])])), # outer table br, submit, end_form, '
' ; } # end print_query ############################################################################## # Print the results sub print_response { # No Query unless (param) { print "
\n"; print b("No query submitted yet."); print '
'; return; } &set_variables(); print "
\n"; print h1("Statistics for the broker $broker"),"\n"; print p("\n","Here you can access the ", a({-href=>"$brokerurl",-target=>'_new'}, "Broker main page.")); &get_statistic(); # Query # print p(b("Result statistics:")),"\n"; print p("Statistics from ${ini_days}.${ini_months}.${ini_years} to ${fin_days}.${fin_months}.${fin_years}"), br,"\n"; # Table (outside) print "\n\n"; print " \n"; print " \n \n \n"; print "
\n"; @rows=(); push(@rows,th(' ') .th('Number')."\n"); push(@rows,td("Total queries:") .td("$stat{'totalqueries'}")."\n"); push(@rows,td("Queries completed:") .td("$stat{'totalcomplet'}")."\n"); push(@rows,td("Total results:") .td("$stat{'totalres'}") ."\n"); push(@rows,td("Timeouts:") .td("$stat{'timeout'}") ."\n"); push(@rows,td("Broker restarted") .td("$stat{'brkonline'}") ."\n"); push(@rows,td("Glimpse restarted") .td("$stat{'glonline'}") ."\n"); push(@rows,td("Collections started") .td("$stat{'collect'}") ."\n"); # outer table print table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB",-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),"\n" , ])])); # outer table print " \n"; @rows=(); push(@rows,th('Results found').th('Number').th('% of total')."\n"); push(@rows,td("not found").td("$stat{r0}").td("$statp{'r0'} \%")."\n"); push(@rows,td("1-5") .td("$stat{r5}").td("$statp{'r5'} \%")."\n"); push(@rows,td("5-10") .td("$stat{r10}").td("$statp{'r10'} \%")."\n"); push(@rows,td("10-20") .td("$stat{r20}").td("$statp{'r20'} \%")."\n"); push(@rows,td("20-50") .td("$stat{r50}").td("$statp{'r50'} \%")."\n"); push(@rows,td(">50") .td("$stat{rn}").td("$statp{'rn'} \%")."\n"); # outer table print table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB",-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),"\n" , ])])); # outer table print " \n"; @rows=(); push(@rows,th('Query type').th('Number') ."\n"); push(@rows,td("Single terms").td("$singleTerm") ."\n"); push(@rows,td("Phrases").td("$phrase") ."\n"); push(@rows,td("logic AND").td("$and") ."\n"); push(@rows,td("logic OR").td("$or") ."\n"); push(@rows,td("Compound").td("$compound") ."\n"); push(@rows,td("by field").td("$field") ."\n"); #print table({-border=>'1',-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),br,"\n" ; # outer table print table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB",-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),"\n" , ])])); # outer table print "
\n
\n"; # Table (outside) print "\n\n"; print " \n"; print " \n \n \n \n"; print "
\n"; @rows=(); # Print Weekday Stats if ( $cb_week) { print p(b("Weekday
(Max: $WEEKDAY{$maxweekdayname}/$stat_wday{$maxweekdayname}):"))."\n"; push(@rows,th('Weekday').th('Number').th('% of total')."\n"); foreach $i (sort keys %stat_wday) { push(@rows,(td($WEEKDAY{$i}).td($stat_wday{$i}).td("$statp{\"w,$i\"} \%")."\n")); } push(@rows,(td('Sum').td("$weekdaysum").td('100'))."\n"); #print table({-border=>'1',-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )) ; # outer table print table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB",-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),"\n" , ])])); # outer table print "
\n"; @rows=(); } # Print Hour Stats if ( $cb_hour) { print p(b("Hour
(Max: $maxhour/$stat_hour{$maxhour}):"))."\n"; push(@rows,th('Hour').th('Number').th('% of total')."\n"); foreach $i (sort keys %stat_hour) { push(@rows,(td($HOURS{$i}).td($stat_hour{$i}).td("$statp{$i} \%")."\n")); } push(@rows,(td('Sum').td("$hoursum").td('100')."\n")); #print table({-border=>'1',-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )) ; # outer table print table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB",-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),"\n" , ])])); # outer table print "
\n"; @rows=(); } # Print Day Stats if ( $cb_day) { print p(b("Day
(Max: $maxday/$stat_day{$maxday}):"))."\n"; push(@rows,th('Day').th('Number').th('% of total')."\n"); foreach $i ( sort { $b <=> $a } keys %stat_day ) { push(@rows,(td($i).td($stat_day{$i}).td("$statp{$i} \%")."\n")); } push(@rows,(td('Sum').td("$daysum").td('100')."\n")); #print table({-border=>'1',-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )) ; # outer table print table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB",-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),"\n" , ])])); # outer table print "
\n"; @rows=(); } # Print Query Stats if ( $cb_query) { print p(b("Queries
(Max: $maxquery/$stat_query{$maxquery}):"))."\n"; push(@rows,th('Query').th('Number').th('% of total')."\n"); foreach $i ( sort { $stat_query{$b} <=> $stat_query{$a} } keys %stat_query ) { if ($stat_query{$i} < $maxdetail ) { push(@rows,(td('...').td('...').td('...')."\n")); last } push(@rows,(td($i).td($stat_query{$i}).td("$statp{$i} \%")."\n")); } push(@rows,(td('Sum').td("$querysum").td('100')."\n")); #print table({-border=>'1',-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )) ; # outer table print table({-border=>'0', -bgcolor=>"$COLOR_FRAME"}, Tr({-align=>CENTER,-valign=>TOP},[td([ table({-border=>'0', -bgcolor=>"$COLOR_TAB",-cellpadding=>'3'}, "\n", Tr({-align=>CENTER,-valign=>CENTER}, [ @rows ] )),"\n" , ])])); # outer table } print "
\n
\n"; print '
',"\n"; } # end print_response ############################################################################## # Initialize sub init { @MAXDETAIL = qw(1 2 3 4 5 10); @HOURS = qw(00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23); @DAYS = qw(01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31); @MONTHS = qw(01 02 03 04 05 06 07 08 09 10 11 12); @YEARS = qw(2000 2001 2002 2003 2004 2005 2006 2007 2008 2009); %MONTHSLAB = ( '01'=>'January', '02'=>'February', '03'=>'March', '04'=>'April', '05'=>'May', '06'=>'June', '07'=>'July', '08'=>'August', '09'=>'September', '10'=>'October', '11'=>'November', '12'=>'December'); %WEEKDAY = ( '1'=>'Mon', '2'=>'Tue', '3'=>'Wed', '4'=>'Thu', '5'=>'Fri', '6'=>'Sat', '7'=>'Sun'); %HOURS = ( '00'=>'0:00 - 1:00', '01'=>'1:00 - 2:00', '02'=>'2:00 - 3:00', '03'=>'3:00 - 4:00', '04'=>'4:00 - 5:00', '05'=>'5:00 - 6:00', '06'=>'6:00 - 7:00', '07'=>'7:00 - 8:00', '08'=>'8:00 - 9:00', '09'=>'9:00 - 10:00', '10'=>'10:00 - 11:00', '11'=>'11:00 - 12:00', '12'=>'12:00 - 13:00', '13'=>'13:00 - 14:00', '14'=>'14:00 - 15:00', '15'=>'15:00 - 16:00', '16'=>'16:00 - 17:00', '17'=>'17:00 - 18:00', '18'=>'18:00 - 19:00', '19'=>'19:00 - 20:00', '20'=>'20:00 - 21:00', '21'=>'21:00 - 22:00', '22'=>'22:00 - 23:00', '23'=>'23:00 - 24:00'); @CASE = qw(NO YES); $CASEDEF = $CASE[0]; # Select default Value if ( ! $BROKERDEF ) { $BROKERDEF = $BROKER[0]; } if ( ! $MAXDETAILDEF ) { $MAXDETAILDEF = $MAXDETAIL[0]; } ############################################################################ # do not change $0 =~ s#.*/##g; $PROGNAME = $0; $AUTHOR = 'Guido Kerkewitz'; $MAIL = 'gk@uni-duisburg.de'; $VERSION = "Version 0.6, 06.05.2002"; $COPY = "written by $AUTHOR"; ############################################################################ } # end init ############################################################################## # Set variables sub set_variables { # transfer parameter $broker = param(broker); $case = param(case); $maxdetail = param(maxdetail); $ini_days = param(ini_days); $ini_months = param(ini_months); $ini_years = param(ini_years); $fin_days = param(fin_days); $fin_months = param(fin_months); $fin_years = param(fin_years); $cb_week = param(cbox_week); $cb_hour = param(cbox_hour); $cb_day = param(cbox_day); $cb_query = param(cbox_query); # Create Variables $logfile="${logprefix}/${broker}/broker.out"; $brokerurl="${brokerprefix}/${broker}/${brokersuffix}"; $date_ini="${ini_years}${ini_months}${ini_days}"; $date_fin="${fin_years}${fin_months}${fin_days}"; # Set defaults # Queries $querysum = 0; $maxquery = 0; %stat_query = (); # Weekday $weekdaysum = 0; $maxweekdayname = ''; %stat_wday = (); foreach $i (sort keys %WEEKDAY) { $stat_wday{$i} = 0 }; # Hour $hoursum = 0; $maxhour = 0; %stat_hour = (); foreach $i ( @HOURS ) { $stat_hour{$i} = 0 }; # Day $daysum = 0; $maxday = 0; %stat_day = (); @stat=(); # stat includes: # Total Queries: $stat{'totalqueries'} # Completed Queries: $stat{'totalcomplet'} # Total results: $stat{'totalres'} # (gk not used) Max. returned Results: $stat{'maxret'} # Timeouts: $stat{'timeout'} # Glimpseserver online/restart: $stat{'glonline'} # Broker online/restart: $stat{'brkonline'} # Collections started $stat{'collect'} # (gk not used) Processing Admin Command $stat{'admin'} # (gk not used) Stating cleaning $stat{'cleaning'} # Count Results: # not found $stat{'r0'} # 1-5 $stat{'r5'} # 5-10 $stat{'r10'} # 10-20 $stat{'r20'} # 20-50 $stat{'r50'} # >50 $stat{'rn'} # percent of total @statp=(); foreach $i ( 'r0', 'r5', 'r10', 'r20', 'r50', 'rn') { $statp{$i}=0; $stat{$i}=0} foreach $i ( 'totalqueries', 'totalcomplet', 'totalres', 'maxret', 'timeout', 'glonline', 'brkonline', 'collect', 'cleaning', 'admin') { $stat{$i}=0} $phrase = 0; $and = 0; $or = 0; $compound = 0; $field = 0; $singleTerm = 0; $truncation = 0; #(gk not used) } # end set_variables ############################################################################## # Get Statistic from broker.out sub get_statistic { open (IN,${logfile}) || die (print "

Sorry, $logfile couldn't be opened.

"); while(){ chop; @line=split(' ',$_); next if ( ($line[1] < $date_ini) || ($line[1] > $date_fin) ); if ($_ =~ /Processing Query/){ # Count Queries $q=$_; $q=~s/(.*?)\#END\s(.*)/$2/; $q=~s/\\\./\./g if ( $gkspecial ); # Site Special Transformation ( $q=lc($q) ) if ( $case =~ /NO/i ); push (@queries, "$q\n"); $stat_query{"$q"}++; # Count query/weekday $line[1]=~/(\d\d\d\d)(\d\d)(\d\d)/; $d=$3; $m=$2; $y=$1; $wday=&Date_DayOfWeek($m,$d,$y); $stat_wday{"$wday"}++; # Count query/hour ($hour, undef) = split(':',$line[2]); $stat_hour{"$hour"}++; # Count query/day $stat_day{"$line[1]"}++; $stat{'totalqueries'}++; } elsif ($_ =~ /Query returned/){ # get the number of results returned if ($line[5] > $stat{'maxret'}) {$stat{'maxret'} = $line[5];} $stat{'totalres'} += $line[5]; $stat{'totalcomplet'}++; if ($line[5]==0) { $stat{'r0'}++ } elsif ($line[5] <= 5) { $stat{'r5'}++; } elsif ($line[5] <= 10) { $stat{'r10'}++;} elsif ($line[5] <= 20) { $stat{'r20'}++;} elsif ($line[5] <= 50) { $stat{'r50'}++;} else { $stat{'rn'}++; } } elsif ($_ =~ /Inline query timeout/) { $stat{'timeout'}++; } elsif ($_ =~ /is on-line/) { $stat{'glonline'}++; } elsif ($_ =~ /Broker is now on-line/) { $stat{'brkonline'}++; } elsif ($_ =~ /Starting collections/) { $stat{'collect'}++; } elsif ($_ =~ /Processing Admin Command/) { $stat{'admin'}++; } elsif ($_ =~ /Starting Cleaning/) { $stat{'cleaning'}++; } else {}#Other lines } #while close(IN); # Prepare the collected values for the output # Weekdaystats foreach $i (sort keys %WEEKDAY) { $weekdaysum+=$stat_wday{$i}; $maxweekdayname=$i if ($stat_wday{$i}>$stat_wday{$maxweekdayname}); } foreach $i (sort keys %WEEKDAY) { $statp{"w,$i"} = sprintf("%.2f", $stat_wday{$i}/$weekdaysum*100); } # Hourstats foreach $i ( @HOURS ) { $hoursum+=$stat_hour{$i}; $maxhour=$i if ($stat_hour{$i}>$stat_hour{$maxhour}); } foreach $i ( @HOURS ) { $statp{$i} = sprintf("%.2f", $stat_hour{$i}/$hoursum*100); } # Daystats foreach $i (sort keys %stat_day) { $daysum+=$stat_day{$i}; $maxday=$i if ($stat_day{$i}>$stat_day{$maxday}); } foreach $i (keys %stat_day) { $statp{$i} = sprintf("%.2f", $stat_day{$i}/$daysum*100); } # Queries foreach $i (sort { $stat_query{$b} <=> $stat_query{$a} } keys %stat_query) { $querysum+=$stat_query{$i}; $maxquery=$i if ($stat_query{$i}>$stat_query{$maxquery}); } foreach $i (keys %stat_query) { $statp{$i} = sprintf("%.2f", $stat_query{$i}/$querysum*100); } # analyse the queries in terms of their structure foreach (keys %stat_query) { if (/"/) { $phrase++; } if (/'/) { $phrase++; } if (/ and /i) { $and++; } if (/ or /i) { $or++; } if (/\*/) { $truncation++; } if (/\(/) { $compound++; } if (/: /) { $field++; } if (!/ /) { $singleTerm++; } } # Count 'Results found' foreach $i ( 'r0', 'r5', 'r10', 'r20', 'r50', 'rn') { $statp{$i} = sprintf("%.2f", $stat{$i}/$stat{'totalqueries'}*100); } $stat{timeout} = 0 if ( ! $stat{timeout} ); # FORMAT: #broker: 20020407 13:51:50: Processing Query 55: #USER #opaque #desc #index error 0 #index maxresult 1000 #index maxfiles 50 #index maxlines 100 #index case insensitive #index matchword #attribute none #END leseliste #broker: 20020407 13:51:50: Query returned 22 objects. } # end get_statistic ################ sub print_contact { print p("\n", &UnixDate("today","Page generated %T at %e.%m.%Y."),br, em("Local contact: $ADMIN")); } ################ sub print_copy { print p("\n",hr,em("$PROGNAME, $COPY, $VERSION")); }