diff --git a/pkg/icingadb/v1/history/state.go b/pkg/icingadb/v1/history/state.go index 8a913812..dec13b04 100644 --- a/pkg/icingadb/v1/history/state.go +++ b/pkg/icingadb/v1/history/state.go @@ -14,7 +14,7 @@ type StateHistory struct { HardState uint8 `json:"hard_state"` PreviousSoftState uint8 `json:"previous_soft_state"` PreviousHardState uint8 `json:"previous_hard_state"` - Attempt uint8 `json:"attempt"` + CheckAttempt uint8 `json:"check_attempt"` Output types.String `json:"output"` LongOutput types.String `json:"long_output"` MaxCheckAttempts uint32 `json:"max_check_attempts"` diff --git a/pkg/icingadb/v1/state.go b/pkg/icingadb/v1/state.go index 60a623d1..e5edede2 100644 --- a/pkg/icingadb/v1/state.go +++ b/pkg/icingadb/v1/state.go @@ -9,14 +9,14 @@ type State struct { EnvironmentMeta `json:",inline"` AcknowledgementCommentId types.Binary `json:"acknowledgement_comment_id"` LastCommentId types.Binary `json:"last_comment_id"` - Attempt uint8 `json:"check_attempt"` - CheckCommandline types.String `json:"commandline"` + CheckAttempt uint8 `json:"check_attempt"` + CheckCommandline types.String `json:"check_commandline"` CheckSource types.String `json:"check_source"` SchedulingSource types.String `json:"scheduling_source"` ExecutionTime float64 `json:"execution_time"` HardState uint8 `json:"hard_state"` InDowntime types.Bool `json:"in_downtime"` - IsAcknowledged types.AcknowledgementState `json:"acknowledgement"` + IsAcknowledged types.AcknowledgementState `json:"is_acknowledged"` IsFlapping types.Bool `json:"is_flapping"` IsHandled types.Bool `json:"is_handled"` IsProblem types.Bool `json:"is_problem"` @@ -35,5 +35,5 @@ type State struct { Severity uint16 `json:"severity"` SoftState uint8 `json:"state"` StateType types.StateType `json:"state_type"` - Timeout float64 `json:"check_timeout"` + CheckTimeout float64 `json:"check_timeout"` } diff --git a/schema/mysql/schema.sql b/schema/mysql/schema.sql index 1abd1a44..b0e59e73 100644 --- a/schema/mysql/schema.sql +++ b/schema/mysql/schema.sql @@ -290,7 +290,7 @@ CREATE TABLE host_state ( hard_state tinyint unsigned NOT NULL, previous_soft_state tinyint unsigned NOT NULL, previous_hard_state tinyint unsigned NOT NULL, - attempt tinyint unsigned NOT NULL, + check_attempt tinyint unsigned NOT NULL, severity smallint unsigned NOT NULL, output longtext DEFAULT NULL, @@ -313,7 +313,7 @@ CREATE TABLE host_state ( execution_time int unsigned DEFAULT NULL, latency int unsigned DEFAULT NULL, - timeout int unsigned DEFAULT NULL, + check_timeout int unsigned DEFAULT NULL, check_source text DEFAULT NULL, scheduling_source text DEFAULT NULL, @@ -456,7 +456,7 @@ CREATE TABLE service_state ( hard_state tinyint unsigned NOT NULL, previous_soft_state tinyint unsigned NOT NULL, previous_hard_state tinyint unsigned NOT NULL, - attempt tinyint unsigned NOT NULL, + check_attempt tinyint unsigned NOT NULL, severity smallint unsigned NOT NULL, output longtext DEFAULT NULL, @@ -480,7 +480,7 @@ CREATE TABLE service_state ( execution_time int unsigned DEFAULT NULL, latency int unsigned DEFAULT NULL, - timeout int unsigned DEFAULT NULL, + check_timeout int unsigned DEFAULT NULL, check_source text DEFAULT NULL, scheduling_source text DEFAULT NULL, @@ -1141,7 +1141,7 @@ CREATE TABLE state_history ( hard_state tinyint unsigned NOT NULL, previous_soft_state tinyint unsigned NOT NULL, previous_hard_state tinyint unsigned NOT NULL, - attempt tinyint unsigned NOT NULL, + check_attempt tinyint unsigned NOT NULL, output longtext DEFAULT NULL, long_output longtext DEFAULT NULL, max_check_attempts int unsigned NOT NULL, diff --git a/schema/mysql/upgrades/1.0.0.sql b/schema/mysql/upgrades/1.0.0.sql index 089bf4e3..23c602c4 100644 --- a/schema/mysql/upgrades/1.0.0.sql +++ b/schema/mysql/upgrades/1.0.0.sql @@ -164,10 +164,14 @@ ALTER TABLE notification_history MODIFY `text` longtext NOT NULL; ALTER TABLE host_state - ADD COLUMN previous_soft_state tinyint unsigned NOT NULL AFTER hard_state; + ADD COLUMN previous_soft_state tinyint unsigned NOT NULL AFTER hard_state, + CHANGE attempt check_attempt tinyint unsigned NOT NULL, + CHANGE timeout check_timeout int unsigned DEFAULT NULL; ALTER TABLE service_state - ADD COLUMN previous_soft_state tinyint unsigned NOT NULL AFTER hard_state; + ADD COLUMN previous_soft_state tinyint unsigned NOT NULL AFTER hard_state, + CHANGE attempt check_attempt tinyint unsigned NOT NULL, + CHANGE timeout check_timeout int unsigned DEFAULT NULL; ALTER TABLE checkcommand_argument ADD COLUMN `separator` varchar(255) DEFAULT NULL AFTER set_if; @@ -191,7 +195,8 @@ ALTER TABLE flapping_history ADD index idx_flapping_history_end_time (end_time) COMMENT 'Filter for history retention'; ALTER TABLE state_history - ADD index idx_state_history_event_time (event_time) COMMENT 'Filter for history retention'; + ADD index idx_state_history_event_time (event_time) COMMENT 'Filter for history retention', + CHANGE attempt check_attempt tinyint unsigned NOT NULL; ALTER TABLE icon_image DROP PRIMARY KEY, diff --git a/schema/pgsql/schema.sql b/schema/pgsql/schema.sql index fbdadb84..78a16b99 100644 --- a/schema/pgsql/schema.sql +++ b/schema/pgsql/schema.sql @@ -392,7 +392,7 @@ CREATE TABLE host_state ( hard_state tinyuint NOT NULL, previous_soft_state tinyuint NOT NULL, previous_hard_state tinyuint NOT NULL, - attempt tinyuint NOT NULL, + check_attempt tinyuint NOT NULL, severity smalluint NOT NULL, output text DEFAULT NULL, @@ -416,7 +416,7 @@ CREATE TABLE host_state ( execution_time uint DEFAULT NULL, latency uint DEFAULT NULL, - timeout uint DEFAULT NULL, + check_timeout uint DEFAULT NULL, check_source text DEFAULT NULL, scheduling_source text DEFAULT NULL, @@ -658,7 +658,7 @@ CREATE TABLE service_state ( hard_state tinyuint NOT NULL, previous_soft_state tinyuint NOT NULL, previous_hard_state tinyuint NOT NULL, - attempt tinyuint NOT NULL, + check_attempt tinyuint NOT NULL, severity smalluint NOT NULL, output text DEFAULT NULL, @@ -682,7 +682,7 @@ CREATE TABLE service_state ( execution_time uint DEFAULT NULL, latency uint DEFAULT NULL, - timeout uint DEFAULT NULL, + check_timeout uint DEFAULT NULL, check_source text DEFAULT NULL, scheduling_source text DEFAULT NULL, @@ -1823,7 +1823,7 @@ CREATE TABLE state_history ( hard_state tinyuint NOT NULL, previous_soft_state tinyuint NOT NULL, previous_hard_state tinyuint NOT NULL, - attempt tinyuint NOT NULL, + check_attempt tinyuint NOT NULL, output text DEFAULT NULL, long_output text DEFAULT NULL, max_check_attempts uint NOT NULL, diff --git a/tests/sql/sla_test.go b/tests/sql/sla_test.go index b87a32d6..8a898504 100644 --- a/tests/sql/sla_test.go +++ b/tests/sql/sla_test.go @@ -342,14 +342,14 @@ func (c *CurrentState) WriteSlaEventToDatabase(db *sqlx.DB, m *SlaHistoryMeta) e if len(m.ServiceId) == 0 { _, err := db.NamedExec("INSERT INTO host_state"+ " (id, host_id, environment_id, properties_checksum, soft_state, previous_soft_state,"+ - " hard_state, previous_hard_state, attempt, severity, last_state_change, next_check, next_update)"+ + " hard_state, previous_hard_state, check_attempt, severity, last_state_change, next_check, next_update)"+ " VALUES (:host_id, :host_id, :environment_id, :properties_checksum, :state, :state, :state, :state, 0, 0, 0, 0, 0)", &v) return err } else { _, err := db.NamedExec("INSERT INTO service_state"+ " (id, host_id, service_id, environment_id, properties_checksum, soft_state, previous_soft_state,"+ - " hard_state, previous_hard_state, attempt, severity, last_state_change, next_check, next_update)"+ + " hard_state, previous_hard_state, check_attempt, severity, last_state_change, next_check, next_update)"+ " VALUES (:service_id, :host_id, :service_id, :environment_id, :properties_checksum, :state, :state, :state, :state, 0, 0, 0, 0, 0)", &v) return err