From cdbd24ec9995183204d16efab2f126d81c8622f1 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Mon, 1 Sep 2014 15:08:56 +0200 Subject: [PATCH] monitoring/commands: Add (ENABLE|DISABLE)_NOTIFICATIONS/DISABLE_NOTIFICATIONS_EXPIRE_TIME commands `ToggleNotifications' is the command object for enabling/disabling host and service notifications on an Icinga instance with an optional expire time for disabling notifications. refs #6593 --- .../Command/Instance/ToggleNotifications.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 modules/monitoring/library/Monitoring/Command/Instance/ToggleNotifications.php diff --git a/modules/monitoring/library/Monitoring/Command/Instance/ToggleNotifications.php b/modules/monitoring/library/Monitoring/Command/Instance/ToggleNotifications.php new file mode 100644 index 000000000..6b1d5e362 --- /dev/null +++ b/modules/monitoring/library/Monitoring/Command/Instance/ToggleNotifications.php @@ -0,0 +1,54 @@ +expireTime = $expireTime !== null ? (int) $expireTime : null; + return parent::disable(); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Module\Monitoring\Command\IcingaCommand::getCommandString() For the method documentation. + */ + public function getCommandString() + { + if ($this->enable === true) { + return 'ENABLE_NOTIFICATIONS'; + } + if ($this->expireTime !== null) { + return sprintf( + '%s;%u;%u', + 'DISABLE_NOTIFICATIONS_EXPIRE_TIME', + time(), // Schedule time. According to the Icinga documentation schedule time has no effect currently + // and should be set to the current timestamp. + $this->expireTime + ); + } + return 'DISABLE_NOTIFICATIONS'; + } +}