示例#1
0
 /**
  * Obtener el listado de paradas programadas.
  *
  * @return mixed
  */
 public function getScheduledDowntimes()
 {
     $fields = array('author', 'comment', 'duration', 'host_alias', 'host_name', 'is_service', 'service_display_name', 'start_time', 'end_time');
     if ($this->isAllHeaders() === false) {
         $filter = array('GET downtimes', 'ResponseHeader: fixed16', 'Columns: ' . implode(' ', $fields), 'ColumnHeaders: off', 'OutputFormat: json');
         $dataQuery = implode("\n", $filter) . "\n\n";
     } else {
         $dataQuery = "GET downtimes\nColumnHeaders: off\nOutputFormat: json\n\n";
     }
     $data = $this->getJsonFromSocket($dataQuery);
     $downtimes = array();
     foreach ($data as $downtime) {
         $Downtime = new Downtime();
         $Downtime->setAuthor($downtime[0]);
         $Downtime->setComment($downtime[1]);
         $Downtime->setDuration($downtime[2]);
         $Downtime->setHostAlias($downtime[3]);
         $Downtime->setHostName($downtime[4]);
         $Downtime->setIsService($downtime[5]);
         $Downtime->setServiceDisplayName($downtime[6]);
         $Downtime->setStartTime($downtime[7]);
         $Downtime->setEndTime($downtime[8]);
         $Downtime->setBackendAlias($this->backend->getAlias());
         $downtimes[] = $Downtime;
     }
     return $this->isAllHeaders() === false ? $downtimes : $data;
 }
示例#2
0
 /**
  * Devuelve los eventos programados
  *
  * @return array
  */
 public function getScheduledDowntimes()
 {
     // Reutilizar la caché
     if (count($this->downtimes) > 0) {
         return $this->downtimes;
     }
     $params = array('output' => array('active_since', 'active_till', 'description'), 'selectHosts' => 'extend', 'selectTimeperiods' => 'extend');
     $maintenances = $this->Zabbix->maintenanceGet($params);
     foreach ($maintenances as $maintenance) {
         $this->setHostsInMaintenance($maintenance->hosts);
         if (time() <= $maintenance->active_till) {
             $period = $this->getTimePeriod($maintenance->timeperiods);
             if ($period !== false) {
                 $Downtime = new Downtime();
                 $Downtime->setAuthor('Zabbix');
                 $Downtime->setComment($maintenance->description);
                 $Downtime->setHostName($this->getHostsForMaintenance($maintenance->maintenanceid));
                 $Downtime->setServiceDisplayName('-');
                 $Downtime->setStartTime($period['start']);
                 $Downtime->setEndTime($period['end']);
                 $Downtime->setBackendAlias($this->backend->getAlias());
                 $this->downtimes[] = $Downtime;
             }
         }
     }
     return $this->downtimes;
 }