Changeset 3376

Show
Ignore:
Timestamp:
02/25/10 02:09:11 (5 months ago)
Author:
steve.schnepp
Message:

- initial add of zooming
- suppression of munin-fastcgi-graph, renaming it to munin-cgi-graph

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/snide/pre_1.5/Makefile

    r3317 r3376  
    8888        $(CHMOD) 0755 $(DBDIR) 
    8989 
    90         for p in master/www/*.tmpl master/www/*.png master/www/*.css resources/favicon.ico; do \ 
     90        for p in master/www/*.tmpl master/www/*.png master/www/*.css master/www/*.js resources/favicon.ico; do \ 
    9191                $(INSTALL) -m 0644 "$$p" $(CONFDIR)/templates/ ; \ 
    9292        done 
     
    9797 
    9898        $(INSTALL) -m 0644 master/www/definitions.html $(CONFDIR)/templates/ 
     99        $(INSTALL) -m 0644 master/www/dynazoom.html $(CONFDIR)/templates/ 
    99100        $(INSTALL) -m 0755 master/DejaVuSansMono.ttf $(LIBDIR)/ 
    100101        $(INSTALL) -m 0755 master/DejaVuSans.ttf $(LIBDIR)/ 
     
    109110        $(INSTALL) -m 0755 build/master/_bin/munin-html $(LIBDIR)/ 
    110111        $(INSTALL) -m 0755 build/master/_bin/munin-limits $(LIBDIR)/ 
    111         ln -s munin-fastcgi-graph build/master/_bin/munin-cgi-graph # Fast::CGI is able to do normal CGI as well 
    112         $(INSTALL) -m 0755 build/master/_bin/munin-cgi-graph $(CGIDIR)/ 
    113         $(INSTALL) -m 0755 build/master/_bin/munin-fastcgi-graph $(CGIDIR)/ 
     112        $(INSTALL) -m 0755 build/master/_bin/munin-fastcgi-graph $(CGIDIR)/munin-cgi-graph 
    114113 
    115114# Not ready to be installed yet  
  • people/snide/pre_1.5/master/_bin/munin-fastcgi-graph.in

    r3329 r3376  
    3232use IPC::SysV qw(IPC_CREAT); 
    3333use CGI::Fast; 
     34use CGI::Carp 'fatalsToBrowser'; 
    3435 
    3536my $GRAPHER = "$Munin::Common::Defaults::MUNIN_LIBDIR/munin-graph"; 
     
    7172while (new CGI::Fast) { 
    7273    my $path = $ENV{PATH_INFO} || ""; 
    73     ($dom, $host, $serv, $scale) = $path =~ m#^/(.*)/([^/]+)/(\w+)-(\w+)\.png#; ## avoid bug in vim 
     74    ($dom, $host, $serv, $scale) = $path =~ m#^/(.*)/([^/]+)/(\w+)-([\w=,]+)\.png#; ## avoid bug in vim 
     75 
     76    my $pinpoint; 
     77    if ($scale =~ /pinpoint=(\d+),(\d+)/) { 
     78            $pinpoint = [ $1, $2, ];  
     79    } 
    7480   
    7581    if (! &verify_parameters ($dom, $host, $serv, $scale)) { 
     
    8692   
    8793    # If a "Cache-Control: no-cache" header gets send, we regenerate the image in every case: 
    88     my $no_cache = defined($ENV{HTTP_CACHE_CONTROL}) && $ENV{HTTP_CACHE_CONTROL} =~ /no-cache/i; 
     94    my $no_cache = $pinpoint || defined($ENV{HTTP_CACHE_CONTROL}) && $ENV{HTTP_CACHE_CONTROL} =~ /no-cache/i; 
    8995  
    9096    if ($no_cache or (! &graph_usable ($filename, $time) )) { 
    91         next unless draw_graph_or_complain($dom, $host, $serv, $TIMES{$scale}, $filename, "$config->{logdir}/munin-cgi-graph.log"); 
     97        my $scale_options; 
     98        if ($pinpoint) { 
     99                $scale_options = [ "--pinpoint=" . $pinpoint->[0] . "," . $pinpoint->[1] ]; 
     100        } else { 
     101                $scale_options = $TIMES{$scale}; 
     102        } 
     103        next unless draw_graph_or_complain($dom, $host, $serv, $scale_options, $filename, "$config->{logdir}/munin-cgi-graph.log"); 
    92104        goto draw; 
    93105    } 
     
    113125 
    114126  draw:   
     127    my $period_scale = $pinpoint ? 1 : $period{$scale}; 
    115128    @stats           = stat ($filename); # restat to be sure 
    116129    $last_modified   = strftime ("%a, %d %b %Y %H:%M:%S %Z", localtime ($stats[9])) unless defined($last_modified); 
    117130    # "Expires" has to use last modified time as base: 
    118     $expires         = strftime ("%a, %d %b %Y %H:%M:%S GMT",  
    119                                 gmtime($stats[9]+($period{$scale}-($stats[9]%$period{$scale})))) unless defined ($expires); 
     131    #$expires         = strftime ("%a, %d %b %Y %H:%M:%S GMT",  
     132#                               gmtime($stats[9]+($period{$scale}-($stats[9]%$period_scale)))) unless defined ($expires); 
    120133     
    121134    print "Status: 200\n"; 
    122135    print "Content-Type: image/png\n"; 
    123136    print "Content-Length: $stats[7]\n"; 
    124     print "Expires: ", $expires, "\n"; 
     137    #print "Expires: ", $expires, "\n"; 
    125138    print "Last-Modified: $last_modified\n"; 
    126139    print "\n"; 
     
    183196 
    184197    return "/tmp/munin-cgi-png/$domain/$name/$service-$scale.png"; 
    185 } 
    186  
    187  
    188 sub logger_open { 
    189     my $dirname = shift; 
    190  
    191     if (!$log->opened) 
    192     { 
    193         unless (open ($log, '>>', "$dirname/munin-cgi-graph.log")) 
    194         { 
    195             print STDERR "Warning: Could not open log file \"$dirname/munin-cgi-graph.log\" for writing: $!"; 
    196         } 
    197     } 
    198198} 
    199199 
     
    260260        else 
    261261        { 
    262                 if (!defined $TIMES{$scale}
     262                if (!defined $TIMES{$scale} && $scale !~ /pinpoint=\d+,\d+/
    263263                { 
    264264                        print STDERR "Warning: Weird scale setting \"$scale\". Bailing out.\n"; 
     
    314314    push @params, "--log-file", $logfile; 
    315315 
     316    push @params, "--size_x", CGI::param("size_x") if (CGI::param("size_x")); 
     317    push @params, "--size_y", CGI::param("size_y") if (CGI::param("size_y")); 
     318 
     319    push @params, "--upper_limit", CGI::param("upper_limit") if (CGI::param("upper_limit")); 
     320    push @params, "--lower_limit", CGI::param("lower_limit") if (CGI::param("lower_limit")); 
     321 
     322 
     323 
    316324    my $file = "/dev/null"; 
    317325 
  • people/snide/pre_1.5/master/lib/Munin/Master/GraphOld.pm

    r3364 r3376  
    102102    "sumweek" => 1 
    103103); 
     104$draw{"pinpoint"} = 0; # XXX - Add a dummy pinpoint value 
     105 
     106my ($size_x, $size_y); 
     107my ($lower_limit, $upper_limit); 
    104108 
    105109my %PALETTE;    # Hash of available palettes 
     
    131135    "week"  => "-8d", 
    132136    "month" => "-33d", 
    133     "year"  => "-400d" 
     137    "year"  => "-400d", 
     138    "pinpoint"  => "dummy", 
    134139); 
    135140 
     
    161166# stats file handle 
    162167my $STATS; 
    163 my $DEBUG; 
     168my $DEBUG = 0; 
     169my $pinpoint = undef; 
    164170 
    165171my %init_draw = %draw; 
     
    195201                "month!"        => \$draw{'month'}, 
    196202                "year!"         => \$draw{'year'}, 
     203                "pinpoint=s"    => \$draw{'pinpoint'}, 
    197204                "sumweek!"      => \$draw{'sumweek'}, 
    198205                "sumyear!"      => \$draw{'sumyear'}, 
     206                "size_x=i"      => \$size_x, 
     207                "size_y=i"      => \$size_y, 
     208                "upper_limit=s" => \$upper_limit, 
     209                "lower_limit=s" => \$lower_limit, 
    199210                "list-images!"  => \$list_images, 
    200211                "o|output-file=s"  => \$output_file, 
     
    223234 
    224235    # untaint the $log_file variable 
    225     $log_file = $1 if $log_file && $log_file =~ m/(.*)/
     236    $log_file = $1 if ($log_file && $log_file =~ m/(.*)/)
    226237 
    227238    logger_open($config->{'logdir'}, $log_file); 
    228239    logger_debug() if $DEBUG; 
     240     
     241    # XXX - Special hack^h^h^h^h treatment for --pinpoint 
     242    if ($draw{'pinpoint'} && $draw{'pinpoint'} =~ m/^(\d+),(\d+)$/ ) { 
     243            %draw = ( "pinpoint" => $draw{'pinpoint'} ); # "pinpoint" replaces all the other timing options 
     244            $pinpoint = { "start" => $1, "end" => $2, }; # preparsed values 
     245    } 
    229246 
    230247    my $palette = &munin_get($config, "palette", "default"); 
     
    300317    my $scale   = shift; 
    301318 
    302     return (munin_get($service, "graph_title", $service) . " - by $scale"); 
     319    my $scale_text; 
     320    if ($pinpoint) { 
     321            my $start_text = localtime($pinpoint->{"start"}); 
     322            my $end_text = localtime($pinpoint->{"end"}); 
     323            $scale_text = "from $start_text to $end_text"; 
     324    } else { 
     325        $scale_text = "by " . $scale; 
     326    } 
     327 
     328    return (munin_get($service, "graph_title", $service) . " - $scale_text"); 
    303329} 
    304330 
     
    354380 
    355381    # When to start the graph 
    356     push @$result, "--start", $times{$scale}; 
     382    if ($pinpoint) { 
     383        push @$result, "--start", $pinpoint->{start}; 
     384        push @$result, "--end", $pinpoint->{end}; 
     385    } else { 
     386        push @$result, "--start", $times{$scale}; 
     387    } 
    357388 
    358389    # Custom graph args, vlabel and graph title 
     
    364395    } 
    365396 
    366     push @$result, "--height", munin_get($service, "graph_height", "175"); 
    367     push @$result, "--width",  munin_get($service, "graph_width",  "400"); 
     397    push @$result, "--height", ($size_y || munin_get($service, "graph_height", "175")); 
     398    push @$result, "--width",  ($size_x || munin_get($service, "graph_width",  "400")); 
     399 
     400    push @$result,"--rigid" if (defined $lower_limit || defined $upper_limit); 
     401 
    368402    push @$result, "--imgformat", "PNG"; 
    369403    push @$result, "--lazy" if ($force_lazy); 
     
    11381172                . "\\r"); 
    11391173 
    1140         if (time - 300 < $lastupdate) { 
     1174        if (time - 300 < $lastupdate && ! $pinpoint) { 
    11411175            if (@added) { # stop one period earlier if it's a .sum or .stack 
    11421176                push @complete, "--end", 
     
    11651199        } 
    11661200 
     1201        # Surcharging the graphing limits 
     1202        my ($upper_limit_overrided, $lower_limit_overrided); 
     1203        for (my $index = 0; $index <= $#complete; $index++) { 
     1204                if ($complete[$index] =~ /^(--upper-limit|-u)$/ && (defined $upper_limit)) { 
     1205                        $upper_limit = get_scientific($upper_limit); 
     1206                        $complete[$index + 1] = $upper_limit; 
     1207                        $upper_limit_overrided = 1; 
     1208                } 
     1209                if ($complete[$index] =~ /^(--lower-limit|-l)$/ && (defined $lower_limit)) { 
     1210                        $lower_limit = get_scientific($lower_limit); 
     1211                        $complete[$index + 1] = $lower_limit; 
     1212                        $lower_limit_overrided = 1; 
     1213                } 
     1214        } 
     1215 
     1216        # Add the limit if not present 
     1217        if (defined $upper_limit && ! $upper_limit_overrided) { 
     1218                push @complete, "--upper-limit", $upper_limit; 
     1219        } 
     1220        if (defined $lower_limit && ! $lower_limit_overrided) { 
     1221                push @complete, "--lower-limit", $lower_limit; 
     1222        } 
     1223 
    11671224        $nb_graphs_drawn ++; 
    11681225        RRDs::graph(@complete); 
     
    11991256            push @rrd_sum, @{get_header($service, $time, 1)}; 
    12001257 
    1201             if (time - 300 < $lastupdate) { 
     1258            if (time - 300 < $lastupdate && ! $pinpoint) { 
    12021259                if (@added) { # stop 5 minutes earlier if it's a .sum or .stack 
    12031260                    push @rrd_sum, "--end", 
     
    14411498} 
    14421499 
     1500# Wrapper for munin_get_picture_filename to handle pinpoint 
    14431501sub get_picture_filename { 
    14441502        if (defined $output_file) { return $output_file; } 
     
    14531511    $text =~ s/:/\\:/g; 
    14541512    return $text; 
     1513} 
     1514 
     1515sub get_scientific { 
     1516        my $value = shift; 
     1517        $value =~ s/m/e-03/; 
     1518        $value =~ s/k/e+03/; 
     1519        $value =~ s/M/e+06/; 
     1520        $value =~ s/G/e+09/; 
     1521        return $value; 
    14551522} 
    14561523 
     
    14931560    --[no]sumyear       Create summarised year-graphs.  [--sumyear] 
    14941561 
     1562    --pinpoint <start,stop> Create custom-graphs. <start,stop> is the standard unix Epoch. [not active] 
     1563    --size_x <pixels>   Sets the X size of the graph in pixels [175] 
     1564    --size_y <pixels>   Sets the Y size of the graph in pixels [400] 
     1565    --lower_limit <lim> Sets the lower limit of the graph 
     1566    --upper_limit <lim> Sets the upper limit of the graph 
     1567 
    14951568"; 
    14961569    exit 0; 
  • people/snide/pre_1.5/master/lib/Munin/Master/HTMLOld.pm

    r3365 r3376  
    415415    # NOTE: The templates have hardcoded path to definitions.html, and it is not right, esp. when 
    416416    # we have nested groups and nested services. 
    417     my @files = ("style.css", "logo.png", "logo-h.png", "definitions.html", "favicon.ico"); 
     417    my @files = ( 
     418            "style.css", "logo.png", "logo-h.png", "definitions.html", "favicon.ico", 
     419            "dynazoom.html", "formatdate.js", "querystring.js", 
     420    ); 
    418421 
    419422    foreach my $file ((@files)) { 
     
    962965    } 
    963966 
     967    # Compute the ZOOM urls 
     968    { 
     969        my $epoch_now = time; 
     970        # The intervals are a bit larger, just like the munin-graph 
     971        my $start_day = $epoch_now - (3600 * 30); 
     972        my $start_week = $epoch_now - (3600 * 24 * 8); 
     973        my $start_month = $epoch_now - (3600 * 24 * 33); 
     974        my $start_year = $epoch_now - (3600 * 24 * 400); 
     975        my $size_x = 800; 
     976        my $size_y = 400; 
     977        my $common_url = "$root_path/dynazoom.html?plugin_name=$path&size_x=$size_x&size_y=$size_y"; 
     978        $srv{zoomday} = "$common_url&start_epoch=$start_day&stop_epoch=$epoch_now"; 
     979        $srv{zoomweek} = "$common_url&start_epoch=$start_week&stop_epoch=$epoch_now"; 
     980        $srv{zoommonth} = "$common_url&start_epoch=$start_month&stop_epoch=$epoch_now"; 
     981        $srv{zoomyear} = "$common_url&start_epoch=$start_year&stop_epoch=$epoch_now"; 
     982    } 
     983 
    964984    for my $scale (@times) { 
    965985        if (my ($w, $h) 
  • people/snide/pre_1.5/master/lib/Munin/Master/Logger.pm

    r3317 r3376  
    7373my $logdir = undef; 
    7474my $logopened = 0; 
    75 my $me = basename($PROGRAM_NAME); 
     75my $me = $1 if basename($PROGRAM_NAME) =~ m/(.*)/; # Fast untaint $PROGRAM_NAME 
    7676 
    7777sub _warn_catcher { 
  • people/snide/pre_1.5/master/www/munin-serviceview.tmpl

    r2956 r3376  
    1515      <!-- Table row: Day image --> 
    1616      <!-- Note, the class of the img does not work to set border width and color.  Could be something to do with the table? --> 
    17       <td><img src="<TMPL_VAR NAME="IMGDAY">" alt="daily graph" <TMPL_IF NAME="IMGDAYWIDTH">width="<TMPL_VAR NAME="IMGDAYWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGDAYHEIGHT">height="<TMPL_VAR NAME="IMGDAYHEIGHT">"</TMPL_IF>/></td> 
     17      <td><a href="<TMPL_VAR NAME="ZOOMDAY">"><img src="<TMPL_VAR NAME="IMGDAY">" alt="daily graph" <TMPL_IF NAME="IMGDAYWIDTH">width="<TMPL_VAR NAME="IMGDAYWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGDAYHEIGHT">height="<TMPL_VAR NAME="IMGDAYHEIGHT">"</TMPL_IF>/></a></td> 
    1818      <!-- cont'd: Week image --> 
    19       <td><img src="<TMPL_VAR NAME="IMGWEEK">" alt="weekly graph" <TMPL_IF NAME="IMGWEEKWIDTH">width="<TMPL_VAR NAME="IMGWEEKWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGWEEKHEIGHT">height="<TMPL_VAR NAME="IMGWEEKHEIGHT">"</TMPL_IF>/></td> 
     19      <td><a href="<TMPL_VAR NAME="ZOOMWEEK">"><img src="<TMPL_VAR NAME="IMGWEEK">" alt="weekly graph" <TMPL_IF NAME="IMGWEEKWIDTH">width="<TMPL_VAR NAME="IMGWEEKWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGWEEKHEIGHT">height="<TMPL_VAR NAME="IMGWEEKHEIGHT">"</TMPL_IF>/></a></td> 
    2020    </tr> 
    2121    <tr> 
    2222      <!-- New table row: Month image --> 
    23       <td><img src="<TMPL_VAR NAME="IMGMONTH">" alt="monthly graph" <TMPL_IF NAME="IMGMONTHWIDTH">width="<TMPL_VAR NAME="IMGMONTHWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGMONTHHEIGHT">height="<TMPL_VAR NAME="IMGMONTHHEIGHT">"</TMPL_IF>/></td> 
     23      <td><a href="<TMPL_VAR NAME="ZOOMMONTH">"><img src="<TMPL_VAR NAME="IMGMONTH">" alt="monthly graph" <TMPL_IF NAME="IMGMONTHWIDTH">width="<TMPL_VAR NAME="IMGMONTHWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGMONTHHEIGHT">height="<TMPL_VAR NAME="IMGMONTHHEIGHT">"</TMPL_IF>/></a></td> 
    2424      <!-- cont'd: Year image --> 
    25       <td><img src="<TMPL_VAR NAME="IMGYEAR">" alt="yearly graph" <TMPL_IF NAME="IMGYEARWIDTH">width="<TMPL_VAR NAME="IMGYEARWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGYEARHEIGHT">height="<TMPL_VAR NAME="IMGYEARHEIGHT">"</TMPL_IF>/></td> 
     25      <td><a href="<TMPL_VAR NAME="ZOOMYEAR">"><img src="<TMPL_VAR NAME="IMGYEAR">" alt="yearly graph" <TMPL_IF NAME="IMGYEARWIDTH">width="<TMPL_VAR NAME="IMGYEARWIDTH">" </TMPL_IF> <TMPL_IF NAME="IMGYEARHEIGHT">height="<TMPL_VAR NAME="IMGYEARHEIGHT">"</TMPL_IF>/></a></td> 
    2626    </tr> 
    2727    <!-- .sum graphs.  One of the least used features of munin? -->