Beispiel #1
0
 /**
  * @return mixed
  */
 public function getHostsProblems()
 {
     // Obtenemos los bloques que corresponden al estado de los hosts y servicios
     preg_match_all('/hoststatus {.*}/isU', $this->fileData, $hostsData);
     $events = array();
     foreach ($this->getItemsArray($hostsData) as $event) {
         $Event = new Host();
         $Event->setAcknowledged($event['problem_has_been_acknowledged']);
         $Event->setActiveChecksEnabled($event['active_checks_enabled']);
         $Event->setCheckCommand($event['check_command']);
         $Event->setCurrentAttempt($event['current_attempt']);
         $Event->setDisplayName($event['host_name']);
         $Event->setHostAlias($event['host_name']);
         $Event->setHostDisplayName($event['host_name']);
         $Event->setFlapping($event['is_flapping']);
         $Event->setLastCheck($event['last_check']);
         $Event->setLastHardState($event['last_hard_state']);
         $Event->setLastHardStateChange($event['last_hard_state_change']);
         $Event->setLastTimeDown($event['last_time_down']);
         $Event->setLastTimeUp($event['last_time_up']);
         $Event->setLastTimeUnreachable($event['last_time_unreachable']);
         $Event->setPluginOutput($event['plugin_output']);
         $Event->setState($event['current_state']);
         $Event->setStateType($event['state_type']);
         $Event->setScheduledDowntimeDepth($event['scheduled_downtime_depth']);
         $Event->setMaxCheckAttempts($event['max_attempts']);
         $Event->setNotificationsEnabled($event['notifications_enabled']);
         $Event->setBackendAlias($this->backend->getAlias());
         $Event->setBackendUrl($this->backend->getUrl());
         $Event->setBackendLevel($this->backend->getLevel());
         $events[] = $Event;
     }
     return $events;
 }
 /**
  * Obtener el listado de hosts
  *
  * @return mixed
  */
 public function getHostsProblems()
 {
     $fields = array('alias', 'state', 'check_command', 'display_name', 'current_attempt', 'max_check_attempts', 'is_flapping', 'plugin_output', 'acknowledged', 'active_checks_enabled', 'last_hard_state', 'scheduled_downtime_depth', 'last_check', 'last_hard_state_change', 'last_time_down', 'last_time_unreachable', 'last_time_up', 'host_alias', 'state_type');
     $data = $this->getJsonFromSocket($this->getHostsFilter($fields));
     $events = array();
     foreach ($data as $event) {
         $Event = new Host();
         $Event->setAlias($event[0]);
         $Event->setState($event[1]);
         $Event->setCheckCommand($event[2]);
         $Event->setDisplayName($event[3]);
         $Event->setCurrentAttempt($event[4]);
         $Event->setMaxCheckAttempts($event[5]);
         $Event->setFlapping($event[6]);
         $Event->setPluginOutput($event[7]);
         $Event->setAcknowledged($event[8]);
         $Event->setActiveChecksEnabled($event[9]);
         $Event->setLastHardState($event[10]);
         $Event->setScheduledDowntimeDepth($event[11]);
         $Event->setLastCheck($event[12]);
         $Event->setLastHardStateChange($event[13]);
         $Event->setLastTimeDown($event[14]);
         $Event->setLastTimeUnreachable($event[15]);
         $Event->setLastTimeUp($event[16]);
         $Event->setHostAlias($event[17]);
         $Event->setStateType($event[18]);
         $Event->setBackendAlias($this->backend->getAlias());
         $Event->setBackendUrl($this->backend->getUrl());
         $Event->setBackendLevel($this->backend->getLevel());
         $events[] = $Event;
     }
     return $this->isAllHeaders() === false ? $events : $data;
 }