summaryrefslogtreecommitdiffstats
path: root/modules/monitoring/library/Monitoring/Command/Object/ScheduleServiceDowntimeCommand.php
blob: a023ab5d5719168a359d5c6040bbadfbb75a52bb (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */

namespace Icinga\Module\Monitoring\Command\Object;

/**
 * Schedule a service downtime
 */
class ScheduleServiceDowntimeCommand extends AddCommentCommand
{
    /**
     * (non-PHPDoc)
     * @see \Icinga\Module\Monitoring\Command\Object\ObjectCommand::$allowedObjects For the property documentation.
     */
    protected $allowedObjects = array(
        self::TYPE_SERVICE
    );

    /**
     * Downtime starts at the exact time specified
     *
     * If `Downtime::$fixed' is set to false, the time between `Downtime::$start' and `Downtime::$end' at which a
     * host or service transitions to a problem state determines the time at which the downtime actually starts.
     * The downtime will then last for `Downtime::$duration' seconds.
     *
     * @var int Unix timestamp
     */
    protected $start;

    /**
     * Downtime ends at the exact time specified
     *
     * If `Downtime::$fixed' is set to false, the time between `Downtime::$start' and `Downtime::$end' at which a
     * host or service transitions to a problem state determines the time at which the downtime actually starts.
     * The downtime will then last for `Downtime::$duration' seconds.
     *
     * @var int Unix timestamp
     */
    protected $end;

    /**
     * Whether it's a fixed or flexible downtime
     *
     * @var bool
     */
    protected $fixed = true;

    /**
     * ID of the downtime which triggers this downtime
     *
     * The start of this downtime is triggered by the start of the other scheduled host or service downtime.
     *
     * @var int|null
     */
    protected $triggerId;

    /**
     * The duration in seconds the downtime must last if it's a flexible downtime
     *
     * If `Downtime::$fixed' is set to false, the downtime will last for the duration in seconds specified, even
     * if the host or service recovers before the downtime expires.
     *
     * @var int|null
     */
    protected $duration;

    /**
     * Set the time when the downtime should start
     *
     * @param   int $start Unix timestamp
     *
     * @return  $this
     */
    public function setStart($start)
    {
        $this->start = (int) $start;
        return $this;
    }

    /**
     * Get the time when the downtime should start
     *
     * @return int Unix timestamp
     */
    public function getStart()
    {
        return $this->start;
    }

    /**
     * Set the time when the downtime should end
     *
     * @param   int $end Unix timestamp
     *
     * @return  $this
     */
    public function setEnd($end)
    {
        $this->end = (int) $end;
        return $this;
    }

    /**
     * Get the time when the downtime should end
     *
     * @return int Unix timestamp
     */
    public function getEnd()
    {
        return $this->end;
    }

    /**
     * Set whether it's a fixed or flexible downtime
     *
     * @param   boolean $fixed
     *
     * @return  $this
     */
    public function setFixed($fixed = true)
    {
        $this->fixed = (bool) $fixed;
        return $this;
    }

    /**
     * Is the downtime fixed?
     *
     * @return boolean
     */
    public function getFixed()
    {
        return $this->fixed;
    }

    /**
     * Set the ID of the downtime which triggers this downtime
     *
     * @param   int $triggerId
     *
     * @return  $this
     */
    public function setTriggerId($triggerId)
    {
        $this->triggerId = (int) $triggerId;
        return $this;
    }

    /**
     * Get the ID of the downtime which triggers this downtime
     *
     * @return int|null
     */
    public function getTriggerId()
    {
        return $this->triggerId;
    }

    /**
     * Set the duration in seconds the downtime must last if it's a flexible downtime
     *
     * @param   int $duration
     *
     * @return  $this
     */
    public function setDuration($duration)
    {
        $this->duration = (int) $duration;
        return $this;
    }

    /**
     * Get the duration in seconds the downtime must last if it's a flexible downtime
     *
     * @return int|null
     */
    public function getDuration()
    {
        return $this->duration;
    }

    /**
     * (non-PHPDoc)
     * @see \Icinga\Module\Monitoring\Command\Object\IcingaCommand::getName() For the method documentation.
     */
    public function getName()
    {
        return 'ScheduleDowntime';
    }
}