| 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); |
|---|
| | 211 | } |
|---|
| | 212 | |
|---|
| | 213 | sub 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; |
|---|