From f57bb0f6a11ad3e6ca423d60c315de6d00fd093f Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 4 Sep 2014 15:37:30 +0200 Subject: [PATCH] modules/commands: Add common `ScheduleDowntimeCommand' `ScheduleDowntimeCommand' is the base class for commands scheduling downtimes. refs #6593 --- .../Common/ScheduleDowntimeCommand.php | 193 ++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Command/Common/ScheduleDowntimeCommand.php diff --git a/modules/monitoring/library/Monitoring/Command/Common/ScheduleDowntimeCommand.php b/modules/monitoring/library/Monitoring/Command/Common/ScheduleDowntimeCommand.php new file mode 100644 index 000000000..67713c425 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Command/Common/ScheduleDowntimeCommand.php @@ -0,0 +1,193 @@ +start = $start; + return $this; + } + + /** + * Get the date and time when the downtime should start + * + * @return DateTime + */ + public function getStart() + { + return $this->start; + } + + /** + * Set the date and time when the downtime should end + * + * @param DateTime $end + * + * @return $this + */ + public function setEnd(DateTime $end) + { + $this->end = $end; + return $this; + } + + /** + * Get the date and time when the downtime should end + * + * @return DateTime + */ + public function getEnd() + { + return $this->end; + } + + /** + * Set whether is flexible or fixed + * + * @param boolean $flexible + * + * @return $this + */ + public function setFlexible($flexible = true) + { + $this->flexible = (bool) $flexible; + return $this; + } + + /** + * Is the downtime flexible? + * + * @return boolean + */ + public function getFlexible() + { + return $this->flexible; + } + + /** + * 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\IcingaCommand::getCommandString() For the method documentation. + */ + public function getCommandString() + { + return sprintf( + '%u;%u;%u;%u;%u;%s', + $this->start->getTimestamp(), + $this->end->getTimestamp(), + ! $this->flexible, + $this->triggerId, + $this->duration, + parent::getCommandString() + ); + } +}