From 3ff9801c232890bbb8299639f6a0f6c844314306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=C4=9Bzslav=20Dvo=C5=99=C3=A1k?= Date: Wed, 17 Aug 2016 18:58:29 +0200 Subject: [PATCH] Enable and disable services notifications during the automatic downtime --- src/classes/engine/Host.php | 2 +- src/downtime.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/classes/engine/Host.php b/src/classes/engine/Host.php index 86b3e94..e996de3 100644 --- a/src/classes/engine/Host.php +++ b/src/classes/engine/Host.php @@ -599,7 +599,7 @@ public function getServices() { $services = []; - $service = new Service; + $service = new Service(); $servicesAssigned = $service->dblink->queryToArray('SELECT '.$service->myKeyColumn.','.$service->nameColumn.' FROM '.$service->myTable.' WHERE host_name LIKE \'%"'.$this->getName().'"%\'', $service->myKeyColumn); if ($servicesAssigned) { diff --git a/src/downtime.php b/src/downtime.php index c74f465..051aef7 100644 --- a/src/downtime.php +++ b/src/downtime.php @@ -6,9 +6,8 @@ * Icinga Editor - Downtime or Uptime confirm * * @package IcingaEditor - * @subpackage WebUI * @author Vitex - * @copyright 2012 Vitex@hippy.cz (G) + * @copyright 2012-2016 Vitex@hippy.cz (G) */ require_once 'includes/IEInit.php'; @@ -19,7 +18,8 @@ $state = $oPage->getRequestValue('state'); if ($host_id && $state) { - $host = new Engine\Host($host_id); + $host = new Engine\Host($host_id); + $servicesAssigned = $host->getServices(); $now = time(); $extCmd = new ExternalCommand(); switch ($state) { @@ -29,17 +29,23 @@ $extCmd->addCommand('SCHEDULE_HOST_DOWNTIME;'.$host->getName().';'.$now.';'.($now + $oneYear).';0;0;'.$oneYear.';'.$owner->getUserLogin().';remote downtime invoke'); $extCmd->addCommand('DISABLE_HOST_NOTIFICATIONS;'.$host->getName()); + foreach ($servicesAssigned as $serviceDescription) { + $extCmd->addCommand('DISABLE_SVC_NOTIFICATIONS;'.$host->getName().';'.$serviceDescription); + } $extCmd->addCommand('PROCESS_HOST_CHECK_RESULT;'.$host->getName().';1;Host go Down'); break; case 'stop': $extCmd->addCommand('PROCESS_HOST_CHECK_RESULT;'.$host->getName().';0;Host go Up'); $extCmd->addCommand('DEL_DOWNTIME_BY_HOST_NAME;'.$host->getName()); $extCmd->addCommand('ENABLE_HOST_NOTIFICATIONS;'.$host->getName()); + foreach ($servicesAssigned as $serviceDescription) { + $extCmd->addCommand('ENABLE_SVC_NOTIFICATIONS;'.$host->getName().';'.$serviceDescription); + } break; default : $oPage->addStatusMessage(sprintf(_('Unknown state %s.'), $state)); die(_('State can be only start or stop')); break; } - echo implode("\n", $extCmd->executeAll()); + echo implode("
\n", $extCmd->executeAll()); } \ No newline at end of file