From 6baca553effcc43c544cc0c0bd69e8ec14bfc07a Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Tue, 10 Mar 2020 14:45:22 +0100 Subject: [PATCH] Flapping History: Add percent_state_change_start/end --- configobject/history/history.go | 10 ++++++---- etc/schema/mysql/mysql.schema.sql | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/configobject/history/history.go b/configobject/history/history.go index b59d054a..3926c04e 100644 --- a/configobject/history/history.go +++ b/configobject/history/history.go @@ -392,12 +392,13 @@ func commentHistoryWorker(super *supervisor.Supervisor) { func flappingHistoryWorker(super *supervisor.Supervisor) { statements := []string{ `INSERT INTO flapping_history (id, environment_id, endpoint_id, object_type, host_id, service_id, start_time, end_time, ` + - `percent_state_change, flapping_threshold_low, flapping_threshold_high)` + - `VALUES (?,?,?,?,?,?,?,?,?,?,?)` + + `percent_state_change_start, percent_state_change_end, flapping_threshold_low, flapping_threshold_high)` + + `VALUES (?,?,?,?,?,?,?,?,?,?,?,?)` + `ON DUPLICATE KEY UPDATE ` + `start_time=IFNULL(NULLIF(start_time, 0), VALUES(start_time)),` + `end_time=IFNULL(NULLIF(end_time, 0), VALUES(end_time)),` + - `percent_state_change=IFNULL(NULLIF(percent_state_change, 0), VALUES(percent_state_change)),` + + `percent_state_change_start=IFNULL(NULLIF(percent_state_change_start, 0), VALUES(percent_state_change_start)),` + + `percent_state_change_end=IFNULL(NULLIF(percent_state_change_end, 0), VALUES(percent_state_change_end)),` + `flapping_threshold_low=IFNULL(NULLIF(flapping_threshold_low, 0), VALUES(flapping_threshold_low)),` + `flapping_threshold_high=IFNULL(NULLIF(flapping_threshold_high, 0), VALUES(flapping_threshold_high))`, `REPLACE INTO history (id, environment_id, endpoint_id, object_type, host_id, service_id, notification_history_id,` + @@ -416,7 +417,8 @@ func flappingHistoryWorker(super *supervisor.Supervisor) { utils.DecodeHexIfNotNil(values["service_id"]), values["start_time"], values["end_time"], - values["percent_state_change"], + values["percent_state_change_start"], + values["percent_state_change_end"], values["flapping_threshold_low"], values["flapping_threshold_high"], } diff --git a/etc/schema/mysql/mysql.schema.sql b/etc/schema/mysql/mysql.schema.sql index 58d63f4f..b9e5d886 100644 --- a/etc/schema/mysql/mysql.schema.sql +++ b/etc/schema/mysql/mysql.schema.sql @@ -927,7 +927,8 @@ CREATE TABLE flapping_history ( start_time bigint(20) unsigned NOT NULL, end_time bigint(20) unsigned DEFAULT NULL, - percent_state_change float unsigned NOT NULL, + percent_state_change_start float unsigned DEFAULT NULL, + percent_state_change_end float unsigned DEFAULT NULL, flapping_threshold_low float unsigned NOT NULL, flapping_threshold_high float unsigned NOT NULL,