Implement enable/disable active checks for hosts/services

Added action and mask for enabling/disabling active checks
of hosts and services.

refs #4355
This commit is contained in:
Johannes Meyer 2013-07-08 10:21:15 +02:00 committed by Marius Hein
parent 4b8643dc56
commit 387811c4a2
3 changed files with 71 additions and 4 deletions

View File

@ -151,12 +151,77 @@ class Monitoring_CommandController extends ModuleActionController
$this->target->scheduleDowntime($this->selectCommandTargets(), $downtime);
}
public function sendActivechecks()
public function enableactivechecksAction()
{
if ($this->getMandatoryParameter("enable")) {
$this->target->enableActiveChecks($this->selectCommandTargets());
// @TODO: Elaborate how "withChilds" and "forHosts" can be utilised
$form = new SendCommand("Enable active checks?");
if ($this->_request->isPost()) {
if ($form->isValid()) {
$withChilds = $forHosts = false;
$services = $form->getServices();
if ($services) {
$withChilds = $services === "all";
$form->addCheckbox("forHosts", "", false);
$forHosts = $form->isChecked("forHosts");
if ($withChilds) {
$targets = $this->selectCommandTargets($form->getHosts());
} else {
$targets = $this->selectCommandTargets($form->getHosts(), $services);
}
} else {
$targets = $this->selectCommandTargets($form->getHosts());
}
$this->target->enableActiveChecks($targets);
}
} else {
$this->target->disableActiveChecks($this->selectCommandTargets());
$services = $this->getParameter("services", false);
if ($services) {
$form->addCheckbox("forHosts", "Enable for hosts too?", false);
}
$form->setServices($services);
$form->setHosts($this->getParameter("hosts"));
$form->setAction($this->view->url());
$form->addSubmitButton("Commit");
$this->view->form = $form;
}
}
public function disableactivechecksAction()
{
// @TODO: Elaborate how "withChilds" and "forHosts" can be utilised
$form = new SendCommand("Disable active checks?");
if ($this->_request->isPost()) {
if ($form->isValid()) {
$withChilds = $forHosts = false;
$services = $form->getServices();
if ($services) {
$withChilds = $services === "all";
$form->addCheckbox("forHosts", "", false);
$forHosts = $form->isChecked("forHosts");
if ($withChilds) {
$targets = $this->selectCommandTargets($form->getHosts());
} else {
$targets = $this->selectCommandTargets($form->getHosts(), $services);
}
} else {
$targets = $this->selectCommandTargets($form->getHosts());
}
$this->target->disableActiveChecks($targets);
}
} else {
$services = $this->getParameter("services", false);
if ($services) {
$form->addCheckbox("forHosts", "Disable for hosts too?", false);
}
$form->setServices($services);
$form->setHosts($this->getParameter("hosts"));
$form->setAction($this->view->url());
$form->addSubmitButton("Commit");
$this->view->form = $form;
}
}

View File

@ -0,0 +1 @@
<?= $this->form ?>

View File

@ -0,0 +1 @@
<?= $this->form ?>