コード例 #1
0
 private function getDowntimesForService($downtimes, $service_id)
 {
     $downtime_service_model = new DowntimeService();
     $downtime_service = $downtime_service_model->get();
     $downtime_forservice = array();
     foreach ($downtimes as $downtime) {
         $id = $downtime->id;
         foreach ($downtime_service as $service) {
             if ($service->resource_downtime_id == $id) {
                 $downtime_forservice[$id] = $downtime;
             }
         }
     }
     return $downtime_forservice;
 }
コード例 #2
0
 function formatInfo($downtime_recs)
 {
     if ($downtime_recs === null) {
         return array();
     }
     $downtimes = array();
     $resource_model = new Resource();
     $resources = $resource_model->getindex();
     $downtime_service_model = new DowntimeService();
     $downtime_services = $downtime_service_model->get();
     $model = new ResourceGroup();
     $rg_info = $model->getindex();
     $model = new Service();
     $service_info = $model->getindex();
     $model = new DowntimeClass();
     $downtime_class = $model->getindex();
     $model = new DowntimeSeverity();
     $downtime_severity = $model->getindex();
     $model = new DN();
     $dns = $model->getindex();
     //include disabled
     $model = new Contact();
     $contacts = $model->getindex();
     //pull all resource ids that we are interested in
     $resource_ids = array();
     foreach ($this->rgs as $rgid => $rg) {
         foreach ($rg as $rid => $resource) {
             $resource_ids[] = $rid;
         }
     }
     foreach ($downtime_recs as $downtime) {
         if (in_array($downtime->resource_id, $resource_ids)) {
             //only show event that we have pulled resource for
             $resource = $resources[$downtime->resource_id];
             $resource_name = $resource[0]->name;
             $resource_fqdn = $resource[0]->fqdn;
             $rg_id = $resource[0]->resource_group_id;
             $rg_name = $rg_info[$resource[0]->resource_group_id][0]->name;
             if ($resource_name !== null) {
                 $start = date(config()->date_format_full, $downtime->unix_start_time);
                 $end = date(config()->date_format_full, $downtime->unix_end_time);
                 $timestamp = date(config()->date_format_full, $downtime->unix_timestamp);
                 //get affected services
                 $affected_services = array();
                 foreach ($downtime_services as $service) {
                     if ($service->resource_downtime_id == $downtime->id) {
                         $info = $service_info[$service->service_id][0];
                         $affected_services[] = $info;
                     }
                 }
                 $desc = $downtime->downtime_summary;
                 //slog($desc);
                 $severity = $downtime_severity[$downtime->downtime_severity_id][0]->name;
                 $class = $downtime_class[$downtime->downtime_class_id][0]->name;
                 if (isset($dns[$downtime->dn_id])) {
                     $dn = $dns[$downtime->dn_id][0]->dn_string;
                     $contact_id = $dns[$downtime->dn_id][0]->contact_id;
                     $contact_name = $contacts[$contact_id][0]->name;
                 } else {
                     error_log("can't find dn with id " . $downtime->dn_id . " on dns list");
                 }
                 $downtimes[] = array("id" => $downtime->id, "name" => $resource_name, "fqdn" => $resource_fqdn, "rg_name" => $rg_name, "rg_id" => $rg_id, "resource_id" => $downtime->resource_id, "desc" => $desc, "severity" => $severity, "class" => $class, "services" => $affected_services, "unix_start_time" => $downtime->unix_start_time, "unix_end_time" => $downtime->unix_end_time, "start_time" => $start, "dn" => $dn, "timestamp" => $timestamp, "contact_name" => $contact_name, "end_time" => $end);
             }
         }
     }
     return $downtimes;
 }