2019-09-23 09:31:18 -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-23 09:31:18 -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\ServiceStates;
|
2019-09-23 09:31:18 -04:00
|
|
|
use ipl\Orm\Relations;
|
|
|
|
|
|
2024-03-14 06:52:09 -04:00
|
|
|
/**
|
|
|
|
|
* Service state model.
|
|
|
|
|
*
|
|
|
|
|
* @property string $service_id
|
|
|
|
|
*/
|
2019-09-23 09:31:18 -04:00
|
|
|
class ServiceState extends State
|
|
|
|
|
{
|
|
|
|
|
public function getTableName()
|
|
|
|
|
{
|
|
|
|
|
return 'service_state';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getKeyName()
|
|
|
|
|
{
|
|
|
|
|
return 'service_id';
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 09:34:01 -04:00
|
|
|
public function getColumnDefinitions()
|
2021-03-08 05:40:16 -05:00
|
|
|
{
|
2024-12-17 08:57:00 -05:00
|
|
|
$columns = [
|
2022-07-11 11:31:53 -04:00
|
|
|
'environment_id' => t('Environment Id'),
|
2021-03-08 05:40:16 -05:00
|
|
|
'state_type' => t('Service State Type'),
|
|
|
|
|
'soft_state' => t('Service Soft State'),
|
|
|
|
|
'hard_state' => t('Service Hard State'),
|
2022-02-24 11:27:25 -05:00
|
|
|
'previous_soft_state' => t('Service Previous Soft State'),
|
2021-03-08 05:40:16 -05:00
|
|
|
'previous_hard_state' => t('Service Previous Hard State'),
|
2022-07-11 11:31:53 -04:00
|
|
|
'check_attempt' => t('Service Check Attempt No.'),
|
2021-03-08 05:40:16 -05:00
|
|
|
'severity' => t('Service State Severity'),
|
2022-07-11 11:31:53 -04:00
|
|
|
'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'),
|
2025-03-28 04:10:45 -04:00
|
|
|
'scheduling_source' => t('Service Scheduling Source'),
|
2022-07-11 11:31:53 -04:00
|
|
|
'last_update' => t('Service Last Update'),
|
|
|
|
|
'last_state_change' => t('Service Last State Change'),
|
|
|
|
|
'next_check' => t('Service Next Check'),
|
2024-12-17 08:57:00 -05:00
|
|
|
'next_update' => t('Service Next Update')
|
2021-03-08 05:40:16 -05:00
|
|
|
];
|
2024-12-17 08:57:00 -05:00
|
|
|
|
2025-01-13 05:29:53 -05:00
|
|
|
if (Backend::supportsDependencies()) {
|
2024-12-17 08:57:00 -05:00
|
|
|
$columns['affects_children'] = t('Service Affects Children');
|
2025-06-03 05:58:19 -04:00
|
|
|
$columns['is_sticky_acknowledgement'] = t('Acknowledgement Is Sticky');
|
2024-12-17 08:57:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $columns;
|
2021-03-08 05:40:16 -05:00
|
|
|
}
|
|
|
|
|
|
2019-09-23 09:31:18 -04:00
|
|
|
public function createRelations(Relations $relations)
|
|
|
|
|
{
|
|
|
|
|
$relations->belongsTo('environment', Environment::class);
|
|
|
|
|
$relations->belongsTo('service', Service::class);
|
2023-09-01 08:48:47 -04:00
|
|
|
$relations->hasOne('last_comment', LastServiceComment::class)
|
2021-08-12 05:45:35 -04:00
|
|
|
->setCandidateKey('last_comment_id')
|
|
|
|
|
->setForeignKey('id')
|
|
|
|
|
->setJoinType('LEFT');
|
2019-09-23 09:31:18 -04:00
|
|
|
}
|
|
|
|
|
|
2021-09-22 04:21:15 -04:00
|
|
|
public function getStateText(): string
|
2019-09-23 09:31:18 -04:00
|
|
|
{
|
2021-09-23 11:24:59 -04:00
|
|
|
return ServiceStates::text($this->soft_state);
|
2019-09-23 09:31:18 -04:00
|
|
|
}
|
|
|
|
|
|
2021-09-22 04:21:15 -04:00
|
|
|
public function getStateTextTranslated(): string
|
2019-09-23 09:31:18 -04:00
|
|
|
{
|
2021-09-23 11:24:59 -04:00
|
|
|
return ServiceStates::text($this->soft_state);
|
2019-09-23 09:31:18 -04:00
|
|
|
}
|
|
|
|
|
}
|