/** * Display the configuration snapshot of a host * with template inheritance * * @method get * @route /host/snapshotslide/[i:id] */ public function snapshotslideAction() { $params = $this->getParams(); $data = HostRepository::getInheritanceValues($params['id'], true); $host = Host::get($params['id'], 'host_name'); $data['host_name'] = $host['host_name']; $data['icon'] = HostRepository::getIconImage($data['host_name']); $hostConfiguration = HostRepository::formatDataForSlider($data); $aDataRealTime = HostRealtime::get($params['id']); $hostReal = HostRepository::formatDataForSlider($aDataRealTime); $servicesStatus = ServiceRealTimeRepository::countAllStatusForHost($params['id']); $edit_url = $this->router->getPathFor("/centreon-configuration/host/" . $params['id']); $this->router->response()->json(array('hostConfig' => $hostConfiguration, 'hostReal' => $hostReal, 'servicesStatus' => $servicesStatus, 'edit_url' => $edit_url, 'success' => true)); }
/** * Get scheduling informations for a specific host * * @method get * @route /host/[i:id]/scheduling-infos */ public function schedulingInfosHostAction() { $params = $this->getParams(); $schedulingInfos = HostRealtime::get($params['id'], array('execution_time', 'latency')); $poller = HostConf::get($params['id'], 'poller_id'); $schedulingInfos['poller_name'] = !is_null($poller['poller_id']) ? Poller::get($poller['poller_id'], 'name') : ""; unset($schedulingInfos['poller_id']); $this->router->response()->json(array('scheduling_infos' => $schedulingInfos, 'success' => true)); }
/** * * @param array $resultSet * @todo fix getIconImage() (perf issue) */ protected function formatDatas(&$resultSet) { $router = Di::getDefault()->get('router'); $previousHost = ''; HostConfigurationRepository::setObjectClass('\\CentreonConfiguration\\Models\\Host'); foreach ($resultSet as $key => &$myServiceSet) { $aTagUsed = array(); // Set host_name $myHostName = Host::get($myServiceSet['host_id'], array('name')); $myServiceSet['name'] = $myHostName['name']; $sideMenuCustom = new SlideMenu($myServiceSet['service_id']); $events = Di::getDefault()->get('events'); $events->emit('centreon-realtime.slide.menu.service', array($sideMenuCustom)); $myServiceSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu(); $myServiceSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu(); // @todo remove virtual hosts and virtual services if ($myServiceSet['name'] === '_Module_BAM') { unset($resultSet[$key]); continue; } if ($myServiceSet['name'] === $previousHost) { $myServiceSet['name'] = ''; } else { $previousHost = $myServiceSet['name']; $icon = '<span class="icoListing">' . HostConfigurationRepository::getIconImage($myServiceSet['name']) . '</span>'; $myServiceSet['name'] = $icon . $myServiceSet['name']; } $icon = '<span class="icoListing">' . ServiceConfigurationRepository::getIconImage($myServiceSet['service_id']) . '</span>'; /*$myServiceSet['DT_RowData']['right_side_details'] = $router->getPathFor('/centreon-realtime/service/') . $myServiceSet['host_id'] . '/'.$myServiceSet['service_id'] . '/tooltip'; */ $myServiceSet['description'] = '<span>' . $icon . '' . $myServiceSet['description'] . '</span>'; if ($myServiceSet['state'] != '0' && $myServiceSet['state'] != '4') { $acknowledgement = ServiceRealtimeRepository::getAcknowledgementInfos($myServiceSet['service_id']); if (count($acknowledgement) > 0) { $myServiceSet['description'] .= ' <i class="fa fa-thumb-tack"></i>'; } } if ($myServiceSet['perfdata'] != '') { $myServiceSet['ico'] = '<span data-overlay-url="/centreon-realtime/service/' . $myServiceSet['host_id'] . '/' . $myServiceSet['service_id'] . '/graph"><span class="overlay"><i class="fa fa-bar-chart-o"></i></span></span>'; } else { $myServiceSet['ico'] = ''; } $myServiceSet['duration'] = Datetime::humanReadable(time() - $myServiceSet['duration'], Datetime::PRECISION_FORMAT, 2); $myServiceSet['last_check'] = Datetime::humanReadable(time() - $myServiceSet['last_check'], Datetime::PRECISION_FORMAT, 2); /* Tags */ $myServiceSet['tagname'] = ""; $aTags = TagsRepository::getList('service', $myServiceSet['service_id'], 2, 0); foreach ($aTags as $oTags) { if (!in_array($oTags['id'], $aTagUsed)) { $aTagUsed[] = $oTags['id']; $myServiceSet['tagname'] .= TagsRepository::getTag('service', $myServiceSet['service_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']); } } /* $templates = ServiceConfigurationRepository::getListTemplates($myServiceSet['service_id'], array(), -1); foreach ($templates as $template) { $aTags = TagsRepository::getList('service', $template, 2, 0); foreach ($aTags as $oTags) { if (!in_array($oTags['id'], $aTagUsed)) { $aTagUsed[] = $oTags['id']; $myServiceSet['tagname'] .= TagsRepository::getTag('service', $template, $oTags['id'], $oTags['text'], $oTags['user_id'], 1); } } } */ $myServiceSet['tagname'] .= TagsRepository::getAddTag('service', $myServiceSet['service_id']); } $resultSet = array_values($resultSet); }
public static function formatDataForHeader($data) { /* Check data */ $checkdata = array(); $checkdata[_('id')] = $data['service_id']; $host = \CentreonRealtime\Models\Host::get($data['host_id']); $host_name = $host['name']; if (!empty($data['description'])) { $checkdata[_('name')] = $host_name . ' ' . $data['description']; } $checkdata[_('state')] = $data['state']; $checkdata[_('icon')] = ""; if (!empty($data['icon'])) { $checkdata[_('icon')] = $data['icon']; } $checkdata[_('url')] = ""; if (!empty($data['url'])) { $checkdata[_('url')] = $data['url']; } $checkdata[_('issue_duration')] = ""; if (!empty($data['issue_duration'])) { $checkdata[_('issue_duration')] = $data['issue_duration']; } return $checkdata; }