Changeset 1297
- Timestamp:
- 08/28/07 16:07:44 (4 years ago)
- Files:
-
- people/jo/multilevel-groups/server/Munin.pm.in (modified) (4 diffs)
- people/jo/multilevel-groups/server/munin-graph.in (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
people/jo/multilevel-groups/server/Munin.pm.in
r1296 r1297 60 60 'munin_copy_node_toloc', 61 61 'munin_get_separated_node', 62 'munin_mkdir_p' 62 'munin_mkdir_p', 63 'munin_get_node_partialpath' 63 64 ); 64 65 … … 573 574 } 574 575 576 # munin_get_node_partialpath: gets a node froma partial path 577 # Parameters: 578 # - $hash: A ref to the "current" location in the hash tree 579 # - $var: A path string with relative location (from the $hash). 580 # Returns: 581 # - Success: The node 582 # - Failure: undef 583 sub munin_get_node_partialpath 584 { 585 my $hash = shift; 586 my $var = shift; 587 my $ret = undef; 588 589 return undef if !defined $hash or ref ($hash) ne "HASH"; 590 591 my $root = munin_get_root_node ($hash); 592 my $hashloc = munin_get_node_loc ($hash); 593 my $varloc = undef; 594 595 if ($var =~ /^\s*([^:]+):(\S+)\s*$/) { 596 my ($leftstring, $rightstring) = ($1, $2); 597 598 my @leftarr = split (/;/, $leftstring); 599 my @rightarr = split (/\./, $rightstring); 600 push @$varloc, @leftarr, @rightarr 601 } elsif ($var =~ /^\s*([^;:\.]+)\s*$/) { 602 push @$varloc, $var; 603 } elsif ($var =~ /^\s*(.+)\.([^\.:;]+)$/) { 604 my ($leftstring, $rightstring) = ($1, $2); 605 606 my @leftarr = split (/;/, $leftstring); 607 my @rightarr = split (/\./, $rightstring); 608 push @$varloc, @leftarr, @rightarr; 609 } elsif ($var =~ /^\s*(\S+)\s*$/) { 610 my @leftarr = split (/;/, $1); 611 push @$varloc, @leftarr; 612 } else { 613 ::logger ("Error: munin_get_node_partialpath: Malformatted variable path \"$var\"."); 614 } 615 616 # We've got both parts of the loc (varloc and hashloc) -- let's figure out 617 # where they meet up. 618 do { 619 $ret = munin_get_node ($root, [@$hashloc, @$varloc]); 620 } while (!defined $ret and pop @$hashloc); 621 622 return $ret; 623 } 624 575 625 # munin_set_var_path: sets a variable in a hash 576 626 # Parameters: … … 1187 1237 my $name = munin_get_node_name ($field); 1188 1238 1239 # Bail out on bad input data 1240 return undef if !defined $field or ref ($field) ne "HASH"; 1241 1189 1242 # If the field has a .filename setting, use it 1190 1243 return $result if $result = munin_get ($field, "filename"); … … 1192 1245 # Handle custom paths (used in .sum, .stack, graph_order, et al) 1193 1246 if (defined $path and length $path) { 1194 if (!munin_get ($field, "label")) { 1195 print "DEBUG: Setting label: $name\n" if $DEBUG; 1196 munin_set_var_loc ($field, ["label"], $name); 1197 } 1198 1199 my $sourcenode = munin_get_node (munin_get_root_node ($field), munin_path_to_loc ($path)); 1247 1248 my $sourcenode = munin_get_node_partialpath ($field, $path); 1200 1249 $result = munin_get_filename ($sourcenode); 1201 1250 people/jo/multilevel-groups/server/munin-graph.in
r1296 r1297 319 319 my $fieldnum = 0; 320 320 for my $field (@$order) { # Search for 'specials'... 321 322 if ($field =~ /^-(.+)$/) { 321 my $tmp_field; 322 323 if ($field =~ /^-(.+)$/) { # Invisible field 323 324 $field = $1; 324 325 munin_set_var_loc ($service, [$field, "graph"], "no"); … … 326 327 327 328 $fieldnum++; 328 my $tmp_field; 329 if (defined ($tmp_field = &get_stack_command ($service->{$field}))) { 330 print "DEBUG: Doing special_stack...\n" if $DEBUG; 329 if ($field =~ /^([^=]+)=(.+)$/) { # Aliased in graph_order 330 my $fname = $1; 331 my $spath = $2; 332 my $src = munin_get_node_partialpath ($service, $spath); 333 my $sname = munin_get_node_name ($src); 334 335 next unless defined $src; 336 logger ("Debug: Copying settings from $sname to $fname.") if $DEBUG; 337 338 foreach my $foption ("draw", "type", "rrdfile", "fieldname", "info") { 339 if (!defined $service->{$fname}->{$foption}) { 340 if (defined $src->{$foption}) { 341 munin_set_var_loc ($service, [$fname, $foption], $src->{$foption}); 342 } 343 } 344 } 345 346 # cdef is special... 347 if (!defined $service->{$fname}->{"cdef"}) { 348 if (defined $src->{"cdef"}) { 349 (my $tmpcdef = $src->{"cdef"}) =~ s/([,=])$sname([,=]|$)/$1$fname$2/g; 350 munin_set_var_loc ($service, [$fname, "cdef"], $tmpcdef); 351 } 352 } 353 354 munin_set_var_loc ($service, [$fname, "label"], $fname); 355 munin_set_var_loc ($service, [$fname, "filename"], munin_get_rrd_filename ($src)); 356 357 } elsif (defined ($tmp_field = get_stack_command ($service->{$field}))) { 358 logger ("DEBUG: expand_specials ($tmp_field): Doing stack...") if $DEBUG; 331 359 my @spc_stack = (); 332 360 foreach my $pre (split (/\s+/, $tmp_field)) { 333 361 (my $name = $pre) =~ s/=.+//; 334 362 if (!@spc_stack) { 335 munin_set_var_loc ($service ->{$name}, ["draw"], munin_get ($service->{$field}, "draw"));336 munin_set_var_loc ($service ->{$field}, ["process"], "no");363 munin_set_var_loc ($service, [$name, "draw"], munin_get ($service->{$field}, "draw", "LINE2")); 364 munin_set_var_loc ($service, [$field, "process"], "no"); 337 365 } else { 338 munin_set_var_loc ($service ->{$name}, ["draw"], "STACK");366 munin_set_var_loc ($service, [$name, "draw"], "STACK"); 339 367 } 340 368 push (@spc_stack, $name); … … 344 372 push @$result, "$name.cdef"; 345 373 346 munin_set_var_loc ($service ->{$name}, ["label"], $name);347 munin_set_var_loc ($service ->{$name}, ["cdef"], "$name,UN,0,$name,IF");374 munin_set_var_loc ($service, [$name, "label"], $name); 375 munin_set_var_loc ($service, [$name, "cdef"], "$name,UN,0,$name,IF"); 348 376 if (munin_get ($service->{$field}, "cdef") and !munin_get_bool ($service->{$name}, "onlynullcdef", 0)) { 349 print "NotOnlynullcdef ($field)...\n"if $DEBUG;377 logger ("NotOnlynullcdef ($field)...") if $DEBUG; 350 378 $service->{$name}->{"cdef"} .= "," . $service->{$field}->{"cdef"}; 351 379 $service->{$name}->{"cdef"} =~ s/\b$field\b/$name/g; 352 380 } else { 353 print "Onlynullcdef ($field)...\n"if $DEBUG;354 munin_set_var_loc ($service ->{$name}, ["onlynullcdef"], 1);381 logger ("Onlynullcdef ($field)...") if $DEBUG; 382 munin_set_var_loc ($service, [$name, "onlynullcdef"], 1); 355 383 push @$result, "$name.onlynullcdef"; 356 384 } 357 385 } 358 } elsif (defined ($tmp_field = &get_sum_command ($service->{$field}))) {386 } elsif (defined ($tmp_field = get_sum_command ($service->{$field}))) { 359 387 my @spc_stack = (); 360 388 my $last_name = ""; 361 print "DEBUG: Doing special_sum...\n"if $DEBUG;389 logger ("DEBUG: expand_specials ($tmp_field): Doing sum...") if $DEBUG; 362 390 363 391 if (@$order == 1 or (@$order == 2 and munin_get {$field, "negative", 0})) { … … 451 479 452 480 # See if we should skip the service 453 nextif (skip_service ($service));481 return if (skip_service ($service)); 454 482 455 483 my $field_count = 0; … … 471 499 472 500 # Get max label length 473 $max_field_len = &munin_get_max_label_length ($service, \@field_order);501 $max_field_len = munin_get_max_label_length ($service, \@field_order); 474 502 475 503 # Global headers makes the value tables easier to read no matter how … … 505 533 logger ("DEBUG: Treating fields \"" . join ("\",\"", @field_order) . "\".") if $DEBUG; 506 534 for my $fname (@field_order) { 507 my $field = munin_get_node ($service, [$fname]);508 535 my $path = undef; 536 my $field = undef; 509 537 510 538 if ($fname =~ s/=(.+)//) { 511 539 $path = $1; 512 540 } 541 $field = munin_get_node ($service, [$fname]); 513 542 514 543 next if !process_field ($field); 515 logger ("DEBUG: Processing field \"$fname\" .") if $DEBUG;544 logger ("DEBUG: Processing field \"$fname\" [".munin_get_node_name($field)."].") if $DEBUG; 516 545 517 546 my $fielddraw = munin_get ($field, "draw", "LINE2"); … … 794 823 RRDs::graph (@complete); 795 824 if (my $ERROR = RRDs::error) { 796 logger ("Unable to graph $filename: $ERROR");825 logger ("Unable to graph ". munin_get_picture_filename ($service, $time) . ": $ERROR"); 797 826 } elsif ($list_images) { 798 827 # Command-line option to list images created … … 876 905 877 906 if (my $ERROR = RRDs::error) { 878 logger ("Unable to graph $filename: $ERROR");907 logger ("Unable to graph ". munin_get_picture_filename ($service, $time) . ": $ERROR"); 879 908 } elsif ($list_images) { 880 909 # Command-line option to list images created … … 888 917 print STATS "GS|$service_time\n" unless $skip_stats; 889 918 919 print "Final look of service subtree: ", Dumper (munin_get_separated_node ($service)), "\n\n"; 890 920 foreach (@added) { 891 921 delete $service->{$_} if exists $service->{$_}; … … 914 944 sub skip_service { 915 945 my $service = shift; 946 my $sname = munin_get_node_name ($service); 947 948 # Skip if we've limited services with cli options 949 return 1 if (@limit_services and !grep /^$sname$/, @limit_services); 916 950 917 951 # Always graph if --force is present
