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; }
private function process_resource_filter_status() { $resources_to_keep = array(); $model = new LatestResourceStatus(); $resource_status = $model->getgroupby("resource_id"); //load downtime $downtime_model = new Downtime(); $params = array("start_time" => time(), "end_time" => time()); $downtimes = $downtime_model->getindex($params); $model = new Resource(); $resources = $model->getindex(); foreach ($resources as $rid => $r) { if (!isset($resource_status[$rid])) { //if status not found, then treat it as UNKNOWN $status_id = 4; //unknown } else { $rs = $resource_status[$rid]; $status_id = $rs[0]->status_id; } //consider status to be down $downtime = @$downtimes[(int) $rid]; if ($downtime !== null) { $status_id = 99; } if ($this->ison("status", $status_id)) { //if(isset($_REQUEST["status_".$status_id])) { if (!in_array($rid, $resources_to_keep)) { $resources_to_keep[] = $rid; } } } return $resources_to_keep; }
public function load() { parent::load(); $model = new VirtualOrganization(); $vos = $model->getindex(); $scmodel = new SupportCenters(); $scs = $scmodel->getindex(); if (isset($_REQUEST["summary_attrs_showmember_resource"])) { $this->view->resource_ownerships = array(); $ownmodel = new VOOwnedResources(); $resource_ownerships = $ownmodel->getindex(); $rmodel = new Resource(); $rs = $rmodel->getindex(); foreach ($this->vo_ids as $vo_id) { $resource_list = array(); if (isset($resource_ownerships[$vo_id])) { foreach ($resource_ownerships[$vo_id] as $resource_ownership) { $resource = $rs[$resource_ownership->resource_id][0]; $resource_list[$resource->id] = $resource; } } $this->view->resource_ownerships[$vo_id] = $resource_list; } } if (isset($_REQUEST["summary_attrs_showfield_of_science"])) { $vofsmodel = new VOFieldOfScience(); $vofss = $vofsmodel->getindex(); $this->view->field_of_science = array(); foreach ($this->vo_ids as $vo_id) { $fs_for_vo = @$vofss[$vo_id]; if ($fs_for_vo !== null) { $ranks = array(); foreach ($fs_for_vo as $fs) { $name = $fs->name; $rank_id = $fs->rank_id; if (!isset($ranks[$rank_id])) { $ranks[$rank_id] = array(); } $ranks[$rank_id][$name] = $fs; } ksort($ranks); $this->view->field_of_science[$vo_id] = $ranks; } } } if (isset($_REQUEST["summary_attrs_showreporting_group"])) { $reportmodel = new VOReport(); $reports = $reportmodel->getindex(); $fqanmodel = new VOReportFQAN(); $fqans = $fqanmodel->getindex(); $contactmodel = new VOReportContact(); $contacts = $contactmodel->getindex(); $this->view->reports = array(); foreach ($this->vo_ids as $vo_id) { $this->view->reports[$vo_id] = array(); if (isset($reports[$vo_id])) { foreach ($reports[$vo_id] as $report) { $report->fqans = @$fqans[$report->id]; $report->contacts = @$contacts[$report->id]; $this->view->reports[$vo_id][] = $report; } } } } if (isset($_REQUEST["summary_attrs_showparent_vo"])) { $model = new VOVO(); $this->view->vovo = $model->getindex(); } if (isset($_REQUEST["summary_attrs_showcontact"])) { $this->view->contacts = array(); $cmodel = new VOContact(); $contacts = $cmodel->getindex(); //group by contact_type_id foreach ($this->vo_ids as $vo_id) { $types = array(); if (isset($contacts[$vo_id])) { foreach ($contacts[$vo_id] as $contact) { if (!isset($types[$contact->contact_type])) { $types[$contact->contact_type] = array(); } $types[$contact->contact_type][] = $contact; } $this->view->contacts[$vo_id] = $types; } } } if (isset($_REQUEST["summary_attrs_showoasis"])) { $model = new VOOasisUser(); $oasis_managers = $model->getindex($this->vo_ids); $grouped = array(); foreach ($oasis_managers as $vo_id => $managers) { if (!isset($grouped[$vo_id])) { $grouped[$vo_id] = array(); } //group by contact_id foreach ($managers as $manager) { $manager = (array) $manager; $contactid = $manager["contact_id"]; if (!isset($grouped[$vo_id][$contactid])) { $manager["dns"] = array($manager["dn"]); $grouped[$vo_id][$contactid] = $manager; } else { $grouped[$vo_id][$contactid]["dns"][] = $manager["dn"]; } } } $this->view->oasis_managers = $grouped; } $this->view->vos = array(); foreach ($this->vo_ids as $vo_id) { $vo = $vos[$vo_id][0]; //lookup support center $vo->sc = $scs[$vo->sc_id][0]; $this->view->vos[$vo_id] = $vo; //parse oasis_repo_urls if (!is_null($vo->oasis_repo_urls)) { $vo->oasis_repo_urls = explode("|", $vo->oasis_repo_urls, -1); } } $this->setpagetitle(self::default_title()); }