~ubuntu-branches/ubuntu/saucy/munin/saucy

« back to all changes in this revision

Viewing changes to master/lib/Munin/Master/Update.pm

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 12:54:28 UTC
  • mfrom: (8.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120611125428-k8z25s77rp755vxe
Tags: 2.0.0-1ubuntu1
* Resync with Debian unstable.
* d/munin-node.upstart,munin.upstart: Add upstart configurations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package Munin::Master::Update;
2
2
 
3
 
# $Id: Update.pm 3271 2009-12-30 11:19:05Z janl $
 
3
# $Id: Update.pm 4203 2011-05-30 14:15:45Z steve.schnepp $
4
4
 
5
5
use warnings;
6
6
use strict;
205
205
    my ($worker_id, $time_used, $service_configs) 
206
206
        = ($res->[0], $res->[1]{time_used}, $res->[1]{service_configs});
207
207
 
 
208
    my $update_time = sprintf("%.2f", $time_used);
 
209
    INFO "[INFO]: Munin-update finished for node $worker_id ($update_time sec)";
208
210
    if (! defined $self->{STATS} ) {
209
211
        # This is may only be the case when we get connection refused
210
212
        ERROR "[BUG!] Did not collect any stats for $worker_id.  If this message appears in your logs a lot please email munin-users.  Thanks.";
280
282
 
281
283
sub _write_new_service_configs {
282
284
    my ($self, $io) = @_;
 
285
    my $datafile_hash = {};
283
286
 
284
287
    print $io "version $Munin::Common::Defaults::MUNIN_VERSION\n";
 
288
    $datafile_hash->{version} = $Munin::Common::Defaults::MUNIN_VERSION;
285
289
 
286
 
    $self->_print_old_service_configs_for_failed_workers($io);
 
290
    $self->_print_old_service_configs_for_failed_workers($io, $datafile_hash);
287
291
 
288
292
    for my $host (keys %{$self->{service_configs}}) {
289
293
        for my $service (keys %{$self->{service_configs}{$host}{data_source}}) {
290
294
            for my $attr (@{$self->{service_configs}{$host}{global}{$service}}) {
291
295
                print $io "$host:$service.$attr->[0] $attr->[1]\n";
 
296
                munin_set_var_path($datafile_hash, "$host:$service.$attr->[0]", $attr->[1]);
292
297
            }
293
298
            for my $data_source (keys %{$self->{service_configs}{$host}{data_source}{$service}}) {
294
299
                for my $attr (keys %{$self->{service_configs}{$host}{data_source}{$service}{$data_source}}) {
295
300
                    print $io "$host:$service.$data_source.$attr $self->{service_configs}{$host}{data_source}{$service}{$data_source}{$attr}\n";
 
301
                    munin_set_var_path($datafile_hash, "$host:$service.$data_source.$attr", $self->{service_configs}{$host}{data_source}{$service}{$data_source}{$attr});
296
302
                }
297
303
            }
298
304
        }
299
305
    }
 
306
 
 
307
    # Also write the binary (Storable) version
 
308
    munin_writeconfig_storable($config->{dbdir}.'/datafile.storable', $datafile_hash);
300
309
}
301
310
 
302
311
 
303
312
sub _print_old_service_configs_for_failed_workers {
304
 
    my ($self, $handle) = @_;
 
313
    my ($self, $handle, $datafile_hash) = @_;
305
314
 
306
315
    for my $worker (@{$self->{failed_workers}}) {
307
316
        # The empty set contains "undef" it seems
321
330
                or ($datum eq 'host_name');
322
331
 
323
332
            printf $handle "%s:%s %s\n", $worker, $datum, $workerdata->{$datum};
 
333
            munin_set_var_path($datafile_hash, $worker . ":". $datum, $workerdata->{$datum});
324
334
        }
325
335
        
326
336
    }