summaryrefslogtreecommitdiffstats
path: root/library/Icingadb/Model/ServiceState.php
blob: 1d7dc31cdbb4fabc83042cd69988bd4e276a336b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php

/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Common\ServiceStates;
use ipl\Orm\Relations;

/**
 * Service state model.
 *
 * @property string $service_id
 */
class ServiceState extends State
{
    public function getTableName()
    {
        return 'service_state';
    }

    public function getKeyName()
    {
        return 'service_id';
    }

    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')
        ];
    }

    public function createRelations(Relations $relations)
    {
        $relations->belongsTo('environment', Environment::class);
        $relations->belongsTo('service', Service::class);
        $relations->hasOne('last_comment', LastServiceComment::class)
            ->setCandidateKey('last_comment_id')
            ->setForeignKey('id')
            ->setJoinType('LEFT');
    }

    public function getStateText(): string
    {
        return ServiceStates::text($this->soft_state);
    }

    public function getStateTextTranslated(): string
    {
        return ServiceStates::text($this->soft_state);
    }
}