* @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 * @author Icinga Development Team */ // {{{ICINGA_LICENSE_HEADER}}} namespace Icinga\Module\Monitoring\Command; use Icinga\Protocol\Commandpipe\BaseCommand; /** * Command to delay a notification */ class DelayNotificationCommand extends BaseCommand { /** * The delay in seconds * * @var int */ private $delay; /** * Initialise a new delay notification command object * * @param int $delay How long, in seconds, notifications should be delayed */ public function __construct($delay) { $this->delay = $delay; } /** * Set how long notifications should be delayed * * @param int $seconds In seconds * * @return self */ public function setDelay($seconds) { $this->delay = (int) $seconds; return $this; } /** * Return this command's parameters properly arranged in an array * * @return array * @see BaseCommand::getParameters() */ public function getParameters() { return array($this->delay); } /** * Return the command as a string with the given host being inserted * * @param string $hostname The name of the host to insert * * @return string The string representation of the command * @see BaseCommand::getHostCommand() */ public function getHostCommand($hostname) { return 'DELAY_HOST_NOTIFICATION;' . implode(';', array_merge(array($hostname), $this->getParameters())); } /** * Return the command as a string with the given host and service being inserted * * @param string $hostname The name of the host to insert * @param string $servicename The name of the service to insert * * @return string The string representation of the command * @see BaseCommand::getServiceCommand() */ public function getServiceCommand($hostname, $servicename) { return 'DELAY_SVC_NOTIFICATION;' . implode( ';', array_merge( array($hostname, $servicename), $this->getParameters() ) ); } }