Changeset 351
- Timestamp:
- 12/11/06 02:15:01 (6 years ago)
- Files:
-
- 1 modified
-
util/server_daily_maint (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
util/server_daily_maint
r350 r351 14 14 my $days_to_keep = 14; # keep 14 days 15 15 my $store_dir = $ENV{HOME} . "/whuffy.com/dev/stats"; # where we retrieve our feedback 16 my $graph_dir = $ENV{HOME} . "/whuffy.com/dev/ test"; # where we store our graphs16 my $graph_dir = $ENV{HOME} . "/whuffy.com/dev/feedback"; # where we store our graphs 17 17 my $stylesheet = '/svgstyles.css'; 18 my $debug = 1;18 my $debug = 0; 19 19 20 20 use strict; … … 566 566 my $gwidth = 250; 567 567 568 print "Generating graph $gname ..\n" if ($debug);568 print "Generating graph $gname ($title)...\n" if ($debug); 569 569 # work out scale.. 570 570 my $min, my $max; … … 584 584 $scalediv = 1 if ($scalediv < 1); 585 585 586 return if (($min == 0) && ($max == 0));586 if (($min == 0) && ($max == 0)) { print "oh oh\n"; return; }; 587 587 588 588 my $graph = SVG::TT::Graph::TimeSeries->new({ … … 621 621 sub graph_count_data 622 622 { 623 my ($template, $varname, $max_hrs, $max_days, $max_weeks, $max_months, @fields) = @_; 624 623 my ($template, $varname, $request, @fields) = @_; 624 625 my @requests = split(/ /, $request); 625 626 my @graphs; 626 627 627 # hours 628 if ($max_hrs > 0) { 628 my $tdata = { 629 hour => { n => 3600, tformat => "%a %H:%M", abbrev => "hr" }, 630 day => { n => 86400, tformat => "%a %e %b", abbrev => "day" }, 631 week => { n => 604800, tformat => "%e %b %y", abbrev => "wk" }, 632 month =>{ n => 2592000, tformat => "%b %y", abbrev => "mn" } 633 }; 634 635 foreach my $r (@requests) 636 { 637 next unless ($r =~ /(\d+)(\w+)/); 638 my $max = $1; 639 my $timeslice = $2; 640 629 641 my $fieldnum = 0, my $d, my $fielddesc = ""; 630 foreach my $field (@fields) { 631 for (my $i = ($max_hrs-1); $i >= 0; $i--) { 632 my $val = numvar($store->{per_hour}->[$i]->{$field},$field,0); 633 $val /= numvar($store->{per_hour}->[$i]->{duration_count},$field,1) if ($field =~ /duration$/); 634 my $time_offset = $starttime + $store->{tzdiff} - (60*60*$i); 635 push(@{$d->[$fieldnum]}, strftime("%Y-%m-%d %H:%M:%S", localtime($time_offset)), $val); 636 } 637 $fieldnum++; 638 $fielddesc .= $field."_"; 639 } 640 push @graphs, { GRAPH => &graph_one_count_data($fielddesc."hr", "Last $max_hrs hours", "%a %H:%M", "6 hours", $d) }; 641 } 642 643 # days 644 if ($max_days > 0) { 645 my $fieldnum = 0, my $d, my $fielddesc = ""; 646 foreach my $field (@fields) { 647 for (my $i = ($max_days-1); $i >= 0; $i--) { 648 my $val = numvar($store->{per_day}->[$i]->{$field},$field,0); 649 $val /= numvar($store->{per_hour}->[$i]->{duration_count},$field,1) if ($field =~ /^duration$/); 650 my $time_offset = $starttime + $store->{tzdiff} - (60*60*24*$i); 651 push(@{$d->[$fieldnum]}, strftime("%Y-%m-%d %H:%M:%S", localtime($time_offset)), $val); 652 } 653 $fieldnum++; 654 $fielddesc .= $field."_"; 655 } 656 push @graphs, { GRAPH => &graph_one_count_data($fielddesc."day", "Last $max_days days", "%a %e %b", "5 days", $d) }; 657 } 658 659 # weeks 660 if ($max_weeks > 0) { 661 my $fieldnum = 0, my $d, my $fielddesc = ""; 662 foreach my $field (@fields) { 663 for (my $i = ($max_weeks-1); $i >= 0; $i--) { 664 my $val = numvar($store->{per_week}->[$i]->{$field},$field,0); 665 $val /= numvar($store->{per_hour}->[$i]->{duration_count},$field,1) if ($field =~ /^duration$/); 666 my $time_offset = $starttime + $store->{tzdiff} - (60*60*24*7*$i); 667 push(@{$d->[$fieldnum]}, strftime("%Y-%m-%d %H:%M:%S", localtime($time_offset)), $val); 668 } 669 $fieldnum++; 670 $fielddesc .= $field."_"; 671 } 672 push @graphs, { GRAPH => &graph_one_count_data($fielddesc."wk", "Last $max_weeks weeks", "%e %b %y", "3 weeks", $d) }; 673 } 674 675 # months 676 if ($max_months > 0) { 677 my $fieldnum = 0, my $d, my $fielddesc = ""; 678 foreach my $field (@fields) { 679 for (my $i = ($max_months-1); $i >= 0; $i--) { 680 my $val = numvar($store->{per_week}->[$i]->{$field},$field,0); 681 $val /= numvar($store->{per_hour}->[$i]->{duration_count},$field,1) if ($field =~ /^duration$/); 682 my $time_offset = $starttime + $store->{tzdiff} - (60*60*24*30*$i); 683 push(@{$d->[$fieldnum]}, strftime("%Y-%m-%d %H:%M:%S", localtime($time_offset)), $val); 684 } 685 $fieldnum++; 686 $fielddesc .= $field."_"; 687 } 688 push @graphs, { GRAPH => &graph_one_count_data($fielddesc."mn", "Last $max_months months", "%b %y", "4 months", $d)}; 642 foreach my $field (@fields) 643 { 644 for (my $i = ($max-1); $i >= 0; $i--) 645 { 646 my $val = numvar($store->{"per_$timeslice"}->[$i]->{$field},$field,0); 647 $val /= numvar($store->{per_hour}->[$i]->{duration_count},$field,1) if ($field =~ /duration$/); 648 my $time_offset = $starttime + $store->{tzdiff} - ($i * $tdata->{$timeslice}->{n}); 649 push(@{$d->[$fieldnum]}, strftime("%Y-%m-%d %H:%M:%S", localtime($time_offset)), $val); 650 } 651 $fieldnum++; 652 $fielddesc .= $field."_"; 653 } 654 my $ts = int($max > 20 ? $max / 4 : $max > 7 ? 3 : 2); 655 push @graphs, { GRAPH => &graph_one_count_data($fielddesc.$tdata->{$timeslice}->{abbrev}, 656 "Last $max $timeslice" . 's', 657 $tdata->{$timeslice}->{tformat}, 658 "$ts $timeslice" . 's', 659 $d) }; 689 660 } 690 661 … … 710 681 &report_count_data($template, 'OVERALL_SEEN', "visits", "all"); 711 682 &report_count_data($template, 'OVERALL_NODATA', "visits_with_no_details", "brief"); 712 &graph_count_data($template, 'GRAPHS_OVERALL', 24,21,12,24, "visits", "visits_with_no_details");683 &graph_count_data($template, 'GRAPHS_OVERALL', "24hour 7day 12week 12month", "visits", "visits_with_no_details"); 713 684 &report_count_data($template, 'USERS', "seen_sysid_list"); 714 &graph_count_data($template, 'GRAPHS_USERS', 24,21,12,24, "seen_sysid_list");685 &graph_count_data($template, 'GRAPHS_USERS', "24hour 7day 12week 12month", "seen_sysid_list"); 715 686 716 687 @graphs = (); … … 732 703 $template->param('DURATION' => \@duration); 733 704 734 &graph_count_data($template, 'GRAPHS_DURATION', 24,21,12,24,"duration", "duration_min", "duration_max");705 &graph_count_data($template, 'GRAPHS_DURATION', "24hour 7day 12week 12month","duration", "duration_min", "duration_max"); 735 706 736 707 @graphs = ( ); … … 807 778 &report_count_data($template, 'COMPONENT_SUCCESS_RUNS', "c_".$c."_success_counter", "all"); 808 779 &report_count_data($template, 'COMPONENT_FAIL_RUNS', "c_".$c."_fail_counter", "brief"); 809 &graph_count_data($template, 'GRAPHS_OVERALL', 24,21,12,24, "c_".$c."_success_counter", "c_".$c."_fail_counter");780 &graph_count_data($template, 'GRAPHS_OVERALL', "24hour 7day 12week 12month", "c_".$c."_success_counter", "c_".$c."_fail_counter"); 810 781 811 782 my @sf; … … 847 818 $h->{'DURATIONS'} = \@durations; 848 819 849 $h->{'GRAPHS_DURATIONS'} = &graph_count_data(undef, undef, 24,21,12,24,$g."_duration", $g."_duration_min", $g."_duration_max");820 $h->{'GRAPHS_DURATIONS'} = &graph_count_data(undef, undef, "24hour 7day 12week 12month",$g."_duration", $g."_duration_min", $g."_duration_max"); 850 821 push @sf, $h; 851 822 } … … 873 844 } 874 845 } 875 push @statistics, { STATNAME => $sname, TIMESLICES => [ @timeslices ], GRAPHS_STATISTICS => &graph_count_data(undef, undef, 72,0,12,0,$svar."_duration", $svar."_duration_min", $svar."_duration_max")};846 push @statistics, { STATNAME => $sname, TIMESLICES => [ @timeslices ], GRAPHS_STATISTICS => &graph_count_data(undef, undef, "72hour 12week",$svar."_duration", $svar."_duration_min", $svar."_duration_max")}; 876 847 } 877 848 # print Dumper(\@statistics);
