Skip to content

Commit

Permalink
schema: Define which state columns are nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Nov 20, 2024
1 parent 2642030 commit 1997f46
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 64 deletions.
63 changes: 31 additions & 32 deletions library/Icingadb/Model/HostState.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,37 @@ public function getKeyName()

public function getColumnDefinitions()
{
return [
'environment_id' => t('Environment Id'),
'state_type' => t('Host State Type'),
'soft_state' => t('Host Soft State'),
'hard_state' => t('Host Hard State'),
'previous_soft_state' => t('Host Previous Soft State'),
'previous_hard_state' => t('Host Previous Hard State'),
'check_attempt' => t('Host Check Attempt No.'),
'severity' => t('Host State Severity'),
'output' => t('Host Output'),
'long_output' => t('Host Long Output'),
'performance_data' => t('Host Performance Data'),
'normalized_performance_data' => t('Host Normalized Performance Data'),
'check_commandline' => t('Host Check Commandline'),
'is_problem' => t('Host Has Problem'),
'is_handled' => t('Host Is Handled'),
'is_reachable' => t('Host Is Reachable'),
'is_flapping' => t('Host Is Flapping'),
'is_overdue' => t('Host Check Is Overdue'),
'is_acknowledged' => t('Host Is Acknowledged'),
'acknowledgement_comment_id' => t('Acknowledgement Comment Id'),
'in_downtime' => t('Host In Downtime'),
'execution_time' => t('Host Check Execution Time'),
'latency' => t('Host Check Latency'),
'check_timeout' => t('Host Check Timeout'),
'check_source' => t('Host Check Source'),
'last_update' => t('Host Last Update'),
'last_state_change' => t('Host Last State Change'),
'next_check' => t('Host Next Check'),
'next_update' => t('Host Next Update'),
'affects_children' => t('Host Affects Children'),
];
return array_merge_recursive(parent::getColumnDefinitions(), [
'state_type' => ['label' => t('Host State Type')],
'soft_state' => ['label' => t('Host Soft State')],
'hard_state' => ['label' => t('Host Hard State')],
'previous_soft_state' => ['label' => t('Host Previous Soft State')],
'previous_hard_state' => ['label' => t('Host Previous Hard State')],
'check_attempt' => ['label' => t('Host Check Attempt No.')],
'severity' => ['label' => t('Host State Severity')],
'output' => ['label' => t('Host Output')],
'long_output' => ['label' => t('Host Long Output')],
'performance_data' => ['label' => t('Host Performance Data')],
'normalized_performance_data' => ['label' => t('Host Normalized Performance Data')],
'check_commandline' => ['label' => t('Host Check Commandline')],
'is_problem' => ['label' => t('Host Has Problem')],
'is_handled' => ['label' => t('Host Is Handled')],
'is_reachable' => ['label' => t('Host Is Reachable')],
'is_flapping' => ['label' => t('Host Is Flapping')],
'is_overdue' => ['label' => t('Host Check Is Overdue')],
'is_acknowledged' => ['label' => t('Host Is Acknowledged')],
'in_downtime' => ['label' => t('Host In Downtime')],
'execution_time' => ['label' => t('Host Check Execution Time')],
'latency' => ['label' => t('Host Check Latency')],
'check_timeout' => ['label' => t('Host Check Timeout')],
'check_source' => ['label' => t('Host Check Source')],
'scheduling_source' => ['label' => t('Host Scheduling Source')],
'last_update' => ['label' => t('Host Last Update')],
'last_state_change' => ['label' => t('Host Last State Change')],
'next_check' => ['label' => t('Host Next Check')],
'next_update' => ['label' => t('Host Next Update')],
'affects_children' => ['label' => t('Host Affects Children')],
]);
}

public function createRelations(Relations $relations)
Expand Down
63 changes: 31 additions & 32 deletions library/Icingadb/Model/ServiceState.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,37 @@ public function getKeyName()

