/**
  * Show the history for a host or service
  */
 public function historyAction()
 {
     $this->getTabs()->activate('history');
     $this->view->history = $this->object->fetchEventHistory()->eventhistory;
     $this->applyRestriction('monitoring/filter/objects', $this->view->history);
     $this->setupLimitControl(50);
     $this->setupPaginationControl($this->view->history, 50);
     $this->view->object = $this->object;
 }
 /**
  * Export to JSON if requested
  */
 protected function handleFormatRequest($query = null)
 {
     if ($this->params->get('format') === 'json' || $this->getRequest()->getHeader('Accept') === 'application/json') {
         $payload = (array) $this->object->properties;
         $payload += array('contacts' => $this->object->contacts->fetchPairs(), 'contact_groups' => $this->object->contactgroups->fetchPairs(), 'vars' => $this->object->customvars);
         $groupName = $this->object->getType() . 'groups';
         $payload[$groupName] = $this->object->{$groupName};
         $this->getResponse()->json()->setSuccessData($payload)->sendResponse();
     }
 }
Esempio n. 3
0
 /**
  * Display the detail view for a downtime
  */
 public function showAction()
 {
     $this->view->downtime = $this->downtime;
     $this->view->isService = $this->isService;
     $this->view->stateName = isset($this->downtime->service_description) ? Service::getStateText($this->downtime->service_state) : Host::getStateText($this->downtime->host_state);
     $this->view->listAllLink = Url::fromPath('monitoring/list/downtimes');
     $this->view->showHostLink = Url::fromPath('monitoring/host/show')->setParam('host', $this->downtime->host_name);
     $this->view->showServiceLink = Url::fromPath('monitoring/service/show')->setParam('host', $this->downtime->host_name)->setParam('service', $this->downtime->service_description);
     if ($this->hasPermission('monitoring/command/downtime/delete')) {
         $this->view->delDowntimeForm = $this->createDelDowntimeForm();
         $this->view->delDowntimeForm->populate(array('redirect' => Url::fromPath('monitoring/list/downtimes'), 'downtime_id' => $this->downtime->id, 'downtime_is_service' => $this->isService));
     }
 }
Esempio n. 4
0
 /**
  * Fetch all downtimes matching the current filter and add tabs
  *
  * @throws Zend_Controller_Action_Exception
  */
 public function init()
 {
     $this->filter = Filter::fromQueryString(str_replace('downtime_id', 'downtime_internal_id', (string) $this->params));
     $query = $this->backend->select()->from('downtime', array('id' => 'downtime_internal_id', 'objecttype' => 'object_type', 'comment' => 'downtime_comment', 'author_name' => 'downtime_author_name', 'start' => 'downtime_start', 'scheduled_start' => 'downtime_scheduled_start', 'scheduled_end' => 'downtime_scheduled_end', 'end' => 'downtime_end', 'duration' => 'downtime_duration', 'is_flexible' => 'downtime_is_flexible', 'is_fixed' => 'downtime_is_fixed', 'is_in_effect' => 'downtime_is_in_effect', 'entry_time' => 'downtime_entry_time', 'host_state', 'service_state', 'host_name', 'service_description', 'host_display_name', 'service_display_name'))->addFilter($this->filter);
     $this->applyRestriction('monitoring/filter/objects', $query);
     $this->downtimes = $query->getQuery()->fetchAll();
     if (false === $this->downtimes) {
         throw new Zend_Controller_Action_Exception($this->translate('Downtime not found'));
     }
     $this->getTabs()->add('downtimes', array('title' => $this->translate('Display detailed information about multiple downtimes.'), 'icon' => 'plug', 'label' => $this->translate('Downtimes') . sprintf(' (%d)', count($this->downtimes)), 'url' => 'monitoring/downtimes/show'))->activate('downtimes');
     foreach ($this->downtimes as $downtime) {
         if (isset($downtime->service_description)) {
             $downtime->isService = true;
         } else {
             $downtime->isService = false;
         }
         if ($downtime->isService) {
             $downtime->stateText = Service::getStateText($downtime->service_state);
         } else {
             $downtime->stateText = Host::getStateText($downtime->host_state);
         }
     }
 }
Esempio n. 5
0
 /**
  * Get the data view
  *
  * @return \Icinga\Module\Monitoring\DataView\ServiceStatus
  */
 protected function getDataView()
 {
     return $this->backend->select()->from('servicestatus', array('instance_name', 'host_icon_image', 'host_icon_image_alt', 'host_acknowledged', 'host_active_checks_enabled', 'host_address', 'host_address6', 'host_alias', 'host_display_name', 'host_handled', 'host_in_downtime', 'host_last_state_change', 'host_name', 'host_notifications_enabled', 'host_passive_checks_enabled', 'host_state', 'service_icon_image', 'service_icon_image_alt', 'service_acknowledged', 'service_acknowledgement_type', 'service_action_url', 'service_active_checks_enabled', 'service_active_checks_enabled_changed', 'service_attempt', 'service_check_command', 'service_check_execution_time', 'service_check_latency', 'service_check_source', 'service_check_timeperiod', 'service_current_notification_number', 'service_description', 'service_display_name', 'service_event_handler_enabled', 'service_event_handler_enabled_changed', 'service_flap_detection_enabled', 'service_flap_detection_enabled_changed', 'service_handled', 'service_in_downtime', 'service_is_flapping', 'service_is_reachable', 'service_last_check', 'service_last_notification', 'service_last_state_change', 'service_long_output', 'service_next_check', 'service_next_update', 'service_notes', 'service_notes_url', 'service_notifications_enabled', 'service_notifications_enabled_changed', 'service_obsessing', 'service_obsessing_changed', 'service_output', 'service_passive_checks_enabled', 'service_passive_checks_enabled_changed', 'service_percent_state_change', 'service_perfdata', 'service_process_perfdata' => 'service_process_performance_data', 'service_state', 'service_state_type'))->where('host_name', $this->host->getName())->where('service_description', $this->service);
 }
Esempio n. 6
0
 /**
  * Return an empty array with all possible host state names
  *
  * @return array    An array containing all possible host states as keys and 0 as values.
  */
 public static function getHostStatesSummaryEmpty()
 {
     return StringHelper::cartesianProduct(array(array('hosts'), array(Host::getStateText(Host::STATE_UP), Host::getStateText(Host::STATE_DOWN), Host::getStateText(Host::STATE_UNREACHABLE), Host::getStateText(Host::STATE_PENDING)), array(null, 'handled', 'unhandled')), '_');
 }