205
205
my ($worker_id, $time_used, $service_configs)
206
206
= ($res->[0], $res->[1]{time_used}, $res->[1]{service_configs});
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.";
281
283
sub _write_new_service_configs {
282
284
my ($self, $io) = @_;
285
my $datafile_hash = {};
284
287
print $io "version $Munin::Common::Defaults::MUNIN_VERSION\n";
288
$datafile_hash->{version} = $Munin::Common::Defaults::MUNIN_VERSION;
286
$self->_print_old_service_configs_for_failed_workers($io);
290
$self->_print_old_service_configs_for_failed_workers($io, $datafile_hash);
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]);
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});
307
# Also write the binary (Storable) version
308
munin_writeconfig_storable($config->{dbdir}.'/datafile.storable', $datafile_hash);
303
312
sub _print_old_service_configs_for_failed_workers {
304
my ($self, $handle) = @_;
313
my ($self, $handle, $datafile_hash) = @_;
306
315
for my $worker (@{$self->{failed_workers}}) {
307
316
# The empty set contains "undef" it seems
321
330
or ($datum eq 'host_name');
323
332
printf $handle "%s:%s %s\n", $worker, $datum, $workerdata->{$datum};
333
munin_set_var_path($datafile_hash, $worker . ":". $datum, $workerdata->{$datum});