public function testHumanReadable() { /* Diff in seconds */ $diff = 47492387; $this->assertEquals('1 year 6 months 4 days 16 hours 19 min 47 sec', Datetime::humanReadable(47492387)); $this->assertEquals('1 year 6 months', Datetime::humanReadable(47492387, Datetime::PRECISION_FORMAT, 2)); $this->assertEquals('1 year 6 months 4 days', Datetime::humanReadable(47492387, Datetime::PRECISION_CHAR, 25)); $this->assertEquals('1 year', Datetime::humanReadable(47492387, Datetime::PRECISION_CHAR, 2)); }
use Centreon\Internal\Utils\Status; use Centreon\Internal\Utils\Datetime; /* Get Param */ $params = $this->getWidgetParams(); /* Get DB */ $dbM = $this->getMonitoringDb(); $db = $this->getConfigurationDb(); /* Init Params */ $data = array(); /* Get Data */ $query = "select h.name, NULL AS description, i.*, st.state FROM rt_issues i, rt_hosts h, rt_hoststateevents st WHERE i.host_id = h.host_id AND i.service_id IS NULL AND st.host_id = h.host_id AND st.start_time = st.start_time AND i.end_time IS NULL AND i.ack_time = 0 AND st.state < 3 UNION select h.name, s.description AS description, i.*, st.state FROM rt_issues i, rt_hosts h, rt_services s, rt_servicestateevents st WHERE i.host_id = h.host_id AND i.host_id = s.host_id AND s.service_id IS NOT NULL AND st.host_id = h.host_id AND st.service_id = s.service_id AND i.start_time = st.start_time AND i.end_time IS NULL AND i.ack_time = 0 AND st.state < 3 ORDER BY state DESC, start_time DESC LIMIT 10"; $stmt = $dbM->prepare($query); $stmt->execute(); $state_id = array("success" => 0, "warning" => 1, "danger" => 2, "default" => 3, "info" => 4); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { $row['duration'] = Datetime::humanReadable(time() - $row['start_time']); $status = 'success'; if (isset($row["description"])) { if ($row["state"] == 1) { $status = 'warning'; } else { if ($row["state"] == 2) { $status = 'danger'; } else { if ($row["state"] == 3) { $status = 'default'; } else { if ($row["state"] == 4) { $status = 'info'; } }
/** * * @param array $resultSet */ protected function formatDatas(&$resultSet) { foreach ($resultSet as &$myIndicatorSet) { // Add percent to impact $myIndicatorSet['last_impact'] = $myIndicatorSet['last_impact'] . '%'; // Set human readable duration $myIndicatorSet['duration'] = Datetime::humanReadable($myIndicatorSet['duration'], Datetime::PRECISION_FORMAT, 2); } }
/** * * @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); }
/** * * @param type $resultSet */ protected function formatDatas(&$resultSet) { foreach ($resultSet as &$myPollerSet) { if (!isset($myPollerSet['engine'])) { $myPollerSet['engine'] = ""; } if (isset($myPollerSet['version'])) { $myPollerSet['version'] = $myPollerSet['engine'] . ' ' . $myPollerSet['version']; } if (isset($myPollerSet['last_alive']) && !empty($myPollerSet['last_alive'])) { $myPollerSet['last_alive'] = Datetime::format($myPollerSet['last_alive']); } if (isset($myPollerSet['start_time']) && !empty($myPollerSet['start_time'])) { $myPollerSet['start_time'] = Datetime::format($myPollerSet['start_time']); } } }
/** * Service slider default menu * * @method get * @route /service/slideschelduded/[i:id] */ public function slideScheldudedInfosAction() { $router = Di::getDefault()->get('router'); $params = $this->getParams(); $return = array(); $service = ServicedetailRepository::getRealtimeData($params['id']); $serviceTemp = $service[0]; $return['schelduded']['name'] = $serviceTemp['instance_name']; $return['schelduded']['execution_time'] = Datetime::humanReadable(time() - $serviceTemp['last_command_check'], Datetime::PRECISION_FORMAT, 2); $return['schelduded']['latency'] = $serviceTemp['latency']; $return['success'] = true; $router->response()->json($return); }
/** * Format data so that it can be displayed in slider * * @param array $data * @return array $checkdata */ public static function formatDataForSlider($data) { /* Check data */ $checkdata = array(); $checkdata[_('id')] = $data['configurationData']['host_id']; $checkdata[_('name')] = $data['configurationData']['host_name']; $checkdata[_('command')] = ""; if (isset($data['configurationData']['command_command_id']) && !is_null($data['configurationData']['command_command_id'])) { $command = Command::getParameters($data['configurationData']['command_command_id'], 'command_name'); $checkdata[_('command')] = $command['command_name']; } $checkdata[_('time_period')] = ""; if (isset($data['configurationData']['timeperiod_tp_id']) && !is_null($data['configurationData']['timeperiod_tp_id'])) { $timeperiod = Timeperiod::getParameters($data['configurationData']['timeperiod_tp_id'], 'tp_name'); $checkdata[_('time_period')] = $timeperiod['tp_name']; } $checkdata[_('max_check attempts')] = ""; if (isset($data['configurationData']['host_max_check_attempts'])) { $checkdata[_('max_check_attempts')] = $data['configurationData']['host_max_check_attempts']; } $checkdata[_('check_interval')] = ""; if (isset($data['configurationData']['host_check_interval'])) { $checkdata[_('check_interval')] = $data['configurationData']['host_check_interval']; } $checkdata[_('retry_check_interval')] = ""; if (isset($data['configurationData']['host_retry_check_interval'])) { $checkdata[_('retry_check_interval')] = $data['configurationData']['host_retry_check_interval']; } $checkdata[_('active_checks_enabled')] = ""; if (isset($data['configurationData']['host_active_checks_enabled'])) { $checkdata[_('active_checks_enabled')] = YesNoDefault::toString($data['configurationData']['host_active_checks_enabled']); } $checkdata[_('passive_checks_enabled')] = ""; if (isset($data['configurationData']['host_passive_checks_enabled'])) { $checkdata[_('passive_checks_enabled')] = YesNoDefault::toString($data['configurationData']['host_passive_checks_enabled']); } if (!empty($data['configurationData']['icon'])) { $checkdata[_('icon')] = $data['configurationData']['icon']; } $checkdata[_('status')] = ""; if (!empty($data['realtimeData']['status'])) { $checkdata[_('status')] = $data['realtimeData']['status']; } $checkdata[_('state')] = ""; if (!empty($data['realtimeData']['state_type'])) { $checkdata[_('state')] = $data['realtimeData']['state_type']; } $checkdata[_('last_check')] = ""; if (!empty($data['realtimeData']['last_check'])) { $checkdata[_('last_check')] = Datetime::humanReadable(time() - $data['realtimeData']['last_check'], Datetime::PRECISION_FORMAT, 2); } $checkdata[_('next_check')] = ""; if (!empty($data['realtimeData']['next_check'])) { $checkdata[_('next_check')] = Datetime::humanReadable(time() - $data['realtimeData']['next_check'], Datetime::PRECISION_FORMAT, 2); } $checkdata[_('acknowledged')] = ""; if (!empty($data['realtimeData']['acknowledged'])) { $checkdata[_('acknowledged')] = $data['realtimeData']['acknowledged']; } $checkdata[_('downtime')] = ""; if (!empty($data['realtimeData']['scheduled_downtime_depth'])) { $checkdata[_('downtime')] = $data['realtimeData']['scheduled_downtime_depth']; } return $checkdata; }
/** * Get information for a incident for display graph * * @route /incident/graph * @method POST */ public function getIncidentGraphInfoAction() { $di = Di::getDefault(); $router = $di->get('router'); $response = array(); $action = $router->request()->param('action', null); $incidentId = $router->request()->param('incident_id', null); if (is_null($incidentId)) { $router->response()->code(400); return; } switch ($action) { case 'get_info': $incident = IncidentsRepository::getIncident($incidentId); $fullname = $incident['name']; if (false === is_null($incident['description'])) { $fullname .= ' - ' . $incident['description']; } $response = array('id' => $incident['issue_id'], 'name' => $fullname, 'status' => self::getCssStatus($incident['state']), 'output' => $incident['output'], 'last_update' => Datetime::format($incident['last_state_change']), 'has_children' => $incident['nb_children'] > 0 ? true : false, 'has_parent' => $incident['nb_parents'] > 0 ? true : false, 'parents' => array_map(function ($values) { $parent = array(); $parent['id'] = $values['issue_id']; $fullname = $values['name']; if (!is_null($values['description'])) { $fullname .= ' - ' . $values['description']; } $parent['name'] = $fullname; return $parent; }, $incident['parents'])); break; case 'getChildren': $listChildren = IncidentsRepository::getChildren($incidentId); $response = array(); foreach ($listChildren as $child) { $fullname = $child['name']; if (false === is_null($child['description'])) { $fullname .= ' - ' . $child['description']; } $response[] = array('id' => $child['issue_id'], 'name' => $fullname, 'status' => self::getCssStatus($child['state']), 'output' => $child['output'], 'last_update' => Datetime::format($child['last_state_change']), 'has_children' => $child['nb_children'] > 0 ? true : false, 'has_parent' => $child['nb_parents'] > 0 ? true : false); } break; case 'get_extended_info': $status = IncidentsRepository::getListStatus($incidentId); $statusList = array(); foreach ($status as $tmp) { if (false === is_null($tmp['service_id'])) { $statusType = Status::TYPE_SERVICE; } else { $statusType = Status::TYPE_HOST; } $statusList[] = array('id' => $tmp['state'], 'text' => Status::numToString($tmp['state'], $statusType, true), 'datetime' => $tmp['start_time']); } $response = array('status' => array(array('id' => 2, 'text' => 'Critical', 'datetime' => '2014-05-12 01:03:11'), array('id' => 2, 'text' => 'Critical', 'datetime' => '2014-05-12 01:03:11'), array('id' => 2, 'text' => 'Critical', 'datetime' => '2014-05-12 01:03:11'), array('id' => 2, 'text' => 'Critical', 'datetime' => '2014-05-12 01:03:11'))); break; default: $router->response()->code(400); return; } $router->response()->json($response); }
/** * * @param array $resultSet */ protected function formatDatas(&$resultSet) { foreach ($resultSet as $key => &$myHostSet) { $sideMenuCustom = new SlideMenu($myHostSet['host_id']); $events = Di::getDefault()->get('events'); $events->emit('centreon-realtime.slide.menu.host', array($sideMenuCustom)); $myHostSet['DT_RowData']['right_side_menu_list'] = $sideMenuCustom->getMenu(); $myHostSet['DT_RowData']['right_side_default_menu'] = $sideMenuCustom->getDefaultMenu(); $aTagUsed = array(); // @todo remove virtual hosts and virtual services if ($myHostSet['name'] === '_Module_BAM') { unset($resultSet[$key]); continue; } // Set host_name $myHostSet['name'] = '<span class="icoListing">' . HostConfigurationRepository::getIconImage($myHostSet['name']) . '</span>' . $myHostSet['name']; if ($myHostSet['state'] != '0' && $myHostSet['state'] != '4') { $acknowledgement = HostRealtimeRepository::getAcknowledgementInfos($myHostSet['host_id']); if (count($acknowledgement) > 0) { $myHostSet['name'] .= ' <i class="fa fa-thumb-tack"></i>'; } } $myHostSet['duration'] = Datetime::humanReadable(time() - $myHostSet['duration'], Datetime::PRECISION_FORMAT, 2); $myHostSet['last_check'] = Datetime::humanReadable(time() - $myHostSet['last_check'], Datetime::PRECISION_FORMAT, 2); /* Tags */ $myHostSet['tagname'] = ""; /* $aTags = TagsRepository::getList('host', $myHostSet['host_id'], 2, 0); foreach ($aTags as $oTags) { $myHostSet['tagname'] .= TagsRepository::getTag('host', $myHostSet['host_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']); } * */ $aTags = TagsRepository::getList('host', $myHostSet['host_id'], 2, 0); foreach ($aTags as $oTags) { if (!in_array($oTags['id'], $aTagUsed)) { $aTagUsed[] = $oTags['id']; $myHostSet['tagname'] .= TagsRepository::getTag('host', $myHostSet['host_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']); } } //Get tags affected by the template $templates = HostConfigurationRepository::getTemplateChain($myHostSet['host_id'], array(), -1); foreach ($templates as $template) { $aTags = TagsRepository::getList('host', $template['id'], 2, 0); foreach ($aTags as $oTags) { if (!in_array($oTags['id'], $aTagUsed)) { $aTagUsed[] = $oTags['id']; $myHostSet['tagname'] .= TagsRepository::getTag('host', $template['id'], $oTags['id'], $oTags['text'], $oTags['user_id'], 1); } } } $myHostSet['tagname'] .= TagsRepository::getAddTag('host', $myHostSet['host_id']); } $resultSet = array_values($resultSet); }
/** * * @param array $resultSet */ protected function formatDatas(&$resultSet) { $router = Di::getDefault()->get('router'); foreach ($resultSet as &$downtime) { $downtime['DT_RowData']['right_side_details'] = $router->getPathFor('/centreon-realtime/downtimes/') . $downtime['downtime_id'] . '/tooltip'; $downtime['duration'] = Datetime::humanReadable($downtime['duration'], Datetime::PRECISION_FORMAT, 2); } }
/** * * @param array $resultSet */ protected function formatDatas(&$resultSet) { $previousType = ''; foreach ($resultSet as &$myBaSet) { // Set business activity type $baType = \CentreonBam\Models\BusinessActivityType::getParameters($myBaSet['ba_type_id'], array('name')); $myBaSet['ba_type_id'] = $baType['name']; if ($myBaSet['ba_type_id'] === $previousType) { $myBaSet['ba_type_id'] = ''; } else { $previousType = $myBaSet['ba_type_id']; } // Set business activity availability $myBaSet['current_level'] = $myBaSet['current_level'] . '%'; // Set business activity name with its icon $myBaSet['name'] = BusinessActivityRepository::getIconImage($myBaSet['name']) . $myBaSet['name']; // Set human readable duration $myBaSet['duration'] = Datetime::humanReadable($myBaSet['duration'], Datetime::PRECISION_FORMAT, 2); /* Tags */ $myBaSet['tagname'] = ""; $aTags = TagsRepository::getList('ba', $myBaSet['ba_id'], 2); foreach ($aTags as $oTags) { $myBaSet['tagname'] .= TagsRepository::getTag('ba', $myBaSet['ba_id'], $oTags['id'], $oTags['text'], $oTags['user_id'], $oTags['template_id']); } $myBaSet['tagname'] .= TagsRepository::getAddTag('ba', $myBaSet['ba_id']); } }
/** * Execute the event * * @param \CentreonMain\Events\Status $event The event object */ public static function execute(StatusEvent $event) { $router = Di::getDefault()->get('router'); $arrayStatusService = array('success', 'warning', 'critical', 'unknown', 'pending'); $arrayStatusHost = array('success', 'critical', 'unreachable', '', 'pending'); $totalHosts = 0; $totalServices = 0; $incidents = IncidentsRepository::getIncidents(); $issues = array(); foreach ($incidents as $incident) { if (is_null($incident['service_desc'])) { $state = $arrayStatusHost[$incident['state']]; if (empty($issues[$state]['nb_hosts'])) { $issues[$state]['nb_hosts'] = 0; } if (empty($issues[$state]['total_impacts'])) { $issues[$state]['total_impacts'] = 0; } if (!isset($issues[$state]['objects']['hosts']) || count($issues[$state]['objects']['hosts']) < 5) { $hostsTemp = IncidentsRepository::formatDataForHeader($incident, 'host'); $hostsTemp['icon'] = HostRepositoryConfig::getIconImagePath($incident['host_id']); $hostsTemp['url'] = $router->getPathFor('/centreon-realtime/host/' . $incident['host_id']); $duration = Datetime::humanReadable(time() - $incident['stimestamp'], Datetime::PRECISION_FORMAT, 2); $hostsTemp['since'] = $duration; $issues[$state]['objects']['hosts'][] = $hostsTemp; } $childIncidents = IncidentsRepository::getChildren($incident['issue_id']); $issues[$state]['nb_hosts'] = $issues[$state]['nb_hosts'] + 1; $issues[$state]['total_impacts'] = $issues[$state]['total_impacts'] + count($childIncidents); } else { $state = $arrayStatusService[$incident['state']]; if (empty($issues[$state]['nb_services'])) { $issues[$state]['nb_services'] = 0; } if (empty($issues[$state]['total_impacts'])) { $issues[$state]['total_impacts'] = 0; } if (!isset($issues[$state]['objects']['services']) || count($issues[$state]['objects']['services']) < 5) { $serviceTemp = IncidentsRepository::formatDataForHeader($incident, 'service'); $serviceTemp['icon'] = ServiceRepositoryConfig::getIconImage($incident['service_id']); $serviceTemp['url'] = $router->getPathFor('/centreon-realtime/service/' . $incident['service_id']); $duration = Datetime::humanReadable(time() - $incident['stimestamp'], Datetime::PRECISION_FORMAT, 2); $serviceTemp['since'] = $duration; $issues[$state]['objects']['services'][] = $serviceTemp; } $childIncidents = IncidentsRepository::getChildren($incident['issue_id']); $issues[$state]['nb_services'] = $issues[$state]['nb_services'] + 1; $issues[$state]['total_impacts'] = $issues[$state]['total_impacts'] + count($childIncidents); } } $hosts = \CentreonRealtime\Models\Host::getList(); $configurationobjects = array(); $configurationobjects['pending']['nb_hosts'] = 0; $configurationobjects['unreachable']['nb_hosts'] = 0; foreach ($hosts as $host) { $totalHosts++; $state = $arrayStatusHost[$host['state']]; if ($host['state'] == "4") { $configurationobjects['pending']['nb_hosts']++; $hostsTemp = $host; $duration = Datetime::humanReadable(time() - $host['last_update'], Datetime::PRECISION_FORMAT, 2); $hostsTemp['icon'] = HostRepositoryConfig::getIconImagePath($host['host_id']); $hostsTemp['url'] = $router->getPathFor('/centreon-realtime/host/' . $host['host_id']); $hostsTemp['since'] = $duration; $hostsTemp['state'] = $state; $configurationobjects['pending']['objects']['hosts'][] = HostRepository::formatDataForHeader($hostsTemp); } else { if ($host['state'] == "3") { $configurationobjects['unreachable']['nb_hosts']++; $hostsTemp = $host; $duration = Datetime::humanReadable(time() - $host['last_update'], Datetime::PRECISION_FORMAT, 2); $hostsTemp['icon'] = HostRepositoryConfig::getIconImagePath($host['host_id']); $hostsTemp['url'] = $router->getPathFor('/centreon-realtime/host/' . $host['host_id']); $hostsTemp['since'] = $duration; $hostsTemp['state'] = $state; $configurationobjects['unreachable']['objects']['hosts'][] = HostRepository::formatDataForHeader($hostsTemp); } } } $services = \CentreonRealtime\Models\Service::getList(); $configurationobjects['pending']['nb_services'] = 0; $configurationobjects['unknown']['nb_services'] = 0; foreach ($services as $service) { $totalServices++; $state = $arrayStatusService[$service['state']]; if ($service['state'] == "4") { $configurationobjects['pending']['nb_services']++; $serviceTemp = $service; $duration = Datetime::humanReadable(time() - $service['last_update'], Datetime::PRECISION_FORMAT, 2); $serviceTemp['icon'] = ServiceRepositoryConfig::getIconImage($service['service_id']); $serviceTemp['url'] = $router->getPathFor('/centreon-realtime/service/' . $service['service_id']); $serviceTemp['since'] = $duration; $serviceTemp['state'] = $state; $configurationobjects['pending']['objects']['services'][] = ServiceRepository::formatDataForHeader($serviceTemp); } else { if ($service['state'] == "3") { $configurationobjects['unknown']['nb_services']++; $serviceTemp = $service; $duration = Datetime::humanReadable(time() - $service['last_update'], Datetime::PRECISION_FORMAT, 2); $serviceTemp['icon'] = ServiceRepositoryConfig::getIconImage($service['service_id']); $serviceTemp['url'] = $router->getPathFor('/centreon-realtime/service/' . $service['service_id']); $serviceTemp['since'] = $duration; $serviceTemp['state'] = $state; $configurationobjects['unknown']['objects']['services'][] = ServiceRepository::formatDataForHeader($serviceTemp); } } } //Get pollers infos $pollersStatus = PollerRepository::pollerStatus(); $pollers = array(); $pollers['stopped']['nb_pollers'] = 0; $pollers['unreachable']['nb_pollers'] = 0; foreach ($pollersStatus as $poller) { if ($poller['running'] != "1") { $pollers['stopped']['nb_pollers']++; $pollerTemp = PollerRepository::formatDataForHeader($poller); $duration = Datetime::humanReadable(time() - $poller['last_alive'], Datetime::PRECISION_FORMAT, 2); $pollerTemp['url'] = $router->getPathFor('/centreon-configuration/poller/' . $poller['instance_id']); $pollerTemp['since'] = $duration; $pollers['stopped']['objects'][] = $pollerTemp; } else { if ($poller['disconnect'] == "1") { $pollers['unreachable']['nb_pollers']++; $pollerTemp = PollerRepository::formatDataForHeader($poller); $duration = Datetime::humanReadable(time() - $poller['last_alive'], Datetime::PRECISION_FORMAT, 2); $pollerTemp['url'] = $router->getPathFor('/centreon-configuration/poller/' . $poller['instance_id']); $pollerTemp['since'] = $duration; $pollers['unreachable']['objects'][] = $pollerTemp; } } } $event->addStatus('issues', $issues); $states = $event->getStatus('states'); if (empty($states)) { $states = array(); } $states['configurationObjects'] = $configurationobjects; $states['pollers'] = $pollers; $event->addStatus('states', $states); $event->addStatus('totalHosts', $totalHosts); $event->addStatus('totalServices', $totalServices); }