Changeset 2726
- Timestamp:
- 10/27/09 13:17:17 (2 years ago)
- Files:
-
- trunk/master/lib/Munin/Master/Node.pm (modified) (13 diffs)
- trunk/master/lib/Munin/Master/Update.pm (modified) (1 diff)
- trunk/master/lib/Munin/Master/UpdateWorker.pm (modified) (16 diffs)
- trunk/master/t/munin_master_plugin_fetch.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/master/lib/Munin/Master/Node.pm
r2703 r2726 13 13 use Munin::Common::Timeout; 14 14 use Munin::Common::TLSClient; 15 use Munin::Master::Logger;16 15 use Data::Dumper; 17 16 use Log::Log4perl qw( :easy ); … … 69 68 sub _extract_name_from_greeting { 70 69 my ($self, $greeting) = @_; 71 croak "Got no reply from node" unless $greeting; 72 $greeting =~ /\#.*(?:lrrd|munin) (?:client|node) at (\S+)/ 73 or croak "Got unknown reply from node"; 70 if (!$greeting) { 71 die "[ERROR] Got no reply from node ".$self->{host}."\n"; 72 } 73 if (! $greeting =~ /\#.*(?:lrrd|munin) (?:client|node) at (\S+)/) { 74 die "[ERROR] Got unknown reply from node ".$self->{host}."\n"; 75 } 74 76 return $1; 75 77 } … … 102 104 $self->{tls} = undef; 103 105 if ($tls_requirement eq "paranoid" or $tls_requirement eq "enabled") { 104 croak("[ERROR] Could not establish TLS connection to '$self->{address}'. Skipping.");106 die "[ERROR] Could not establish TLS connection to '$self->{address}'. Skipping.\n"; 105 107 } 106 108 } … … 141 143 142 144 143 sub list_ services {145 sub list_plugins { 144 146 my ($self) = @_; 145 147 … … 148 150 : $self->{host}; 149 151 150 croak "Couldn't find out which host to list" unless $host; 152 if (not $host) { 153 die "[ERROR] Couldn't find out which host to list on $host.\n"; 154 } 151 155 152 156 $self->_node_write_single("list $host\n"); … … 154 158 155 159 if (not $list) { 156 logger("[WARNING] Config node $self->{host} listed no services for $host");160 WARN "[WARNING] Config node $self->{host} listed no services for $host"; 157 161 } 158 162 … … 164 168 my ($self, $service, @lines) = @_; 165 169 166 my @global_config = (); 167 my %data_source_config = (); 168 169 my @graph_order = (); 170 my $plugin = $service; 171 172 my $nodedesignation = $self->{host}."/".$self->{address}."/".$self->{port}; 173 174 my $global_config = { 175 multigraph => [], 176 }; 177 my $data_source_config = {}; 178 my @graph_order = ( ); 179 180 # Pascal style nested subroutine 181 local *new_service = sub { 182 push @{$global_config->{multigraph}}, $service; 183 $global_config->{$service} = []; 184 $data_source_config->{$service} = {}; 185 }; 186 187 local *push_graphorder = sub { 188 my ($oldservice) = @_; 189 190 push( @{$global_config->{$oldservice}}, 191 ['graph_order', join(' ', @graph_order)] ) 192 unless !@graph_order || 193 grep { $_->[0] eq 'graph_order' } @{$global_config->{$oldservice}}; 194 @graph_order = ( ); 195 }; 196 197 DEBUG "[DEBUG] Now parsing config output from plugin $plugin on ".$self->{host}; 198 199 new_service($service); 170 200 171 201 for my $line (@lines) { 172 croak "Client reported timeout in configuration of '$service'" 173 if $line =~ /\# timeout/; 202 203 DEBUG "[CONFIG from $plugin] $line"; 204 205 if ($line =~ /\# timeout/) { 206 die "[ERROR] Timeout error ($nodedesignation). Please consult the log.\n"; 207 } 208 174 209 next unless $line; 175 210 next if $line =~ /^\#/; 176 211 177 if ($line =~ m{\A (\w+)\.(\w+) \s+ (.+) }xms) { 212 if ($line =~ m{\A multigraph \s+ (.+) }xms) { 213 push_graphorder($service); 214 215 $service = $1; 216 217 if ($service eq 'multigraph') { 218 ERROR "[ERROR] SERVICE can't be named \"$service\" in plugin $plugin on ".$self->{host}."/".$self->{address}."/".$self->{port}; 219 croak("Illegal service name. Please consult the log"); 220 } 221 new_service($service); 222 DEBUG "[CONFIG multigraph $plugin] Service is now $service"; 223 } 224 elsif ($line =~ m{\A (\w+)\.(\w+) \s+ (.+) }xms) { 178 225 my ($ds_name, $ds_var, $ds_val) = ($1, $2, $3); 179 226 $ds_name = $self->_sanitise_fieldname($ds_name); 180 $data_source_config{$ds_name} ||= {}; 181 $data_source_config{$ds_name}{$ds_var} = $ds_val; 182 DEBUG "[CONFIG dataseries] $service->$ds_name.$ds_var = $ds_val"; 183 push @graph_order, $ds_name if ($ds_var eq 'label'); 184 } 185 elsif ($line =~ m{\A (\w+) \s+ (.+) }xms) { 186 push @global_config, [$1, $2]; 187 DEBUG "[CONFIG graph global] $service->$1 = $2"; 188 } 189 else { 190 croak "Protocol exception: while configuring '$service': unrecognised line '$line'"; 191 } 192 } 193 194 $self->_validate_data_sources(\%data_source_config); 195 196 push @global_config, ['graph_order', join(' ', @graph_order)] 197 unless !@graph_order || grep { $_->[0] eq 'graph_order' } @global_config; 198 199 return (global => \@global_config, data_source => \%data_source_config); 227 $data_source_config->{$service}{$ds_name} ||= {}; 228 $data_source_config->{$service}{$ds_name}{$ds_var} = $ds_val; 229 DEBUG "[CONFIG dataseries $plugin] $service->$ds_name.$ds_var = $ds_val"; 230 push ( @graph_order, $ds_name ) if $ds_var eq 'label'; 231 } 232 elsif ($line =~ m{\A (\w+) \s+ (.+) }xms) { 233 push @{$global_config->{$service}}, [$1, $2]; 234 DEBUG "[CONFIG graph global $plugin] $service->$1 = $2"; 235 } 236 else { 237 die "[ERROR] Protocol exception: unrecognized line '$line' from $plugin on $nodedesignation.\n"; 238 } 239 } 240 241 $self->_validate_data_sources($data_source_config); 242 243 push_graphorder($service); 244 245 return (global => $global_config, data_source => $data_source_config); 200 246 } 201 247 … … 215 261 216 262 sub _validate_data_sources { 217 my ($self, $data_source_config) = @_; 218 219 for my $ds (keys %$data_source_config) { 220 croak "Missing required attribute 'label' for data source '$ds'" 221 unless defined $data_source_config->{$ds}{label}; 222 } 223 } 224 225 226 sub fetch_service_data { 227 my ($self, $service) = @_; 228 229 $self->_node_write_single("fetch $service\n"); 230 my @lines = $self->_node_read(); 231 232 my %values = (); 263 my ($self, $all_data_source_config) = @_; 264 265 for my $service (keys %$all_data_source_config) { 266 my $data_source_config = $all_data_source_config->{$service}; 267 268 for my $ds (keys %$data_source_config) { 269 croak "Missing required attribute 'label' for data source '$ds'" 270 unless defined $data_source_config->{$ds}{label}; 271 } 272 } 273 } 274 275 276 sub parse_service_data { 277 my ($self, $service, @lines) = @_; 278 279 my $plugin = $service; 280 281 my $nodedesignation = $self->{host}."/".$self->{address}.":".$self->{port}; 282 283 my %values = ( 284 $service => {}, 285 ); 286 287 DEBUG "[DEBUG] Now parsing fetch output from plugin $plugin on ". 288 $nodedesignation; 233 289 234 290 for my $line (@lines) { 235 croak "Client reported timeout in configuration of '$service'" 236 if $line =~ /\# timeout/; 291 292 DEBUG "[FETCH from $plugin] $line"; 293 294 if ($line =~ /\# timeout/) { 295 WARN "[WARNING] Timeout in fetch from '$plugin' on ". 296 $nodedesignation; 297 croak("Timeout error. Please consult the log."); 298 } 299 237 300 next unless $line; 238 301 next if $line =~ /^\#/; 239 302 240 if ($line =~ m{ (\w+)\.value \s+ ([\S:]+) }xms) { 303 if ($line =~ m{\A multigraph \s+ (.+) }xms) { 304 $service = $1; 305 $values{$service} = {}; 306 307 if ($service eq 'multigraph') { 308 ERROR "[ERROR] SERVICE can't be named \"$service\" in plugin $plugin on ". 309 $nodedesignation; 310 croak("Plugin error. Please consult the log."); 311 } 312 } 313 elsif ($line =~ m{ (\w+)\.value \s+ ([\S:]+) }xms) { 241 314 my ($data_source, $value, $when) = ($1, $2, 'N'); 242 315 … … 248 321 } 249 322 250 $values{$data_source} = { value => $value, when => $when }; 323 $values{$service}{$data_source} = 324 { value => $value, when => $when }; 251 325 } 252 326 else { 253 croak "Protocol exception: while fetching '$service': unrecogniced line '$line'";327 die "[ERROR] Protocol exception while fetching '$service' from $nodedesignation: unrecogniced line '$line'" 254 328 } 255 329 } 256 330 257 331 return %values; 332 } 333 334 335 sub fetch_service_data { 336 my ($self, $plugin) = @_; 337 338 $self->_node_write_single("fetch $plugin\n"); 339 my @lines = $self->_node_read(); 340 341 return $self->parse_service_data($plugin,@lines); 258 342 } 259 343 … … 276 360 my ($self, $text) = @_; 277 361 278 logger("[DEBUG] Writing to socket: \"$text\".") if $config->{debug};362 DEBUG "[DEBUG] Writing to socket: \"$text\"."; 279 363 my $timed_out = !do_with_timeout($self->{io_timeout}, sub { 280 364 if ($self->{tls} && $self->{tls}->session_started()) { … … 287 371 }); 288 372 if ($timed_out) { 289 logger("[WARNING] Socket write timed out\n");373 WARN "[WARNING] Socket write timed out to ".$self->{host}."\n"; 290 374 return; 291 375 } … … 308 392 }); 309 393 if ($timed_out) { 310 logger("[WARNING] Socket read timed out\n");394 WARN "[WARNING] Socket read timed out to ".$self->{host}."\n"; 311 395 return; 312 396 } 313 logger("[DEBUG] Reading from socket: \"$res\".") if $config->{debug};397 DEBUG "[DEBUG] Reading from socket to ".$self->{host}.": \"$res\"."; 314 398 return $res; 315 399 } … … 332 416 }); 333 417 if ($timed_out) { 334 logger ("[WARNING] Socket read timed out: $@\n");418 WARN "[WARNING] Socket read timed out to ".$self->{host}.": $@\n"; 335 419 return; 336 420 } 337 logger ("[DEBUG] Reading from socket: \"".(join ("\\n",@array))."\".") if $config->{debug};421 DEBUG "[DEBUG] Reading from socket: \"".(join ("\\n",@array))."\"."; 338 422 return @array; 339 423 } trunk/master/lib/Munin/Master/Update.pm
r2704 r2726 259 259 print $io "version $Munin::Common::Defaults::MUNIN_VERSION\n"; 260 260 for my $host (keys %{$self->{service_configs}}) { 261 for my $service (keys %{$self->{service_configs}{$host} }) {262 for my $attr (@{$self->{service_configs}{$host}{ $service}{global}}) {261 for my $service (keys %{$self->{service_configs}{$host}{data_source}}) { 262 for my $attr (@{$self->{service_configs}{$host}{global}{$service}}) { 263 263 print $io "$host:$service.$attr->[0] $attr->[1]\n"; 264 264 } 265 for my $data_source (keys %{$self->{service_configs}{$host}{ $service}{data_source}}) {266 for my $attr (keys %{$self->{service_configs}{$host}{ $service}{data_source}{$data_source}}) {267 print $io "$host:$service.$data_source.$attr $self->{service_configs}{$host}{ $service}{data_source}{$data_source}{$attr}\n";265 for my $data_source (keys %{$self->{service_configs}{$host}{data_source}{$service}}) { 266 for my $attr (keys %{$self->{service_configs}{$host}{data_source}{$service}{$data_source}}) { 267 print $io "$host:$service.$data_source.$attr $self->{service_configs}{$host}{data_source}{$service}{$data_source}{$attr}\n"; 268 268 } 269 269 } trunk/master/lib/Munin/Master/UpdateWorker.pm
r2704 r2726 2 2 use base qw(Munin::Master::Worker); 3 3 4 # $Id$ 4 =comment 5 6 This file is part of Munin. 7 8 Copyright (C) 2002-2009 Jimmy Olsen, et al. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; version 2 dated June, 1991. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 23 24 $Id$ 25 26 =cut 5 27 6 28 use warnings; … … 9 31 use Carp; 10 32 use English qw(-no_match_vars); 33 use Log::Log4perl qw( :easy ); 34 11 35 use File::Basename; 12 36 use File::Path; 13 37 use File::Spec; 14 38 use Munin::Master::Config; 15 use Munin::Master::Logger;16 39 use Munin::Master::Node; 17 40 use Munin::Master::Utils; … … 40 63 my $update_time = Time::HiRes::time; 41 64 42 my $lock_file = sprintf '%s/munin-%s-%s.lock', 43 $config->{rundir}, 44 $self->{host}{group}{group_name}, 45 $self->{host}{host_name}; 46 47 munin_getlock($lock_file) 48 or croak "Could not get lock for '$self->{host}{host_name}'. Skipping node."; 49 50 my %all_service_configs = (); 65 my $host = $self->{host}{host_name}; 66 67 my $nodedesignation = $host."/". 68 $self->{host}{address}.":".$self->{host}{port}; 69 70 my $lock_file = sprintf ('%s/munin-%s-%s.lock', 71 $config->{rundir}, 72 $self->{host}{group}{group_name}, 73 $host); 74 75 if (!munin_getlock($lock_file)) { 76 WARN "Could not get lock $lock_file for $nodedesignation. Skipping node."; 77 die "Could not get lock $lock_file for $nodedesignation. Skipping node.\n"; 78 } 79 80 my %all_service_configs = ( 81 data_source => {}, 82 global => {}, 83 ); 51 84 52 85 $self->{node}->do_in_session(sub { 53 86 $self->{node}->negotiate_capabilities(); 54 87 # Note: A multigraph plugin can present multiple services. 55 my @plugins = $self->{node}->list_services(); 56 # my @services = 88 my @plugins = $self->{node}->list_plugins(); 57 89 58 90 for my $plugin (@plugins) { … … 63 95 my %service_config = $self->uw_fetch_service_config($plugin); 64 96 unless (%service_config) { 65 logger("[WARNING] Service $plugin returned no config");97 WARN "[WARNING] Service $plugin on $nodedesignation returned no config"; 66 98 next; 67 99 } 68 69 $self->_compare_and_act_on_config_changes($plugin,70 \%service_config);71 100 72 101 my %service_data = eval { … … 74 103 }; 75 104 if ($EVAL_ERROR) { 76 logger($EVAL_ERROR); 105 ERROR $EVAL_ERROR; 106 warn "$EVAL_ERROR\n"; 77 107 next; 78 108 } 79 109 80 $self->_update_rrd_files($plugin, \%service_config, \%service_data); 81 $all_service_configs{$plugin} = \%service_config; 110 # Since different plugins can populate multiple positions in the 111 # service namespace we'll check for collisions and warn of them. 112 113 for my $service (keys %{$service_config{data_source}}) { 114 if (defined($all_service_configs{data_source}{$service})) { 115 WARN "[WARNING] Service colision: plugin $plugin on $nodedesignation reports $service which already exists on that host. Deleting new data."; 116 delete($service_config{data_source}{$service}); 117 delete($service_data{$service}) 118 if defined $service_data{$service}; 119 } 120 } 121 122 $self->_compare_and_act_on_config_changes(\%service_config); 123 124 %{$all_service_configs{data_source}} = ( 125 %{$all_service_configs{data_source}}, 126 %{$service_config{data_source}}); 127 128 %{$all_service_configs{global}} = ( 129 %{$all_service_configs{global}}, 130 %{$service_config{global}}); 131 132 $self->_update_rrd_files(\%service_config, \%service_data); 82 133 } 83 134 … … 96 147 sub uw_fetch_service_config { 97 148 # not sure why fetch_service_config needs eval and fetch_service_data 98 # does not. - janl 2009 .10.22149 # does not. - janl 2009-10-22 99 150 my ($self, $plugin) = @_; 100 151 … … 105 156 # FIX Report failed service so that we can use the old service 106 157 # config. 107 logger($EVAL_ERROR); 158 ERROR $EVAL_ERROR; 159 warn "$EVAL_ERROR\n"; 108 160 return; 109 161 } 110 162 163 # FIX for nested services 111 164 if ($self->{host}{service_config} && $self->{host}{service_config}{$plugin}) { 112 165 %service_config … … 119 172 120 173 sub _compare_and_act_on_config_changes { 121 my ($self, $ service, $service_config) = @_;174 my ($self, $nested_service_config) = @_; 122 175 123 176 # Kjellm: Why do we need to tune RRD files after upgrade? 124 177 # Shouldn't we create a upgrade script or something instead? 125 178 # 126 # janl: Not sure? Code duplication? Ease of use? Lazyness? 179 # janl: Upgrade script sucks. This way it's inline in munin and 180 # no need to remember anything or anything. 127 181 128 182 my $just_upgraded = 0; … … 136 190 } 137 191 138 for my $data_source (keys %{$service_config->{data_source}}) { 139 my $old_data_source = $data_source; 140 my $ds_config = $service_config->{data_source}{$data_source}; 141 $self->_set_rrd_data_source_defaults($ds_config); 142 143 my $group = $self->{host}{group}{group_name}; 144 my $host = $self->{host}{host_name}; 145 146 my $old_host_config = 147 $old_config->{groups}{$group}{hosts}{$host}; 148 my $old_ds_config = 149 $old_host_config->get_canned_ds_config($service, 150 $data_source); 151 152 if (not %$old_ds_config 153 and defined($ds_config->{oldname}) 154 and $ds_config->{oldname}) { 155 156 $old_data_source = $ds_config->{oldname}; 157 $old_ds_config = 158 $old_host_config->get_canned_ds_config($service, 159 $old_data_source); 160 } 161 162 if (%$old_ds_config 163 and not $self->_ds_config_eq($old_ds_config, $ds_config)) { 164 $self->_ensure_filename($service, 165 $old_data_source, $data_source, 166 $old_ds_config, $ds_config) 167 and $self->_ensure_tuning($service, $data_source, 168 $ds_config); 169 } elsif ($just_upgraded) { 170 $self->_ensure_tuning($service, $data_source, 171 $ds_config); 172 } 192 for my $service (keys %{$nested_service_config->{data_source}}) { 193 194 my $service_config = $nested_service_config->{data_source}{$service}; 195 196 for my $data_source (keys %{$service_config}) { 197 my $old_data_source = $data_source; 198 my $ds_config = $service_config->{$data_source}; 199 $self->_set_rrd_data_source_defaults($ds_config); 200 201 my $group = $self->{host}{group}{group_name}; 202 my $host = $self->{host}{host_name}; 203 204 my $old_host_config = $old_config->{groups}{$group}{hosts}{$host}; 205 my $old_ds_config = undef; 206 207 if ($old_host_config) { 208 $old_ds_config = 209 $old_host_config->get_canned_ds_config($service, 210 $data_source); 211 } 212 213 if (defined($old_ds_config) 214 and %$old_ds_config 215 and defined($ds_config->{oldname}) 216 and $ds_config->{oldname}) { 217 218 $old_data_source = $ds_config->{oldname}; 219 $old_ds_config = 220 $old_host_config->get_canned_ds_config($service, 221 $old_data_source); 222 } 223 224 if (defined($old_ds_config) 225 and %$old_ds_config 226 and not $self->_ds_config_eq($old_ds_config, $ds_config)) { 227 $self->_ensure_filename($service, 228 $old_data_source, $data_source, 229 $old_ds_config, $ds_config) 230 and $self->_ensure_tuning($service, $data_source, 231 $ds_config); 232 # _ensure_filename prints helpfull warnings in the log 233 } elsif ($just_upgraded) { 234 $self->_ensure_tuning($service, $data_source, 235 $ds_config); 236 } 237 } 173 238 } 174 239 } … … 215 280 $old_ds_config); 216 281 282 my $hostspec = $self->{node}{hostname}.'/'.$self->{node}{address}.':'. 283 $self->{node}{port}; 284 217 285 if ($rrd_file ne $old_rrd_file) { 218 286 if (-f $old_rrd_file and -f $rrd_file) { 219 287 my $host = $self->{host}{host_name}; 220 logger("[WARNING]: $host $service $data_source config change"221 . " suggests moving '$old_rrd_file' to '$rrd_file' but"222 . " both exist; manually merge the data or remove"223 . " whichever file you care less about.\n");224 return '';288 WARN "[WARNING]: $hostspec $service $data_source config change " 289 . "suggests moving '$old_rrd_file' to '$rrd_file' " 290 . "but both exist; manually merge the data " 291 . "or remove whichever file you care less about.\n"; 292 return ''; 225 293 } elsif (-f $old_rrd_file) { 226 logger("[INFO]: Config update, changing name of '$old_rrd_file'"227 . " to '$rrd_file' ");294 INFO "[INFO]: Config update, changing name of '$old_rrd_file'" 295 . " to '$rrd_file' on $hostspec "; 228 296 unless (rename ($old_rrd_file, $rrd_file)) { 229 logger ("[ERROR]: Could not rename '$old_rrd_file' to"230 . " '$rrd_file': $!\n");297 ERROR "[ERROR]: Could not rename '$old_rrd_file' to" 298 . " '$rrd_file' for $hostspec: $!\n"; 231 299 return ''; 232 300 } … … 251 319 252 320 for my $rrd_prop (qw(type max min)) { 253 logger("[INFO]: Config update, ensuring $rrd_prop of"254 . " '$rrd_file' is '$ds_config->{$rrd_prop}'.\n");321 INFO "[INFO]: Config update, ensuring $rrd_prop of" 322 . " '$rrd_file' is '$ds_config->{$rrd_prop}'.\n"; 255 323 RRDs::tune($rrd_file, $tune_flags{$rrd_prop}, 256 324 "42:$ds_config->{$rrd_prop}"); 257 325 if (my $tune_error = RRDs::error()) { 258 logger("[ERROR] Tuning $rrd_prop of '$rrd_file' to"259 . " '$ds_config->{$rrd_prop}' failed.\n");326 ERROR "[ERROR] Tuning $rrd_prop of '$rrd_file' to" 327 . " '$ds_config->{$rrd_prop}' failed.\n"; 260 328 $success = ''; 261 329 } … … 267 335 268 336 sub _update_rrd_files { 269 my ($self, $service, $service_config, $service_data) = @_; 270 271 for my $ds_name (keys %{$service_config->{data_source}}) { 272 $self->_set_rrd_data_source_defaults($service_config->{data_source}{$ds_name}); 273 274 unless ($service_config->{data_source}{$ds_name}{label}) { 275 logger("[ERROR] Unable to update $service -> $ds_name: Missing data source configuration attribute: label"); 276 next; 277 } 278 279 my $rrd_file 280 = $self->_create_rrd_file_if_needed($service, $ds_name, 281 $service_config->{data_source}{$ds_name}); 282 283 if (%$service_data and defined($service_data->{$ds_name})) { 284 $self->_update_rrd_file($rrd_file, $ds_name, $service_data->{$ds_name}); 285 } 286 else { 287 logger("[WARNING] Service $service returned no data"); 288 } 337 my ($self, $nested_service_config, $nested_service_data) = @_; 338 339 my $nodedesignation = $self->{host}{host_name}."/". 340 $self->{host}{address}.":".$self->{host}{port}; 341 342 for my $service (keys %{$nested_service_config->{data_source}}) { 343 344 my $service_config = $nested_service_config->{data_source}{$service}; 345 my $service_data = $nested_service_data->{$service}; 346 347 for my $ds_name (keys %{$service_config}) { 348 $self->_set_rrd_data_source_defaults($service_config->{$ds_name}); 349 350 unless ($service_config->{$ds_name}{label}) { 351 ERROR "[ERROR] Unable to update $service on $nodedesignation -> $ds_name: Missing data source configuration attribute: label"; 352 next; 353 } 354 355 my $rrd_file 356 = $self->_create_rrd_file_if_needed($service, $ds_name, 357 $service_config->{$ds_name}); 358 359 if (%$service_data and defined($service_data->{$ds_name})) { 360 $self->_update_rrd_file($rrd_file, $ds_name, $service_data->{$ds_name}); 361 } 362 else { 363 WARN "[WARNING] Service $service on $nodedesignation returned no data"; 364 } 365 } 289 366 } 290 367 } … … 334 411 } ($group, $file); 335 412 336 logger("[DEBUG] Made rrd filename: $group / $file\n") if $config->{debug};413 DEBUG "[DEBUG] Made rrd filename: $group / $file\n"; 337 414 338 415 return File::Spec->catfile($config->{dbdir}, … … 345 422 my ($self, $rrd_file, $service, $ds_name, $ds_config) = @_; 346 423 347 logger("creating rrd-file for $service->$ds_name: '$rrd_file'");424 INFO "[INFO] creating rrd-file for $service->$ds_name: '$rrd_file'"; 348 425 mkpath(dirname($rrd_file), {mode => oct(777)}); 349 426 my @args = ( … … 377 454 RRDs::create @args; 378 455 if (my $ERROR = RRDs::error) { 379 logger("[ERROR] Unable to create '$rrd_file': $ERROR");456 ERROR "[ERROR] Unable to create '$rrd_file': $ERROR"; 380 457 } 381 458 } … … 403 480 } 404 481 405 logger("[DEBUG] Updating $rrd_file with $value") if $config->{debug};482 DEBUG "[DEBUG] Updating $rrd_file with ".$ds_values->{when}.":$value"; 406 483 RRDs::update($rrd_file, "$ds_values->{when}:$value"); 407 484 if (my $ERROR = RRDs::error) { 408 logger ("[ERROR] In RRD: unable to update $rrd_file: $ERROR");485 ERROR "[ERROR] In RRD: Error updating $rrd_file: $ERROR"; 409 486 } 410 487 } trunk/master/t/munin_master_plugin_fetch.t
r2676 r2726 23 23 24 24 # print Dumper \%answer; 25 26 =comment 27 28 Keep old correct answer for reference. 25 29 26 30 my $fasit = { … … 55 59 }; 56 60 61 =cut 62 63 my $fasit = { 64 'cpu' => { 65 'irq' => { 66 'when' => '1256305015', 67 'value' => '2770' 68 }, 69 'system' => { 70 'when' => 'N', 71 'value' => '66594' 72 }, 73 'softirq' => { 74 'when' => '1256305015', 75 'value' => '127' 76 }, 77 'user' => { 78 'when' => 'N', 79 'value' => '145923' 80 }, 81 'iowait' => { 82 'when' => 'N', 83 'value' => '14375' 84 }, 85 'idle' => { 86 'when' => 'N', 87 'value' => '2245122' 88 }, 89 'nice' => { 90 'when' => 'N', 91 'value' => '268' 92 } 93 } 94 }; 95 57 96 is_deeply(\%answer,$fasit,"Plugin fetch output"); 58 97
