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; }
public function load() { parent::load(); $model = new ResourceGroup(); $this->view->resource_groups_by_gridtype = $model->getgroupby("osg_grid_type_id"); $model = new Resource(); $this->view->resources_by_resource_group = $model->getgroupby("resource_group_id"); $model = new GridTypes(); $this->view->grid_types = $model->getindex(); $model = new Service(); $this->view->services = $model->getindex(); $model = new ResourceServices(); $this->view->services_by_resource = $model->getgroupby("resource_id"); $this->view->counts = array(); //filter service groups $this->view->service_groups = array(); $model = new ServiceGroup(); $service_groups = $model->getindex(); foreach ($service_groups as $id => $service_group) { if (isset($_REQUEST["count_sg_" . $id])) { $this->view->service_groups[$id] = $service_group; } } $this->view->resource_counts = array(); //for each grid type foreach ($this->view->resource_groups_by_gridtype as $grid_type_id => $resource_groups) { $resource_counts = 0; //for each resource groups, foreach ($resource_groups as $resource_group) { $resources = $this->view->resources_by_resource_group[$resource_group->id]; //for each resource foreach ($resources as $resource) { //apply filter if (isset($_REQUEST["count_active"])) { if ($resource->active == 0) { continue; } } if (isset($_REQUEST["count_enabled"])) { if ($resource->disable == 1) { continue; } } $resource_counts++; //pull counter for current grid type //$services = $this->services_by_resource[$resource->id]; if (!isset($this->view->counts[$grid_type_id])) { $this->view->counts[$grid_type_id] = array(); } $count_service = $this->view->counts[$grid_type_id]; //for each services if (isset($this->view->services_by_resource[$resource->id])) { foreach ($this->view->services_by_resource[$resource->id] as $service) { if (!isset($count_service[$service->id])) { $count_service[$service->id] = 0; } $count_service[$service->id] = $count_service[$service->id] + 1; } } $this->view->counts[$grid_type_id] = $count_service; } } $this->view->resource_counts[$grid_type_id] = $resource_counts; } $this->setpagetitle(self::default_title()); }
private function getStatus($gid, $url) { if (!isset($this->resource_groups)) { $model = new ResourceGroup(); $this->resource_groups = $model->getgroupby("id"); } $rginfo = $this->resource_groups[$gid][0]; if (!isset($this->latest_resource_status)) { $model = new LatestResourceStatus(); $this->latest_resource_status = $model->getgroupby("resource_id"); $model = new Resource(); $this->resources_by_resource_group = $model->getgroupby("resource_group_id"); } //calculate service status (the same standard algorithm) $warning = 0; $critical = 0; $unknown = 0; $downtime = 0; $resources = $this->resources_by_resource_group[$gid]; $count = 0; foreach ($resources as $resource) { if ($resource->active == 0) { continue; } //filter by deactivated resource $count++; //is this resource under downtime? if (isset($this->downtimes[$resource->id])) { $downtime++; continue; } if (isset($this->latest_resource_status[$resource->id])) { $status = $this->latest_resource_status[$resource->id][0]; switch ((int) $status->status_id) { case 2: $warning++; break; case 3: $critical++; break; case 4: $unknown++; break; } } else { $unknown++; } } $rgstatus = "UNKNOWN"; if ($count > 0) { if ($critical > 0) { $rgstatus = "CRITICAL"; } else { if ($warning > 0) { $rgstatus = "WARNING"; } else { if ($unknown > 0) { $rgstatus = "UNKNOWN"; } else { if ($downtime > 0) { $rgstatus = "DOWNTIME"; } else { $rgstatus = "OK"; } } } } } return array("name" => $rginfo->name, "description" => $rginfo->description, "status" => $rgstatus, "resource_group_id" => $rginfo->id, "url" => $url); }
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()); }