public function load()
 {
     parent::load();
     $this->view->rgs = $this->rgs;
     $model = new ResourceGroup();
     $this->view->resource_groups = $model->getindex();
     //convert old current_status_attrs_spe format to the new
     if (isset($_REQUEST["current_status_attrs_spe"]) && !isset($_REQUEST["current_status_attrs_spe_sel"])) {
         $ids = array();
         foreach ($_REQUEST as $key => $value) {
             if (strpos($key, "current_status_attrs_spe_") === 0) {
                 $id = substr($key, strlen("current_status_attrs_spe_"));
                 $ids[] = $id;
             }
         }
         $_REQUEST["current_status_attrs_spe_sel"] = $ids;
     }
     //load current status cache for all requested resources
     $this->view->cache = array();
     foreach ($this->view->rgs as $rgid => $rg) {
         foreach ($rg as $rid => $resource) {
             $cache_filename_template = config()->current_resource_status_xml_cache;
             $cache_filename = str_replace("<ResourceID>", $rid, $cache_filename_template);
             if (file_exists($cache_filename)) {
                 $cache_xml = file_get_contents($cache_filename);
                 $this->view->cache[$rid] = new SimpleXMLElement($cache_xml);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function load()
 {
     parent::load();
     $model = new ResourceGroup();
     $resource_groups = $model->getindex();
     $legend = false;
     list($urlbase, $sub_title, $ylabel) = $this->map();
     //$this->load_daterangequery();
     $start_time = date("Y-m-d h:i:s", $this->view->start_time);
     $end_time = date("Y-m-d h:i:s", $this->view->end_time);
     $resource_names = array();
     foreach ($this->rgs as $rgid => $rg) {
         $resource_group = $resource_groups[$rgid][0];
         //add resource group name as resource name as well
         $resource_names[] = $resource_group->name;
         //add resource names (if it differes from the resource group name)
         foreach ($rg as $rid => $resource) {
             if ($resource->name != $resource_group->name) {
                 $resource_names[] = $resource->name;
             }
         }
     }
     $this->view->url = $urlbase . "?facility=" . implode("|", $resource_names) . "&title=&ylabel={$ylabel}&starttime={$start_time}&endtime={$end_time}";
     if (!$legend) {
         $this->view->url .= "&legend=False";
     }
     $this->view->resource_names = implode(" / ", $resource_names);
     $this->setpagetitle($this->default_title() . " <small>" . $sub_title . "</small>");
 }
Ejemplo n.º 3
0
 public function load()
 {
     parent::load();
     $this->view->rgs = $this->rgs;
     $model = new ResourceGroup();
     $this->view->resource_groups = $model->getindex();
     //load current status cache for all requested resources
     $this->view->cache = array();
     /*
     foreach($this->view->rgs as $rgid=>$rg) {
         foreach($rg as $rid=>$resource) {
             $cache_filename_template = config()->current_resource_status_xml_cache;
             $cache_filename = str_replace("<ResourceID>", $rid, $cache_filename_template); 
             if(file_exists($cache_filename)) {
                 $cache_xml = file_get_contents($cache_filename);
                 $this->view->cache[$rid] = new SimpleXMLElement($cache_xml);
             }
         }
     }
     */
     $this->view->cache[383] = array("event1" => array("key1" => "value1", "key2" => "value2"));
 }
Ejemplo n.º 4
0
 public function load()
 {
     parent::load();
     $this->view->rgs = $this->rgs;
     $model = new ResourceGroup();
     $this->view->resource_groups = $model->getindex();
     $service_type_model = new Service();
     $this->view->service_info = $service_type_model->getindex();
     ///////////////////////////////////////////////////////////////////////
     // Load graph inforamtion
     $this->view->services = array();
     foreach ($this->rgs as $rgid => $rg) {
         foreach ($rg as $rid => $resource) {
             //pull A&R history
             $model = new ServiceAR();
             $params["start_time"] = $this->view->start_time;
             $params["end_time"] = $this->view->end_time;
             $params["resource_ids"] = array($rid);
             $this->view->services[$rid] = $model->getgroupby("service_id", $params);
         }
     }
     $this->setpagetitle(self::default_title());
 }
Ejemplo n.º 5
0
 public function get()
 {
     $voms_info = array();
     $bdii_xml = file_get_contents(config()->bdii_xml);
     $bdiis = new SimpleXMLElement($bdii_xml);
     //match RG names with OIM RG name
     $model = new ResourceGroup();
     $rgs = $model->getindex();
     $ret = array();
     foreach ($rgs as $rg) {
         $rg = $rg[0];
         $name = $rg->name;
         $rgid = $rg->id;
         foreach ($bdiis as $bdii) {
             $group_name = (string) $bdii->GroupName;
             if ($name == $group_name) {
                 $rg->resources = $this->processXML($bdii);
             }
         }
         $ret[$rgid] = $rg;
     }
     return $ret;
 }
 public function load()
 {
     parent::load();
     //$this->view->ruler = $this->generateRuler($this->view->start_time, $this->view->end_time);
     $this->view->rgs = $this->rgs;
     //message("success", "Hello there");
     $model = new ResourceGroup();
     $this->view->resource_groups = $model->getindex();
     $resource_model = new Resource();
     $resource_service_model = new ResourceServices();
     $this->view->resources = array();
     $this->view->services = array();
     foreach ($this->rgs as $rg) {
         foreach ($rg as $rid => $resource) {
             //load resource detail
             $recs = $resource_model->get(array("resource_id" => $rid));
             $this->view->resources[$rid] = $recs[0];
             //load service info
             $params = array("resource_id" => $rid);
             $this->view->services[$rid] = $resource_service_model->get($params);
         }
     }
 }
Ejemplo n.º 7
0
 private function process_rg_filter_gipstatus()
 {
     $rgs_to_keep = array();
     $model = new LDIF();
     $summary = $model->getValidationSummary();
     $model = new ResourceGroup();
     $rgs = $model->getindex();
     foreach ($rgs as $rg_id => $rg) {
         $rg_name = $rg[0]->name;
         //search for the gip status for this resource group
         $found = false;
         $overallstatus = "UNKNOWN";
         //if not found, treat it as unknown
         if (isset($summary[$rg_name])) {
             $overallstatus = (string) $summary[$rg_name]->Result;
             //rename it to the old naming (for backward compatibility)
             switch ($overallstatus) {
                 case "PASS":
                     $overallstatus = "OK";
                     break;
                 case "CRIT":
                     $overallstatus = "FAIL";
                     break;
                 default:
                     $overallstatus = "UNKNOWN";
             }
         }
         //has user selected this resource status?
         if ($this->ison("gipstatus", $overallstatus)) {
             //if(isset($_REQUEST["gipstatus_".$overallstatus])) {
             if (!in_array($rg_id, $rgs_to_keep)) {
                 $rgs_to_keep[] = $rg_id;
             }
         }
     }
     return $rgs_to_keep;
 }
Ejemplo n.º 8
0
 public function load()
 {
     parent::load();
     $model = new LDIF();
     $gip = $model->getValidationSummary();
     $cemonbdii = $model->getBdii();
     $wlcgstatus = array();
     if (isset($_REQUEST["gip_status_attrs_showwlcgstatus"])) {
         $wlcgstatus_raw = $model->getWLCGStatus();
         $this->view->wlcgstatus_updatetime = $wlcgstatus_raw["updatetime"];
         $wlcgstatus = array();
         foreach ($wlcgstatus_raw as $rgid => $status_lists) {
             //don't process if it's not requested
             if (!isset($this->rgs[$rgid])) {
                 continue;
             }
             $group = array();
             foreach ($status_lists as $hostname => $statuses) {
                 $group_status = "OK";
                 foreach ($statuses as $status) {
                     if ($status->Status != "OK") {
                         $group_status = "CRITICAL";
                     }
                 }
                 $group[$hostname] = array($group_status, $statuses);
             }
             $wlcgstatus[$rgid] = $group;
         }
     }
     $model = new ResourceGroup();
     $resource_groups = $model->getindex();
     //merge those xmls
     $this->view->resource_groups = array();
     $this->view->resource_details = array();
     foreach ($this->rgs as $rgid => $resources) {
         $tests = array();
         $resource_group = $resource_groups[$rgid][0];
         $gipstatus = null;
         if (isset($gip[$resource_group->name])) {
             $gipstatus = $gip[$resource_group->name];
         }
         if (isset($_REQUEST["gip_status_attrs_showresource"])) {
             //gather resource details
             foreach ($resources as $rid => $resource) {
                 $details = array();
                 if (isset($_REQUEST["gip_status_attrs_showcemondata"])) {
                     //search cemon bdii data
                     $rawdata = array();
                     foreach ($cemonbdii->resource as $cemon_resource) {
                         if ($cemon_resource->name == $resource->name) {
                             $details["cemon_raw_data"] = $cemon_resource;
                             break;
                         }
                     }
                 }
                 //TODO - add code to gather more resource details here
                 $this->view->resource_details[$rid] = $details;
             }
         }
         //put everything together
         $this->view->resource_groups[$rgid] = array("name" => $resource_group->name, "gridtype" => $resource_group->grid_type, "resources" => $resources, "gipstatus" => $gipstatus, "wlcgstatus" => @$wlcgstatus[$rgid]);
     }
     $this->setpagetitle(self::default_title());
 }
Ejemplo n.º 9
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;
 }
Ejemplo n.º 10
0
 public function load()
 {
     parent::load();
     $this->view->rgs = $this->rgs;
     $model = new ResourceGroup();
     $this->view->resource_groups = $model->getindex();
     $service_type_model = new Service();
     $this->view->services = $service_type_model->getindex();
     //load AR history
     $model = new ServiceAR();
     $params = array();
     $params["start_time"] = $this->view->start_time;
     $params["end_time"] = $this->view->end_time;
     //get list of resource ids that we are interested in
     $resource_ids = array();
     foreach ($this->rgs as $rgid => $rg) {
         foreach ($rg as $rid => $resource) {
             $resource_ids[] = $rid;
         }
     }
     //group by resource/service_id
     $ar_resource_service = array();
     if (!empty($resource_ids)) {
         $params["resource_ids"] = $resource_ids;
         $ar = $model->get($params);
         foreach ($ar as $a) {
             $r_id = (int) $a->resource_id;
             if (!isset($ar_resource_service[$r_id])) {
                 $ar_resource_service[$r_id] = array();
             }
             $service_id = (int) $a->service_id;
             if (!isset($ar_resource_service[$r_id][$service_id])) {
                 $ar_resource_service[$r_id][$service_id] = array();
             }
             $ar_resource_service[$r_id][$service_id][] = $a;
         }
     }
     $data = array();
     foreach ($ar_resource_service as $rid => $resource) {
         //filter by resource_id
         if (!in_array($rid, $resource_ids)) {
             continue;
         }
         $data[$rid] = array();
         foreach ($resource as $service_id => $service) {
             $count = 0;
             $a_total = 0;
             $r_total = 0;
             foreach ($service as $rec) {
                 $count++;
                 $a_total += (double) $rec->availability;
                 $r_total += (double) $rec->reliability;
             }
             //store data
             if ($count != 0) {
                 $data[$rid][$service_id] = array("availability" => $a_total / $count, "reliability" => $r_total / $count);
             }
         }
     }
     //sort data
     if (isset($_REQUEST["sort"])) {
         $dirty_sort = $_REQUEST["sort"];
         switch ($dirty_sort) {
             case "resource_name":
                 break;
             case "a":
                 uasort($data, "cmp_availability");
                 break;
             case "r":
                 uasort($data, "cmp_reliability");
                 break;
         }
     }
     $this->view->data = $data;
     $this->setpagetitle(self::default_title());
 }
Ejemplo n.º 11
0
 public function load()
 {
     parent::load();
     $dirty_type = @$_REQUEST["bdiitree_type"];
     switch ($dirty_type) {
         default:
         case "total_jobs":
             $sub_title = "Number of Jobs";
             $key = "TotalJobs";
             break;
         case "free_cpus":
             $sub_title = "Number of Free CPUs";
             $key = "FreeCPUs";
             break;
         case "estimated_response_time":
             $sub_title = "Estimated Response Time";
             $key = "EstimatedResponseTime";
             break;
         case "waiting_jobs":
             $sub_title = "Number of Waiting Jobs";
             $key = "WaitingJobs";
             break;
         case "running_jobs":
             $sub_title = "Number of Running Jobs";
             $key = "RunningJobs";
             break;
         case "free_job_slots":
             $sub_title = "Number of Free Job Slots";
             $key = "FreeJobSlots";
             break;
     }
     $model = new BDII();
     $rgs = $model->get();
     $model = new ResourceGroup();
     $oim_rgs = $model->getindex();
     $this->view->total_area = 0;
     $this->view->key = $key;
     $this->view->sub_title = $sub_title;
     $this->view->rgs = array();
     foreach ($this->rgs as $rgid => $rg) {
         //filter ones that passed mysql query for resource group
         if (isset($rgs[$rgid])) {
             $bdii_rg = $rgs[$rgid];
             $rg_view = array();
             //has resources information?
             if (isset($bdii_rg->resources)) {
                 //for each resource..
                 foreach ($bdii_rg->resources as $rid => $resource) {
                     //filter ones that passed mysql query for resource
                     if (isset($rg[$rid])) {
                         //aggregate data for each services
                         $agg = new Aggregator();
                         $num = 0;
                         $services = $resource["bdii"]->Services;
                         foreach ($services as $service) {
                             $service = $service->Service;
                             $servicename = $service->ServiceName;
                             //$serviceuri = $service->ServiceUri;
                             //for each queue
                             if ($service->Queues === null) {
                                 continue;
                             }
                             foreach ($service->Queues as $queue) {
                                 $queue = $queue->Queue;
                                 $state = $queue->State;
                                 $agg->sum("TotalJobs", $state->GlueCEStateTotalJobs);
                                 $agg->sum("FreeCPUs", $state->GlueCEStateFreeCPUs);
                                 $agg->sum("EstimatedResponseTime", $state->GlueCEStateEstimatedResponseTime);
                                 $agg->sum("WaitingJobs", $state->GlueCEStateWaitingJobs);
                                 $agg->sum("RunningJobs", $state->GlueCEStateRunningJobs);
                                 $agg->sum("FreeJobSlots", $state->GlueCEStateFreeJobSlots);
                                 ++$num;
                             }
                         }
                         if ($num > 0) {
                             $rg_view[$rid] = array("info" => $rg[$rid], "agg" => $agg);
                             $this->view->total_area += $agg->get($key);
                         }
                     }
                 }
             }
             $this->view->rgs[$rgid] = array("info" => $oim_rgs[$rgid][0], "resources" => $rg_view);
             /*
                             $bdii = $rg->bdii;
                             $this->view->rgs[$rgid] = $bdii;
                             foreach($bdii->aggregates as $aggregate) {
                             }
             */
         } else {
             elog("Can't find information for resource group {$rgid}");
         }
     }
     $this->setpagetitle($this->default_title() . " - " . $sub_title);
 }