示例#1
0
 /**
  * Schedule host downtimes
  */
 public function scheduleHostDowntimeAction()
 {
     $filter = $this->getFilterOrExitIfEmpty();
     $hostList = new HostList($this->backend);
     $hostList->applyFilter($this->getRestriction('monitoring/filter/objects'))->applyFilter($filter);
     if (!$hostList->count()) {
         $this->getResponse()->json()->setFailData(array('filter' => 'No hosts found matching the filter'))->sendResponse();
     }
     $form = new ScheduleHostDowntimeCommandForm();
     $form->setIsApiTarget(true)->setBackend($this->backend)->setObjects($hostList->fetch())->handleRequest($this->getRequest());
 }
示例#2
0
 /**
  * Calculate the current state summary and populate hostStateSummary and serviceStateSummary
  * properties
  */
 protected function initStateSummaries()
 {
     $serviceStates = array_fill_keys(self::getServiceStatesSummaryEmpty(), 0);
     $hostStates = array_fill_keys(HostList::getHostStatesSummaryEmpty(), 0);
     foreach ($this as $service) {
         $unhandled = false;
         if ((bool) $service->problem === true && (bool) $service->handled === false) {
             $unhandled = true;
         }
         $stateName = 'services_' . $service::getStateText($service->state);
         ++$serviceStates[$stateName];
         ++$serviceStates[$stateName . ($unhandled ? '_unhandled' : '_handled')];
         if (!isset($knownHostStates[$service->getHost()->getName()])) {
             $unhandledHost = (bool) $service->host_problem === true && (bool) $service->host_handled === false;
             ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state)];
             ++$hostStates['hosts_' . $service->getHost()->getStateText($service->host_state) . ($unhandledHost ? '_unhandled' : '_handled')];
             $knownHostStates[$service->getHost()->getName()] = true;
         }
     }
     $serviceStates['services_total'] = count($this);
     $this->hostStateSummary = $hostStates;
     $this->serviceStateSummary = $serviceStates;
 }
示例#3
0
 public function showAction()
 {
     $this->setAutorefreshInterval(15);
     $checkNowForm = new CheckNowCommandForm();
     $checkNowForm->setObjects($this->hostList)->handleRequest();
     $this->view->checkNowForm = $checkNowForm;
     $this->hostList->setColumns(array('host_acknowledged', 'host_active_checks_enabled', 'host_display_name', 'host_handled', 'host_in_downtime', 'host_is_flapping', 'host_last_state_change', 'host_name', 'host_notifications_enabled', 'host_passive_checks_enabled', 'host_problem', 'host_state'));
     $acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
     if (!empty($acknowledgedObjects)) {
         $removeAckForm = new RemoveAcknowledgementCommandForm();
         $removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
         $this->view->removeAckForm = $removeAckForm;
     }
     $hostStates = $this->hostList->getStateSummary();
     $this->setAutorefreshInterval(15);
     $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
     $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime');
     $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result');
     $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment');
     $this->view->stats = $hostStates;
     $this->view->objects = $this->hostList;
     $this->view->unhandledObjects = $this->hostList->getUnhandledObjects();
     $this->view->problemObjects = $this->hostList->getProblemObjects();
     $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getProblemObjects()->objectsFilter()->toQueryString());
     $this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
     $this->view->acknowledgeLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
     $this->view->unacknowledgedObjects = $this->hostList->getUnacknowledgedObjects();
     $this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime();
     $this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts')->setQueryString($this->hostList->getObjectsInDowntime()->objectsFilter()->toQueryString());
     $this->view->showDowntimesLink = Url::fromPath('monitoring/list/downtimes')->setQueryString($this->hostList->objectsFilter()->andFilter(FilterEqual::where('object_type', 'host'))->toQueryString());
     $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
     $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification');
 }
示例#4
0
 public function showAction()
 {
     $this->setAutorefreshInterval(15);
     if ($this->Auth()->hasPermission('monitoring/command/schedule-check')) {
         $checkNowForm = new CheckNowCommandForm();
         $checkNowForm->setObjects($this->hostList)->handleRequest();
         $this->view->checkNowForm = $checkNowForm;
     }
     $acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
     if (!empty($acknowledgedObjects)) {
         $removeAckForm = new RemoveAcknowledgementCommandForm();
         $removeAckForm->setObjects($acknowledgedObjects)->handleRequest();
         $this->view->removeAckForm = $removeAckForm;
     }
     $featureStatus = $this->hostList->getFeatureStatus();
     $toggleFeaturesForm = new ToggleObjectFeaturesCommandForm(array('backend' => $this->backend, 'objects' => $this->hostList));
     $toggleFeaturesForm->load((object) $featureStatus)->handleRequest();
     $this->view->toggleFeaturesForm = $toggleFeaturesForm;
     $hostStates = $this->hostList->getStateSummary();
     $this->setAutorefreshInterval(15);
     $this->view->rescheduleAllLink = Url::fromRequest()->setPath('monitoring/hosts/reschedule-check');
     $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime');
     $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result');
     $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment');
     $this->view->stats = $hostStates;
     $this->view->objects = $this->hostList;
     $this->view->unhandledObjects = $this->hostList->getUnhandledObjects();
     $this->view->problemObjects = $this->hostList->getProblemObjects();
     $this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getUnhandledObjects()->objectsFilter()->toQueryString());
     $this->view->downtimeLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString($this->hostList->getProblemObjects()->objectsFilter()->toQueryString());
     $this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects();
     $this->view->acknowledgeLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString($this->hostList->getUnacknowledgedObjects()->objectsFilter()->toQueryString());
     $this->view->unacknowledgedObjects = $this->hostList->getUnacknowledgedObjects();
     $this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime();
     $this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts')->setQueryString($this->hostList->getObjectsInDowntime()->objectsFilter()->toQueryString());
     $this->view->showDowntimesLink = Url::fromPath('monitoring/list/downtimes')->setQueryString($this->hostList->objectsFilter()->andFilter(FilterEqual::where('object_type', 'host'))->toQueryString());
     $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments');
     $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification');
 }