diff --git a/source/code/plugin/filter_health_model_builder.rb b/source/code/plugin/filter_health_model_builder.rb index 5aa7f610e..fa92038e6 100644 --- a/source/code/plugin/filter_health_model_builder.rb +++ b/source/code/plugin/filter_health_model_builder.rb @@ -184,7 +184,8 @@ def filter_stream(tag, es) all_monitors.each{|monitor_instance_id, monitor| if monitor.is_aggregate_monitor @state.update_state(monitor, - @provider.get_config(monitor.monitor_id) + @provider.get_config(monitor.monitor_id), + true ) end diff --git a/source/code/plugin/health/health_monitor_state.rb b/source/code/plugin/health/health_monitor_state.rb index 498c75ec7..7eb674f1e 100644 --- a/source/code/plugin/health/health_monitor_state.rb +++ b/source/code/plugin/health/health_monitor_state.rb @@ -57,10 +57,11 @@ def initialize_state(deserialized_state) 2. if there is a "consistent" state change for monitors 3. if the signal is stale (> 4hrs) 4. If the latest state is none +5. If an aggregate monitor has a change in its details, but no change in state =end def update_state(monitor, #UnitMonitor/AggregateMonitor - monitor_config #Hash - ) + monitor_config, #Hash + is_aggregate_monitor = false) samples_to_keep = 1 monitor_instance_id = monitor.monitor_instance_id log = HealthMonitorHelpers.get_log_handle @@ -76,12 +77,13 @@ def update_state(monitor, #UnitMonitor/AggregateMonitor samples_to_keep = monitor_config['ConsecutiveSamplesForStateTransition'].to_i end + deleted_record = {} if @@monitor_states.key?(monitor_instance_id) health_monitor_instance_state = @@monitor_states[monitor_instance_id] health_monitor_records = health_monitor_instance_state.prev_records #This should be an array if health_monitor_records.size == samples_to_keep - health_monitor_records.delete_at(0) + deleted_record = health_monitor_records.delete_at(0) end health_monitor_records.push(monitor.details) health_monitor_instance_state.prev_records = health_monitor_records @@ -106,7 +108,6 @@ def update_state(monitor, #UnitMonitor/AggregateMonitor @@monitor_states[monitor_instance_id] = health_monitor_instance_state end - # update old and new state based on the history and latest record. # TODO: this is a little hairy. Simplify @@ -142,6 +143,10 @@ def update_state(monitor, #UnitMonitor/AggregateMonitor @@first_record_sent[monitor_instance_id] = true health_monitor_instance_state.should_send = true set_state(monitor_instance_id, health_monitor_instance_state) + elsif agg_monitor_details_changed?(is_aggregate_monitor, deleted_record, health_monitor_instance_state.prev_records[0]) + health_monitor_instance_state.should_send = true + set_state(monitor_instance_id, health_monitor_instance_state) + log.debug "#{monitor_instance_id} condition: agg monitor details changed should_send #{health_monitor_instance_state.should_send}" end # latest state is different that last sent state else @@ -212,5 +217,17 @@ def is_state_change_consistent(health_monitor_records, samples_to_check) end return true end + + def agg_monitor_details_changed?(is_aggregate_monitor, last_sent_details, latest_details) + log = HealthMonitorHelpers.get_log_handle + if !is_aggregate_monitor + return false + end + if latest_details['details'] != last_sent_details['details'] + log.info "Last Sent Details #{JSON.pretty_generate(last_sent_details)} \n Latest Details: #{JSON.pretty_generate(latest_details)}" + return true + end + return false + end end end \ No newline at end of file