Changeset 3355

Show
Ignore:
Timestamp:
02/14/10 12:01:07 (2 years ago)
Author:
steve.schnepp
Message:

- Implementation of dirtyconfig (fixes #836)
- Converts the standard df plugin for dirtyconfig

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/snide/pre_1.5/master/lib/Munin/Master/Node.pm

    r3321 r3355  
    3131        reader  => undef, 
    3232        writer  => undef, 
    33         master_capabilities => qw(multigraph), 
     33        master_capabilities => qw(multigraph dirtyconfig), 
    3434        io_timeout => 120, 
    3535        configref => $configref, 
  • people/snide/pre_1.5/master/lib/Munin/Master/UpdateWorker.pm

    r3351 r3355  
    8484                } 
    8585 
    86                 # Check if this plugin has to be updated 
    87                 my $update_rate_in_seconds = get_global_service_value(\%service_config, $plugin, "update_rate", 0); # default is 0 sec : always update when asked 
    88                 DEBUG "[DEBUG] update_rate $update_rate_in_seconds for $plugin on $nodedesignation"; 
    89                 if ($update_rate_in_seconds  
    90                         && is_fresh_enough($nodedesignation, $plugin, $update_rate_in_seconds)) { 
    91                     # It's fresh enough, skip this $service 
    92                     DEBUG "[DEBUG] $plugin is fresh enough, not updating it"; 
    93                     next; 
     86                # Check if this plugin has already sent its data via a dirtyconfig 
     87                my %service_data = $self->handle_dirty_config(\%service_config); 
     88 
     89                if (! %service_data) { 
     90                        # Check if this plugin has to be updated 
     91                        my $update_rate_in_seconds = get_global_service_value(\%service_config, $plugin, "update_rate", 0); # default is 0 sec : always update when asked 
     92                        DEBUG "[DEBUG] update_rate $update_rate_in_seconds for $plugin on $nodedesignation"; 
     93                        if ($update_rate_in_seconds  
     94                                && is_fresh_enough($nodedesignation, $plugin, $update_rate_in_seconds)) { 
     95                            # It's fresh enough, skip this $service 
     96                            DEBUG "[DEBUG] $plugin is fresh enough, not updating it"; 
     97                            next; 
     98                        } 
     99 
     100                        %service_data = $self->{node}->fetch_service_data($plugin); 
    94101                } 
    95102 
    96                 my %service_data = $self->{node}->fetch_service_data($plugin); 
    97103 
    98104                # Since different plugins can populate multiple 
     
    203209 
    204210        return $is_fresh_enough; 
     211} 
     212 
     213sub handle_dirty_config { 
     214        my ($self, $service_config) = @_; 
     215         
     216        my %service_data; 
     217 
     218        my $services = $service_config->{global}{multigraph}; 
     219        foreach my $service (@$services) { 
     220                my $service_data_source = $service_config->{"data_source"}->{$service}; 
     221                foreach my $field (keys %$service_data_source) { 
     222                        my $field_value = $service_data_source->{$field}->{"value"}; 
     223                        # If not present, ignore 
     224                        next if (! defined $field_value); 
     225 
     226                        DEBUG "[DEBUG] handle_dirty_config:$service, $field, $field_value"; 
     227                        # Adds the service_data 
     228                        $service_data{$service}->{$field} = { 
     229                                "value" => $field_value, 
     230                                "when" => "N", # This may be the perfect candidate for "update_rate NNN/discrete" 
     231                        }; 
     232                } 
     233        } 
     234 
     235        return %service_data; 
    205236} 
    206237 
  • people/snide/pre_1.5/plugins/node.d/df.in

    r2314 r3355  
    5454        print_critical $name 
    5555    done 
    56     exit 0 
     56 
     57    # Q&D first dirtyconfig capable plugin 
     58    # exit 0 
    5759fi 
    5860