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;
     $this->view->error = null;
     $resource_group_model = new ResourceGroup();
     $resource_groups = $resource_group_model->getgroupby("name");
     list($host, $port, $base, $aggregator) = $this->processQuery();
     if ($host == null || $port == null || $base == null || $aggregator == null) {
         $this->view->error = "Invalid parameters.";
     } else {
         $conn = ldap_connect($host, $port);
         $results = ldap_search($conn, $base, $aggregator->filter());
         $entries = ldap_get_entries($conn, $results);
         $detail_groups = array();
         //group by resource group id and contatins aggregated object
         $first = true;
         foreach ($entries as $entry) {
             if ($first) {
                 $first = false;
                 $count = $entry;
                 //TODO - should I do something with count object?
                 continue;
             }
             $dn = $entry["dn"];
             //parse out sitename
             $token = "Mds-Vo-name=";
             $token_len = strlen($token);
             $begin = strpos($dn, $token);
             $len = strpos($dn, ",", $begin) - $begin;
             $sitename = substr($dn, $begin + $token_len, $len - $token_len);
             if (isset($resource_groups[$sitename])) {
                 $rgid = (int) $resource_groups[$sitename][0]->id;
                 $rg_info = $resource_groups[$sitename][0];
                 $entry_id = substr($dn, 0, $begin - 1);
                 if (!isset($detail_groups[$rgid])) {
                     //new resource group
                     $detail_groups[$rgid] = $aggregator->newobject($sitename);
                 }
                 $detail_groups[$rgid]->process($entry, $entry_id);
             } else {
                 //echo "not osg site name: $sitename";
             }
         }
         $this->view->detail_groups = $detail_groups;
         $this->view->headers = $aggregator->headers();
         $this->view->resource_groups = $resource_group_model->getgroupby("id");
     }
     $this->setpagetitle($this->default_title());
     $this->view->has_subscribe_igoogle = false;
     $this->view->has_subscribe_uwa = false;
     $this->view->has_subscribe_mobile = true;
     $this->view->has_subscribe_xml = false;
     $this->view->has_subscribe_csv = false;
 }
Ejemplo n.º 4
0
 public function load()
 {
     parent::load();
     $model = new Downtime();
     $downtimes = $model->get();
     $past = array();
     $current = array();
     $future = array();
     foreach ($downtimes as $downtime) {
         $id = $downtime->id;
         if ($downtime->unix_end_time < time()) {
             if (isset($_REQUEST["downtime_attrs_showpast"])) {
                 switch ($_REQUEST["downtime_attrs_showpast"]) {
                     case "":
                         break;
                         //none..
                     //none..
                     default:
                         $days = (int) $_REQUEST["downtime_attrs_showpast"];
                         if ($downtime->unix_end_time < time() - 3600 * 24 * $days) {
                             break;
                             //too old
                         }
                     case "all":
                         $past[$id] = $downtime;
                 }
             }
         } else {
             if ($downtime->unix_start_time > time()) {
                 $future[$id] = $downtime;
             } else {
                 $current[$id] = $downtime;
             }
         }
     }
     $this->view->past_downtimes = $this->formatInfo($past);
     $this->view->current_downtimes = $this->formatInfo($current);
     $this->view->future_downtimes = $this->formatInfo($future);
     $this->setpagetitle(self::default_title());
 }
Ejemplo n.º 5
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.º 6
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());
 }
 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.º 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
 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.º 10
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);
 }
