Changeset 3376
- Timestamp:
- 02/25/10 02:09:11 (5 months ago)
- Files:
-
- people/snide/pre_1.5/Makefile (modified) (3 diffs)
- people/snide/pre_1.5/master/_bin/munin-fastcgi-graph.in (modified) (7 diffs)
- people/snide/pre_1.5/master/lib/Munin/Master/GraphOld.pm (modified) (14 diffs)
- people/snide/pre_1.5/master/lib/Munin/Master/HTMLOld.pm (modified) (2 diffs)
- people/snide/pre_1.5/master/lib/Munin/Master/Logger.pm (modified) (1 diff)
- people/snide/pre_1.5/master/www/dynazoom.html (added)
- people/snide/pre_1.5/master/www/formatdate.js (added)
- people/snide/pre_1.5/master/www/munin-serviceview.tmpl (modified) (1 diff)
- people/snide/pre_1.5/master/www/querystring.js (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
people/snide/pre_1.5/Makefile
r3317 r3376 88 88 $(CHMOD) 0755 $(DBDIR) 89 89 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 \ 91 91 $(INSTALL) -m 0644 "$$p" $(CONFDIR)/templates/ ; \ 92 92 done … … 97 97 98 98 $(INSTALL) -m 0644 master/www/definitions.html $(CONFDIR)/templates/ 99 $(INSTALL) -m 0644 master/www/dynazoom.html $(CONFDIR)/templates/ 99 100 $(INSTALL) -m 0755 master/DejaVuSansMono.ttf $(LIBDIR)/ 100 101 $(INSTALL) -m 0755 master/DejaVuSans.ttf $(LIBDIR)/ … … 109 110 $(INSTALL) -m 0755 build/master/_bin/munin-html $(LIBDIR)/ 110 111 $(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 114 113 115 114 # Not ready to be installed yet people/snide/pre_1.5/master/_bin/munin-fastcgi-graph.in
r3329 r3376 32 32 use IPC::SysV qw(IPC_CREAT); 33 33 use CGI::Fast; 34 use CGI::Carp 'fatalsToBrowser'; 34 35 35 36 my $GRAPHER = "$Munin::Common::Defaults::MUNIN_LIBDIR/munin-graph"; … … 71 72 while (new CGI::Fast) { 72 73 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 } 74 80 75 81 if (! &verify_parameters ($dom, $host, $serv, $scale)) { … … 86 92 87 93 # 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; 89 95 90 96 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"); 92 104 goto draw; 93 105 } … … 113 125 114 126 draw: 127 my $period_scale = $pinpoint ? 1 : $period{$scale}; 115 128 @stats = stat ($filename); # restat to be sure 116 129 $last_modified = strftime ("%a, %d %b %Y %H:%M:%S %Z", localtime ($stats[9])) unless defined($last_modified); 117 130 # "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); 120 133 121 134 print "Status: 200\n"; 122 135 print "Content-Type: image/png\n"; 123 136 print "Content-Length: $stats[7]\n"; 124 print "Expires: ", $expires, "\n";137 #print "Expires: ", $expires, "\n"; 125 138 print "Last-Modified: $last_modified\n"; 126 139 print "\n"; … … 183 196 184 197 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 }198 198 } 199 199 … … 260 260 else 261 261 { 262 if (!defined $TIMES{$scale} )262 if (!defined $TIMES{$scale} && $scale !~ /pinpoint=\d+,\d+/) 263 263 { 264 264 print STDERR "Warning: Weird scale setting \"$scale\". Bailing out.\n"; … … 314 314 push @params, "--log-file", $logfile; 315 315 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 316 324 my $file = "/dev/null"; 317 325 people/snide/pre_1.5/master/lib/Munin/Master/GraphOld.pm
r3364 r3376 102 102 "sumweek" => 1 103 103 ); 104 $draw{"pinpoint"} = 0; # XXX - Add a dummy pinpoint value 105 106 my ($size_x, $size_y); 107 my ($lower_limit, $upper_limit); 104 108 105 109 my %PALETTE; # Hash of available palettes … … 131 135 "week" => "-8d", 132 136 "month" => "-33d", 133 "year" => "-400d" 137 "year" => "-400d", 138 "pinpoint" => "dummy", 134 139 ); 135 140 … … 161 166 # stats file handle 162 167 my $STATS; 163 my $DEBUG; 168 my $DEBUG = 0; 169 my $pinpoint = undef; 164 170 165 171 my %init_draw = %draw; … … 195 201 "month!" => \$draw{'month'}, 196 202 "year!" => \$draw{'year'}, 203 "pinpoint=s" => \$draw{'pinpoint'}, 197 204 "sumweek!" => \$draw{'sumweek'}, 198 205 "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, 199 210 "list-images!" => \$list_images, 200 211 "o|output-file=s" => \$output_file, … … 223 234 224 235 # 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/(.*)/); 226 237 227 238 logger_open($config->{'logdir'}, $log_file); 228 239 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 } 229 246 230 247 my $palette = &munin_get($config, "palette", "default"); … … 300 317 my $scale = shift; 301 318 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"); 303 329 } 304 330 … … 354 380 355 381 # 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 } 357 388 358 389 # Custom graph args, vlabel and graph title … … 364 395 } 365 396 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 368 402 push @$result, "--imgformat", "PNG"; 369 403 push @$result, "--lazy" if ($force_lazy); … … 1138 1172 . "\\r"); 1139 1173 1140 if (time - 300 < $lastupdate ) {1174 if (time - 300 < $lastupdate && ! $pinpoint) { 1141 1175 if (@added) { # stop one period earlier if it's a .sum or .stack 1142 1176 push @complete, "--end", … … 1165 1199 } 1166 1200 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 1167 1224 $nb_graphs_drawn ++; 1168 1225 RRDs::graph(@complete); … … 1199 1256 push @rrd_sum, @{get_header($service, $time, 1)}; 1200 1257 1201 if (time - 300 < $lastupdate ) {1258 if (time - 300 < $lastupdate && ! $pinpoint) { 1202 1259 if (@added) { # stop 5 minutes earlier if it's a .sum or .stack 1203 1260 push @rrd_sum, "--end", … … 1441 1498 } 1442 1499 1500 # Wrapper for munin_get_picture_filename to handle pinpoint 1443 1501 sub get_picture_filename { 1444 1502 if (defined $output_file) { return $output_file; } … … 1453 1511 $text =~ s/:/\\:/g; 1454 1512 return $text; 1513 } 1514 1515 sub 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; 1455 1522 } 1456 1523 … … 1493 1560 --[no]sumyear Create summarised year-graphs. [--sumyear] 1494 1561 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 1495 1568 "; 1496 1569 exit 0; people/snide/pre_1.5/master/lib/Munin/Master/HTMLOld.pm
r3365 r3376 415 415 # NOTE: The templates have hardcoded path to definitions.html, and it is not right, esp. when 416 416 # 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 ); 418 421 419 422 foreach my $file ((@files)) { … … 962 965 } 963 966 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 964 984 for my $scale (@times) { 965 985 if (my ($w, $h) people/snide/pre_1.5/master/lib/Munin/Master/Logger.pm
r3317 r3376 73 73 my $logdir = undef; 74 74 my $logopened = 0; 75 my $me = basename($PROGRAM_NAME);75 my $me = $1 if basename($PROGRAM_NAME) =~ m/(.*)/; # Fast untaint $PROGRAM_NAME 76 76 77 77 sub _warn_catcher { people/snide/pre_1.5/master/www/munin-serviceview.tmpl
r2956 r3376 15 15 <!-- Table row: Day image --> 16 16 <!-- 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> 18 18 <!-- 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> 20 20 </tr> 21 21 <tr> 22 22 <!-- 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> 24 24 <!-- 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> 26 26 </tr> 27 27 <!-- .sum graphs. One of the least used features of munin? -->
