diff --git a/configobject/objecttypes/host/hoststate/hoststate.go b/configobject/objecttypes/host/hoststate/hoststate.go index 187a6338..4da59f81 100644 --- a/configobject/objecttypes/host/hoststate/hoststate.go +++ b/configobject/objecttypes/host/hoststate/hoststate.go @@ -14,6 +14,7 @@ var ( "state_type", "soft_state", "hard_state", + "previous_hard_state", "attempt", "severity", "output", @@ -46,6 +47,7 @@ type HostState struct { StateType float32 `json:"state_type"` SoftState float32 `json:"state"` HardState float32 `json:"NONE"` //TODO (NoH): I'm not sure where to get this from + PreviousHardState uint8 `json:"previous_hard_state"` Attempt float32 `json:"check_attempt"` Severity float32 `json:"severity"` Output string `json:"output"` @@ -92,6 +94,7 @@ func (h *HostState) UpdateValues() []interface{} { utils.IcingaStateTypeToString(h.StateType), h.SoftState, h.HardState, + h.PreviousHardState, h.Attempt, h.Severity, h.Output, diff --git a/configobject/objecttypes/service/servicestate/servicestate.go b/configobject/objecttypes/service/servicestate/servicestate.go index 718ec7b4..feb2fbcf 100644 --- a/configobject/objecttypes/service/servicestate/servicestate.go +++ b/configobject/objecttypes/service/servicestate/servicestate.go @@ -14,6 +14,7 @@ var ( "state_type", "soft_state", "hard_state", + "previous_hard_state", "attempt", "severity", "output", @@ -46,6 +47,7 @@ type ServiceState struct { StateType float32 `json:"state_type"` SoftState float32 `json:"state"` HardState float32 `json:"NONE"` //TODO (NoH): I'm not sure where to get this from + PreviousHardState uint8 `json:"previous_hard_state"` Attempt float32 `json:"check_attempt"` Severity float32 `json:"severity"` Output string `json:"output"` @@ -92,6 +94,7 @@ func (s *ServiceState) UpdateValues() []interface{} { utils.IcingaStateTypeToString(s.StateType), s.SoftState, s.HardState, + s.PreviousHardState, s.Attempt, s.Severity, s.Output, diff --git a/configobject/statesync/statesync.go b/configobject/statesync/statesync.go index 595bd958..bf1bf439 100644 --- a/configobject/statesync/statesync.go +++ b/configobject/statesync/statesync.go @@ -101,7 +101,7 @@ func syncStates(super *supervisor.Supervisor, objectType string) { _, errExec := super.Dbw.SqlExecTx( tx, mysqlObservers[objectType], - `REPLACE INTO `+objectType+`_state (`+objectType+`_id, environment_id, state_type, soft_state, hard_state, attempt, severity, output, long_output, performance_data,`+ + `REPLACE INTO `+objectType+`_state (`+objectType+`_id, environment_id, state_type, soft_state, hard_state, previous_hard_state, attempt, severity, output, long_output, performance_data,`+ `check_commandline, is_problem, is_handled, is_reachable, is_flapping, is_acknowledged, acknowledgement_comment_id,`+ `in_downtime, execution_time, latency, timeout, check_source, last_update, last_state_change, last_soft_state,`+ `last_hard_state, next_check, next_update) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, @@ -110,6 +110,7 @@ func syncStates(super *supervisor.Supervisor, objectType string) { redisStateTypeToDBStateType(values["state_type"]), values["state"], values["last_hard_state"], + values["previous_hard_state"], values["check_attempt"], redisIntToDBInt(values["severity"]), values["output"], diff --git a/etc/schema/mysql/host.sql b/etc/schema/mysql/host.sql index 03e29771..12c96b5b 100644 --- a/etc/schema/mysql/host.sql +++ b/etc/schema/mysql/host.sql @@ -114,6 +114,7 @@ CREATE TABLE host_state ( state_type enum('hard', 'soft') NOT NULL, soft_state tinyint(1) unsigned NOT NULL, hard_state tinyint(1) unsigned NOT NULL, + previous_hard_state tinyint(1) unsigned NOT NULL, attempt tinyint(1) unsigned NOT NULL, severity smallint unsigned NOT NULL, diff --git a/etc/schema/mysql/service.sql b/etc/schema/mysql/service.sql index 6a186a2b..f3736f37 100644 --- a/etc/schema/mysql/service.sql +++ b/etc/schema/mysql/service.sql @@ -107,6 +107,7 @@ CREATE TABLE service_state ( state_type enum('hard', 'soft') NOT NULL, soft_state tinyint(1) unsigned NOT NULL, hard_state tinyint(1) unsigned NOT NULL, + previous_hard_state tinyint(1) unsigned NOT NULL, attempt tinyint(1) unsigned NOT NULL, severity smallint unsigned NOT NULL,