Skip to content

Commit 3ff9801

Browse files
committed
Enable and disable services notifications during the automatic downtime
1 parent e9f0da2 commit 3ff9801

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/classes/engine/Host.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public function getServices()
599599
{
600600
$services = [];
601601

602-
$service = new Service;
602+
$service = new Service();
603603
$servicesAssigned = $service->dblink->queryToArray('SELECT '.$service->myKeyColumn.','.$service->nameColumn.' FROM '.$service->myTable.' WHERE host_name LIKE \'%"'.$this->getName().'"%\'',
604604
$service->myKeyColumn);
605605
if ($servicesAssigned) {

src/downtime.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
* Icinga Editor - Downtime or Uptime confirm
77
*
88
* @package IcingaEditor
9-
* @subpackage WebUI
109
* @author Vitex <vitex@hippy.cz>
11-
* @copyright 2012 Vitex@hippy.cz (G)
10+
* @copyright 2012-2016 Vitex@hippy.cz (G)
1211
*/
1312
require_once 'includes/IEInit.php';
1413

@@ -19,7 +18,8 @@
1918
$state = $oPage->getRequestValue('state');
2019

2120
if ($host_id && $state) {
22-
$host = new Engine\Host($host_id);
21+
$host = new Engine\Host($host_id);
22+
$servicesAssigned = $host->getServices();
2323
$now = time();
2424
$extCmd = new ExternalCommand();
2525
switch ($state) {
@@ -29,17 +29,23 @@
2929
$extCmd->addCommand('SCHEDULE_HOST_DOWNTIME;'.$host->getName().';'.$now.';'.($now
3030
+ $oneYear).';0;0;'.$oneYear.';'.$owner->getUserLogin().';remote downtime invoke');
3131
$extCmd->addCommand('DISABLE_HOST_NOTIFICATIONS;'.$host->getName());
32+
foreach ($servicesAssigned as $serviceDescription) {
33+
$extCmd->addCommand('DISABLE_SVC_NOTIFICATIONS;'.$host->getName().';'.$serviceDescription);
34+
}
3235
$extCmd->addCommand('PROCESS_HOST_CHECK_RESULT;'.$host->getName().';1;Host go Down');
3336
break;
3437
case 'stop':
3538
$extCmd->addCommand('PROCESS_HOST_CHECK_RESULT;'.$host->getName().';0;Host go Up');
3639
$extCmd->addCommand('DEL_DOWNTIME_BY_HOST_NAME;'.$host->getName());
3740
$extCmd->addCommand('ENABLE_HOST_NOTIFICATIONS;'.$host->getName());
41+
foreach ($servicesAssigned as $serviceDescription) {
42+
$extCmd->addCommand('ENABLE_SVC_NOTIFICATIONS;'.$host->getName().';'.$serviceDescription);
43+
}
3844
break;
3945
default :
4046
$oPage->addStatusMessage(sprintf(_('Unknown state %s.'), $state));
4147
die(_('State can be only start or stop'));
4248
break;
4349
}
44-
echo implode("\n", $extCmd->executeAll());
50+
echo implode("<br/>\n", $extCmd->executeAll());
4551
}

0 commit comments

Comments
 (0)