From 72efe7e8a02638a198291c5224d3893389f41575 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 9 Jul 2013 12:40:31 +0200 Subject: [PATCH] Implement command to send custom notifications Added command and mask to send custom notifications for hosts/services. refs #4355 --- .../controllers/CommandController.php | 31 +++++++++++++++++++ .../command/sendcustomnotification.phtml | 1 + 2 files changed, 32 insertions(+) create mode 100644 modules/monitoring/application/views/scripts/command/sendcustomnotification.phtml diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index f01eca038..de9a652b0 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -510,6 +510,37 @@ class Monitoring_CommandController extends ModuleActionController } } + public function sendcustomnotificationAction() + { + $form = new SendCommand("Send custom notification"); + $form->addTextBox("author", "Author (Your name):", "", true); + $form->addTextBox("comment", "Comment:", "", false, true); + $form->addCheckbox("force", "Forced:", false); + $form->addCheckbox("broadcast", "Broadcast:", false); + + if ($this->_request->isPost()) { + if ($form->isValid()) { + $comment = new Comment($form->getText("author"), $form->getText("comment")); + $targets = $this->selectCommandTargets($form->getHosts(), $form->getServices()); + + if ($form->isChecked("force")) { + $this->target->sendForcedCustomNotification($targets, $comment, + $form->isChecked("broadcast")); + } else { + $this->target->sendCustomNotification($targets, $comment, + $form->isChecked("broadcast")); + } + } + } else { + $form->getElement("author")->setValue(Manager::getInstance()->getUser()->getUsername()); + $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 sendComment() { $author = "AUTHOR"; //@TODO: get from auth backend diff --git a/modules/monitoring/application/views/scripts/command/sendcustomnotification.phtml b/modules/monitoring/application/views/scripts/command/sendcustomnotification.phtml new file mode 100644 index 000000000..4bae1498a --- /dev/null +++ b/modules/monitoring/application/views/scripts/command/sendcustomnotification.phtml @@ -0,0 +1 @@ +form ?> \ No newline at end of file