Skip to content

Commit

Permalink
Enable and disable services notifications during the automatic downtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Aug 17, 2016
1 parent e9f0da2 commit 3ff9801
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/classes/engine/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 10 additions & 4 deletions src/downtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
* Icinga Editor - Downtime or Uptime confirm
*
* @package IcingaEditor
* @subpackage WebUI
* @author Vitex <vitex@hippy.cz>
* @copyright 2012 Vitex@hippy.cz (G)
* @copyright 2012-2016 Vitex@hippy.cz (G)
*/
require_once 'includes/IEInit.php';

Expand All @@ -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) {
Expand All @@ -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("<br/>\n", $extCmd->executeAll());
}

0 comments on commit 3ff9801

Please sign in to comment.