Changeset 1494

Show
Ignore:
Timestamp:
02/26/08 23:37:49 (4 years ago)
Author:
jo
Message:

A tiny bit further in getting munin-limits to understand multilevel-groups.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/jo/multilevel-groups-2/server/Munin.pm.in

    r1493 r1494  
    413413# Parameters:  
    414414# - $hash: A hash ref to search 
    415 # - $field: The name of the field to search for 
     415# - $field: The name of the field to search for, or a regex 
    416416# - $avoid: [optional] Stop traversing further down if this field is found 
    417417# Returns: 
     
    424424    my $res = []; 
    425425 
     426    if (ref ($field) ne "Regexp") { 
     427        if ($field =~ /^\^/) { 
     428            $field = qr/^$field$/; 
     429        } else { 
     430            $field = qr/$field/; 
     431        } 
     432    } 
     433 
    426434    if (ref ($hash) eq "HASH") { 
    427435        ::logger ("Debug: Searching for $field in " . join ('::', @{munin_get_node_loc ($hash)})); 
     
    429437            next if $key =~ /^#%#/; 
    430438            last if defined $avoid and $key eq $avoid; 
    431             if ($key eq $field) { 
     439            if ($key =~ $field) { 
    432440                push @$res, $hash; 
    433441            } elsif (ref ($hash->{$key}) eq "HASH") { 
  • people/jo/multilevel-groups-2/server/munin-graph.in

    r1353 r1494  
    540540        $field = munin_get_node ($service, [$fname]); 
    541541 
    542         next if !process_field ($field); 
     542        next if (!defined $field or !$field or !process_field ($field)); 
    543543        logger ("DEBUG: Processing field \"$fname\" [".munin_get_node_name($field)."].") if $DEBUG; 
    544544 
  • people/jo/multilevel-groups-2/server/munin-limits.in

    r1493 r1494  
    106106} 
    107107 
    108 for my $domain ( keys %{$config->{domain}}) { 
    109     logger ("processing domain: $domain")
    110     process_domain($domain)
    111 
     108# Make array of what is probably to check for notifications 
     109my $work_array = []
     110push @$work_array, map { munin_get_parent_node ($_) } @{munin_find_field($config, qr/^(critical|warning|crit|warn)$/)}
     111 
    112112&munin_writeconfig ("$config->{dbdir}/limits", \%notes); 
    113113 
     
    116116logger("munin-limits finished ($update_time sec)"); 
    117117 
    118 sub process_group { 
    119     my $hash = shift || return undef; 
    120     my $name = munin_get_node_name ($hash); 
    121  
    122     if ($hash and ref ($hash) eq "HASH") { 
    123         if (defined $hash->{'graph_title'}) { # Graph, need to check limits 
    124             logger ("processing plugin: $name") if $DEBUG; 
    125             process_service ($hash); 
    126         } else { 
    127             foreach my $childobj (munin_get_children ($hash)) { 
    128                 next unless ref ($childobj) eq "HASH"; 
    129                 logger ("processing group: $name") if $DEBUG; 
    130                 process_group ($childobj); 
    131             } 
    132         } 
    133     } 
    134 
     118print Data::Dumper ($work_array); 
     119 
     120exit 0; 
    135121 
    136122sub process_service { 
     
    144130 
    145131    # Some fields that are nice to have in the plugin output 
    146     $hash->{'fields'} = join (' ', map { munin_get_node_name ($_) } @$children))
     132    $hash->{'fields'} = join (' ', map { munin_get_node_name ($_) } @$children)
    147133    $hash->{'plugin'} = $service; 
    148134    $hash->{'graph_title'} = $hash->{'notify_alias'} if defined $hash->{'notify_alias'};