public function processXML($bdii) { $resources = array(); $model = new Resource(); $oim_resources = $model->getgroupby("fqdn"); foreach ($bdii->Resources->Resource as $resource) { $fqdn = (string) $resource->FQDN; if (isset($oim_resources[$fqdn])) { $oim_resource_info = $oim_resources[$fqdn][0]; $resources[$oim_resource_info->id] = array("info" => $oim_resource_info, "bdii" => $resource); } else { slog("BDII FQDN: [{$fqdn}] doesn't exist in OIM"); } } return $resources; }
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); }