From 1138afd5fb4c1210d51ca936c627510854297931 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 8 Jul 2013 11:16:23 +0200 Subject: [PATCH] Implement enable/disable flap detection for hosts/services Added action and mask for enabling/disabling flap detection for hosts and services. refs #4355 --- .../controllers/CommandController.php | 43 +++++++++++++++---- .../command/disableflapdetection.phtml | 1 + .../scripts/command/enableflapdetection.phtml | 1 + 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/command/disableflapdetection.phtml create mode 100644 modules/monitoring/application/views/scripts/command/enableflapdetection.phtml diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index be9936b2b..5610c6a94 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -343,6 +343,40 @@ class Monitoring_CommandController extends ModuleActionController } } + public function enableflapdetectionAction() + { + $form = new SendCommand("Enable flap detection?"); + if ($this->_request->isPost()) { + if ($form->isValid()) { + $targets = $this->selectCommandTargets($form->getHosts(), $form->getServices()); + $this->target->enableFlappingDetection($targets); + } + } else { + $form->setServices($this->getParameter("services", false)); + $form->setHosts($this->getParameter("hosts")); + $form->setAction($this->view->url()); + $form->addSubmitButton("Commit"); + $this->view->form = $form; + } + } + + public function disableflapdetectionAction() + { + $form = new SendCommand("Disable flap detection?"); + if ($this->_request->isPost()) { + if ($form->isValid()) { + $targets = $this->selectCommandTargets($form->getHosts(), $form->getServices()); + $this->target->disableFlappingDetection($targets); + } + } else { + $form->setServices($this->getParameter("services", false)); + $form->setHosts($this->getParameter("hosts")); + $form->setAction($this->view->url()); + $form->addSubmitButton("Commit"); + $this->view->form = $form; + } + } + public function sendPassivechecks() { if ($this->getMandatoryParameter("enable")) { @@ -352,15 +386,6 @@ class Monitoring_CommandController extends ModuleActionController } } - public function sendFlappingdetection() - { - if ($this->getMandatoryParameter("enable")) { - $this->target->enableFlappingDetection($this->selectCommandTargets()); - } else { - $this->target->disableFlappingDetection($this->selectCommandTargets()); - } - } - public function sendComment() { $author = "AUTHOR"; //@TODO: get from auth backend diff --git a/modules/monitoring/application/views/scripts/command/disableflapdetection.phtml b/modules/monitoring/application/views/scripts/command/disableflapdetection.phtml new file mode 100644 index 000000000..4bae1498a --- /dev/null +++ b/modules/monitoring/application/views/scripts/command/disableflapdetection.phtml @@ -0,0 +1 @@ +form ?> \ No newline at end of file diff --git a/modules/monitoring/application/views/scripts/command/enableflapdetection.phtml b/modules/monitoring/application/views/scripts/command/enableflapdetection.phtml new file mode 100644 index 000000000..4bae1498a --- /dev/null +++ b/modules/monitoring/application/views/scripts/command/enableflapdetection.phtml @@ -0,0 +1 @@ +form ?> \ No newline at end of file