Adjust schedule downtime handling

refs #4580
This commit is contained in:
Johannes Meyer 2013-09-05 12:41:28 +02:00 committed by Eric Lippmann
parent ba7f455643
commit 52079b2e73
2 changed files with 36 additions and 7 deletions

View File

@ -29,7 +29,6 @@
namespace Icinga\Module\Monitoring\Command; namespace Icinga\Module\Monitoring\Command;
use Icinga\Protocol\Commandpipe\Comment; use Icinga\Protocol\Commandpipe\Comment;
use Icinga\Exception\NotImplementedError;
/** /**
* Command for scheduling a new downtime * Command for scheduling a new downtime
@ -176,6 +175,27 @@ class ScheduleDowntimeCommand extends BaseCommand
$this->triggerId = $triggerId; $this->triggerId = $triggerId;
} }
/**
* Return this command's parameters properly arranged in an array
*
* @return array
*
* @see BaseCommand::getParameters()
*/
public function getParameters()
{
return array_merge(
array(
$this->startTime,
$this->endTime,
$this->fixed ? '1' : '0',
$this->triggerId,
$this->duration
),
$this->comment->getParameters(true)
);
}
/** /**
* Return the command as a string for the given host or all of it's services * Return the command as a string for the given host or all of it's services
* *
@ -186,7 +206,8 @@ class ScheduleDowntimeCommand extends BaseCommand
*/ */
public function getHostCommand($hostname, $servicesOnly = false) public function getHostCommand($hostname, $servicesOnly = false)
{ {
throw new NotImplementedError(); return sprintf('SCHEDULE_HOST%s_DOWNTIME;', $servicesOnly ? '_SVC' : '')
. implode(';', array_merge(array($hostname), $this->getParameters()));
} }
/** /**
@ -199,7 +220,8 @@ class ScheduleDowntimeCommand extends BaseCommand
*/ */
public function getPropagatedHostCommand($hostname, $triggered = false) public function getPropagatedHostCommand($hostname, $triggered = false)
{ {
throw new NotImplementedError(); return sprintf('SCHEDULE_AND_PROPAGATE%s_HOST_DOWNTIME;', $triggered ? '_TRIGGERED' : '')
. implode(';', array_merge(array($hostname), $this->getParameters()));
} }
/** /**
@ -212,7 +234,13 @@ class ScheduleDowntimeCommand extends BaseCommand
*/ */
public function getServiceCommand($hostname, $servicename) public function getServiceCommand($hostname, $servicename)
{ {
throw new NotImplementedError(); return 'SCHEDULE_SVC_DOWNTIME;' . implode(
';',
array_merge(
array($hostname, $servicename),
$this->getParameters()
)
);
} }
/** /**
@ -225,7 +253,8 @@ class ScheduleDowntimeCommand extends BaseCommand
*/ */
public function getHostgroupCommand($hostgroup, $hostsOnly = true) public function getHostgroupCommand($hostgroup, $hostsOnly = true)
{ {
throw new NotImplementedError(); return sprintf('SCHEDULE_HOSTGROUP_%s_DOWNTIME;', $hostsOnly ? 'HOST' : 'SVC')
. implode(';', array_merge(array($hostgroup), $this->getParameters()));
} }
/** /**
@ -238,6 +267,7 @@ class ScheduleDowntimeCommand extends BaseCommand
*/ */
public function getServicegroupCommand($servicegroup, $hostsOnly = true) public function getServicegroupCommand($servicegroup, $hostsOnly = true)
{ {
throw new NotImplementedError(); return sprintf('SCHEDULE_SERVICEGROUP_%s_DOWNTIME;', $hostsOnly ? 'HOST' : 'SVC')
. implode(';', array_merge(array($servicegroup), $this->getParameters()));
} }
} }

View File

@ -15,7 +15,6 @@ class CommandPipeLoader extends LibraryLoader {
require_once("Zend/Config.php"); require_once("Zend/Config.php");
require_once("Zend/Log.php"); require_once("Zend/Log.php");
require_once("../../library/Icinga/Application/Logger.php"); require_once("../../library/Icinga/Application/Logger.php");
require_once("../../library/Icinga/Exception/NotImplementedError.php");
require_once("../../library/Icinga/Protocol/Commandpipe/Comment.php"); require_once("../../library/Icinga/Protocol/Commandpipe/Comment.php");
require_once("../../library/Icinga/Protocol/Commandpipe/CommandType.php"); require_once("../../library/Icinga/Protocol/Commandpipe/CommandType.php");