Ejemplo n.º 11
0
 public function load()
 {
     parent::load();
     $this->view->rgs = $this->rgs;
     //pull commonly needed information
     $gridtype_model = new GridTypes();
     $this->view->gridtypes = $gridtype_model->getindex();
     $model = new ResourceGroup();
     $this->view->resourcegroups = $model->getgroupby("id");
     ///////////////////////////////////////////////////////////////////////////////////////////
     //pull other optional stuff
     if (isset($_REQUEST["summary_attrs_showservice"])) {
         $servicetype_model = new Service();
         $this->view->servicetypes = $servicetype_model->getindex();
         $resourceservice_model = new ServiceByResourceID();
         $this->view->resource_services = $resourceservice_model->getindex();
         //load details (all of them for now..) and attach it to resource_services
         $detail_model = new ResourceServiceDetail();
         $resource_service_details = $detail_model->get();
         foreach ($this->view->resource_services as $rid => $services) {
             foreach ($services as $service) {
                 $service->details = array();
                 //search for details for this service
                 foreach ($resource_service_details as $detail) {
                     if ($detail->resource_id == $rid && $detail->service_id == $service->service_id) {
                         $service->details[$detail->key] = $detail->value;
                     }
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showrsvstatus"])) {
         $model = new LatestResourceStatus();
         $this->view->resource_status = $model->getgroupby("resource_id");
         $downtime_model = new Downtime();
         $this->view->downtime = $downtime_model->getindex(array("start_time" => time(), "end_time" => time()));
     }
     if (isset($_REQUEST["summary_attrs_showgipstatus"])) {
         $model = new LDIF();
         $this->view->gipstatus = $model->getValidationSummary();
     }
     if (isset($_REQUEST["summary_attrs_showvomembership"])) {
         $cache_filename = config()->vomatrix_xml_cache;
         $cache_xml = file_get_contents($cache_filename);
         $vocache = new SimpleXMLElement($cache_xml);
         $resourcegrouped = $vocache->ResourceGrouped[0];
         $this->view->vos_supported = array();
         $this->view->vos_errors = array();
         foreach ($resourcegrouped as $resource) {
             $attr = $resource->attributes();
             $resource_id = (int) $attr->id;
             $this->view->vos_supported[$resource_id] = $resource->Members[0];
             $this->view->vos_errors[$resource_id] = $resource->ErrorMessage[0];
         }
     }
     if (isset($_REQUEST["summary_attrs_showvoownership"])) {
         $model = new ResourceOwnership();
         $this->view->resource_ownerships = $model->getindex();
     }
     if (isset($_REQUEST["summary_attrs_showwlcg"])) {
         $model = new ResourceWLCG();
         $this->view->resource_wlcg = $model->getindex();
         //append bdii link
         foreach ($this->rgs as $rg_id => $rg) {
             foreach ($rg as $resource_id => $resource) {
                 //get resource group name
                 $rgroup = $this->view->resourcegroups[$rg_id][0];
                 $rgname = $rgroup->name;
                 if (isset($this->view->resource_wlcg[$resource_id][0])) {
                     $this->view->resource_wlcg[$resource_id][0]->ldap_url = "ldap://is.grid.iu.edu:2180/mds-vo-name={$rgname},o=grid";
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showenv"])) {
         $model = new ResourceEnv();
         $details = $model->getindex(array("metric_id" => 0));
         $this->view->envs = array();
         //convert to XML String to SimpleXMLElement object
         foreach ($this->rgs as $rg) {
             foreach ($rg as $resource_id => $resource) {
                 if (isset($details[$resource_id])) {
                     $rec = $details[$resource_id][0];
                     $env = null;
                     if ($rec !== null) {
                         try {
                             $env = new SimpleXMLElement($rec->xml);
                         } catch (exception $e) {
                             elog((string) $e);
                             elog($rec->xml);
                         }
                     }
                     $this->view->envs[$resource_id] = $env;
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showcontact"])) {
         $model = new ResourceContact();
         $contacts = $model->getindex();
         //group by contact_type_id
         $this->view->contacts = array();
         foreach ($this->rgs as $rg) {
             foreach ($rg as $resource_id => $resource) {
                 $types = array();
                 if (isset($contacts[$resource_id])) {
                     foreach ($contacts[$resource_id] as $contact) {
                         if (!isset($types[$contact->contact_type])) {
                             $types[$contact->contact_type] = array();
                         }
                         //group by contact name
                         $types[$contact->contact_type][] = $contact;
                     }
                     $this->view->contacts[$resource_id] = $types;
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showfqdn"])) {
         $amodel = new ResourceAlias();
         $this->view->aliases = $amodel->getindex();
     }
     if (isset($_REQUEST["summary_attrs_showhierarchy"])) {
         $this->view->hierarchy = array();
         $model = new Facilities();
         $facilities = $model->getgroupby("id", array("filter_disabled" => false));
         $model = new Site();
         $sites = $model->getgroupby("id", array("filter_disabled" => false));
         $this->view->sites = $sites;
         $model = new SupportCenters();
         $scs = $model->getgroupby("id");
         foreach ($this->rgs as $rgid => $rg) {
             $rginfo = $this->view->resourcegroups[$rgid][0];
             $siteinfo = $sites[$rginfo->site_id][0];
             $facilityinfo = $facilities[$siteinfo->facility_id][0];
             $scinfo = $scs[$siteinfo->sc_id][0];
             $this->view->hierarchy[$rgid] = array("facility" => $facilityinfo, "site" => $siteinfo, "sc" => $scinfo);
         }
     }
     if (isset($_REQUEST["summary_attrs_showticket"])) {
         $ticketmodel = new OpenTickets();
         $this->view->tickets = $ticketmodel->getGroupByRID();
     }
     $this->setpagetitle(self::default_title());
 }