2013-06-03 16:56:08 +02:00
|
|
|
<?php
|
2013-06-07 13:29:11 +02:00
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
2013-06-03 16:56:08 +02:00
|
|
|
namespace Icinga\Protocol\Commandpipe;
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* Class Downtime
|
|
|
|
* @package Icinga\Protocol\Commandpipe
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
class Downtime
|
|
|
|
{
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public $startTime;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public $endTime;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
private $fixed = false;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public $duration;
|
2013-06-07 13:29:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var mixed
|
|
|
|
*/
|
2013-06-03 16:56:08 +02:00
|
|
|
public $comment;
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $start
|
|
|
|
* @param $end
|
|
|
|
* @param Comment $comment
|
|
|
|
* @param int $duration
|
|
|
|
*/
|
|
|
|
public function __construct($start, $end, Comment $comment, $duration = 0)
|
2013-06-03 16:56:08 +02:00
|
|
|
{
|
|
|
|
$this->startTime = $start;
|
|
|
|
$this->endTime = $end;
|
|
|
|
$this->comment = $comment;
|
2013-06-07 13:29:11 +02:00
|
|
|
if ($duration != 0) {
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->fixed = true;
|
2013-06-07 13:29:11 +02:00
|
|
|
}
|
2013-06-03 16:56:08 +02:00
|
|
|
$this->duration = intval($duration);
|
|
|
|
}
|
|
|
|
|
2013-06-07 13:29:11 +02:00
|
|
|
/**
|
|
|
|
* @param $type
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getFormatString($type)
|
|
|
|
{
|
|
|
|
return 'SCHEDULE_' . $type . '_DOWNTIME;%s'
|
|
|
|
. ($type == CommandPipe::TYPE_SERVICE ? ';%s;' : ';')
|
|
|
|
. $this->startTime . ';' . $this->endTime
|
|
|
|
. ';' . ($this->fixed ? '1' : '0') . ';' . $this->duration . ';0;'
|
|
|
|
. $this->comment->author . ';' . $this->comment->comment;
|
2013-06-03 16:56:08 +02:00
|
|
|
}
|
|
|
|
}
|