public function getColumnDefinitions()
{
return [
'environment_id' => t('Environment Id'),
'state_type' => t('Service State Type'),
'soft_state' => t('Service Soft State'),
'hard_state' => t('Service Hard State'),
'previous_soft_state' => t('Service Previous Soft State'),
'previous_hard_state' => t('Service Previous Hard State'),
'check_attempt' => t('Service Check Attempt No.'),
'severity' => t('Service State Severity'),
'output' => t('Service Output'),
'long_output' => t('Service Long Output'),
'performance_data' => t('Service Performance Data'),
'normalized_performance_data' => t('Service Normalized Performance Data'),
'check_commandline' => t('Service Check Commandline'),
'is_problem' => t('Service Has Problem'),
'is_handled' => t('Service Is Handled'),
'is_reachable' => t('Service Is Reachable'),
'is_flapping' => t('Service Is Flapping'),
'is_overdue' => t('Service Check Is Overdue'),
'is_acknowledged' => t('Service Is Acknowledged'),
'acknowledgement_comment_id' => t('Acknowledgement Comment Id'),
'in_downtime' => t('Service In Downtime'),
'execution_time' => t('Service Check Execution Time'),
'latency' => t('Service Check Latency'),
'check_timeout' => t('Service Check Timeout'),
'check_source' => t('Service Check Source'),
'last_update' => t('Service Last Update'),
'last_state_change' => t('Service Last State Change'),
'next_check' => t('Service Next Check'),
'next_update' => t('Service Next Update'),
'affects_children' => t('Service Affects Children'),
];
return array_merge_recursive(parent::getColumnDefinitions(), [
'state_type' => ['label' => t('Service State Type')],
'soft_state' => ['label' => t('Service Soft State')],
'hard_state' => ['label' => t('Service Hard State')],
'previous_soft_state' => ['label' => t('Service Previous Soft State')],
'previous_hard_state' => ['label' => t('Service Previous Hard State')],
'check_attempt' => ['label' => t('Service Check Attempt No.')],
'severity' => ['label' => t('Service State Severity')],
'output' => ['label' => t('Service Output')],
'long_output' => ['label' => t('Service Long Output')],
'performance_data' => ['label' => t('Service Performance Data')],
'normalized_performance_data' => ['label' => t('Service Normalized Performance Data')],
'check_commandline' => ['label' => t('Service Check Commandline')],
'is_problem' => ['label' => t('Service Has Problem')],
'is_handled' => ['label' => t('Service Is Handled')],
'is_reachable' => ['label' => t('Service Is Reachable')],
'is_flapping' => ['label' => t('Service Is Flapping')],
'is_overdue' => ['label' => t('Service Check Is Overdue')],
'is_acknowledged' => ['label' => t('Service Is Acknowledged')],
'in_downtime' => ['label' => t('Service In Downtime')],
'execution_time' => ['label' => t('Service Check Execution Time')],
'latency' => ['label' => t('Service Check Latency')],
'check_timeout' => ['label' => t('Service Check Timeout')],
'check_source' => ['label' => t('Service Check Source')],
'scheduling_source' => ['label' => t('Service Scheduling Source')],
'last_update' => ['label' => t('Service Last Update')],
'last_state_change' => ['label' => t('Service Last State Change')],
'next_check' => ['label' => t('Service Next Check')],
'next_update' => ['label' => t('Service Next Update')],
'affects_children' => ['label' => t('Service Affects Children')],
]);
}

public function createRelations(Relations $relations)
Expand Down
47 changes: 47 additions & 0 deletions library/Icingadb/Model/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,53 @@ public function getColumns()
];
}

public function getColumnDefinitions()
{
return [
'environment_id' => [
'label' => t('Environment Id'),
'nullable' => false
],
'state_type' => ['nullable' => false],
'soft_state' => ['nullable' => false],
'hard_state' => ['nullable' => false],
'previous_soft_state' => ['nullable' => false],
'previous_hard_state' => ['nullable' => false],
'check_attempt' => ['nullable' => false],
'severity' => ['nullable' => false],
'output' => ['nullable' => true],
'long_output' => ['nullable' => true],
'performance_data' => ['nullable' => true],
'normalized_performance_data' => ['nullable' => true],
'check_commandline' => ['nullable' => true],
'is_problem' => ['nullable' => false],
'is_handled' => ['nullable' => false],
'is_reachable' => ['nullable' => false],
'is_flapping' => ['nullable' => false],
'is_overdue' => ['nullable' => false],
'is_acknowledged' => ['nullable' => false],
'acknowledgement_comment_id' => [
'label' => t('Acknowledgement Comment Id'),
'nullable' => true
],
'last_comment_id' => [
'label' => t('Last Comment Id'),
'nullable' => true
],
'in_downtime' => ['nullable' => false],
'affects_children' => ['nullable' => false],
'execution_time' => ['nullable' => true],
'latency' => ['nullable' => true],
'check_timeout' => ['nullable' => true],
'check_source' => ['nullable' => true],
'scheduling_source' => ['nullable' => true],
'last_update' => ['nullable' => true],
'last_state_change' => ['nullable' => false],
'next_check' => ['nullable' => false],
'next_update' => ['nullable' => false],
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new BoolCast([
Expand Down

0 comments on commit 1997f46

Please sign in to comment.