icingadb-web/library/Icingadb/Model/HostState.php

91 lines
3.5 KiB
PHP
Raw Permalink Normal View History

2019-09-09 07:17:28 -04:00
<?php
2020-03-13 03:38:01 -04:00
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
2019-11-04 19:07:30 -05:00
namespace Icinga\Module\Icingadb\Model;
2019-09-09 07:17:28 -04:00
2024-12-17 08:57:00 -05:00
use Icinga\Module\Icingadb\Common\Backend;
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Common\HostStates;
2019-09-09 07:17:28 -04:00
use ipl\Orm\Relations;
/**
* Host state model.
*/
class HostState extends State
{
public function getTableName()
{
return 'host_state';
}
public function getKeyName()
{
return 'host_id';
}
public function getColumnDefinitions()
{
2024-12-17 08:57:00 -05:00
$columns = [
2022-07-11 11:31:53 -04:00
'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'),
2022-07-11 11:31:53 -04:00
'check_attempt' => t('Host Check Attempt No.'),
'severity' => t('Host State Severity'),
2022-07-11 11:31:53 -04:00
'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'),
'scheduling_source' => t('Host Scheduling Source'),
2022-07-11 11:31:53 -04:00
'last_update' => t('Host Last Update'),
'last_state_change' => t('Host Last State Change'),
'next_check' => t('Host Next Check'),
2024-12-17 08:57:00 -05:00
'next_update' => t('Host Next Update')
];
2024-12-17 08:57:00 -05:00
if (Backend::supportsDependencies()) {
2024-12-17 08:57:00 -05:00
$columns['affects_children'] = t('Host Affects Children');
$columns['is_sticky_acknowledgement'] = t('Acknowledgement Is Sticky');
2024-12-17 08:57:00 -05:00
}
return $columns;
}
2019-09-09 07:17:28 -04:00
public function createRelations(Relations $relations)
{
2019-09-23 09:31:18 -04:00
$relations->belongsTo('environment', Environment::class);
2019-09-09 07:17:28 -04:00
$relations->belongsTo('host', Host::class);
$relations->hasOne('last_comment', LastHostComment::class)
2021-08-12 05:45:35 -04:00
->setCandidateKey('last_comment_id')
->setForeignKey('id')
->setJoinType('LEFT');
2019-09-09 07:17:28 -04:00
}
2023-08-21 08:13:32 -04:00
public function getStateText(): string
2019-09-09 07:17:28 -04:00
{
return HostStates::text($this->soft_state);
2019-09-09 07:17:28 -04:00
}
2023-08-21 08:13:32 -04:00
public function getStateTextTranslated(): string
2019-09-09 07:17:28 -04:00
{
return HostStates::translated($this->soft_state);
2019-09-09 07:17:28 -04:00
}
}