Search in sources :

Example 6 with ResourceKey

use of com.integrien.alive.common.adapter3.ResourceKey in project Server_Management_Plugin_vRealize by Huawei.

the class ESightAdapter method onCollect.

/**
 * This method is called for each collection cycle. By default, this value
 * is 5 minutes unless user changes it
 *
 * @param adapterInstResource ResourceConfig
 * @param monitoringResources Collection<ResourceConfig>
 */
@Override
public void onCollect(ResourceConfig adapterInstResource, Collection<ResourceConfig> monitoringResources) {
    if (logger.isInfoEnabled()) {
        logger.info("Inside onCollect method of ESightAdapter class");
    }
    final IdentifierCredentialProperties prop = new IdentifierCredentialProperties(adapterLoggerFactory, adapterInstResource);
    String hostIp = prop.getIdentifier(Constant.KEY_SERVER_IP_ADDRESS, "").trim();
    setHost(hostIp);
    int hostPort = prop.getIntIdentifier(Constant.KEY_ESIGHT_SERVER_PORT, Constant.DEFAULT_ESIGHT_SERVER_PORT);
    String username = prop.getCredential(Constant.KEY_ESIGHT_ACCOUNT);
    String eSightCode = prop.getCredential(Constant.KEY_ESIGHT_CODE);
    String openid = null;
    try {
        openid = service.login(hostIp, hostPort, username, eSightCode);
    } catch (EsightException e) {
        logger.error(e.getMessage() + ": eSight server (" + hostIp + ") authentication failed.", e);
    }
    if (openid == null || openid.isEmpty()) {
        configEsight(hostIp);
        return;
    }
    final Long startTime = System.nanoTime();
    DiscoveryResult discoveryResult = collectResult.getDiscoveryResult(true);
    List<ResourceKey> resources = collectResourceDataFromESight(hostIp);
    // 注销会话 openid
    service.logout(openid);
    if (resources.size() == 0) {
        logger.error("No resources collected from server with IP " + hostIp);
    } else {
        logger.error(resources.size() + " resources collected from server with IP " + hostIp);
    }
    for (ResourceKey resourceKey : resources) {
        useResourceKey(discoveryResult, resourceKey);
    }
    Long seconds = TimeUnit.SECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
    logger.error("Collected resource from esight elapsed time is " + seconds + " seconds.");
    if (seconds > Constant.DEFAULT_COLLECT_INTERVAL * 60) {
        logger.error("PLEASE UPDATE THE COLLECT INTERVAL GREATER THAN " + seconds + " SECONDS.");
    }
}
Also used : DiscoveryResult(com.integrien.alive.common.adapter3.DiscoveryResult) EsightException(com.huawei.esight.exception.EsightException) IdentifierCredentialProperties(com.integrien.alive.common.adapter3.IdentifierCredentialProperties) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey)

Example 7 with ResourceKey

use of com.integrien.alive.common.adapter3.ResourceKey in project Server_Management_Plugin_vRealize by Huawei.

the class ESightAdapter method useResourceKey.

private void useResourceKey(DiscoveryResult discoveryResult, ResourceKey resourceKey) {
    if (isNewResource(resourceKey)) {
        discoveryResult.addResource(new ResourceConfig(resourceKey));
    }
    // Check if resource is part of monitored set, otherwise continue
    ResourceConfig resourceConfig = getMonitoringResource(resourceKey);
    if (resourceConfig == null) {
        return;
    }
    // Add metrics
    addMetricData(resourceConfig, metricsByResource.get(resourceKey));
    // Add relationships
    Relationships rel = new Relationships();
    rel.setRelationships(resourceKey, relationshipsByResource.get(resourceKey), Collections.singleton(getAdapterKind()));
    discoveryResult.addRelationships(rel);
}
Also used : Relationships(com.integrien.alive.common.adapter3.Relationships) ResourceConfig(com.integrien.alive.common.adapter3.config.ResourceConfig)

Example 8 with ResourceKey

use of com.integrien.alive.common.adapter3.ResourceKey in project Server_Management_Plugin_vRealize by Huawei.

the class DiskBean method convert2Resource.

@Override
public ResourceKey convert2Resource(String id, String adapterKind, Map<ResourceKey, List<MetricData>> metricsByResource) {
    ResourceKey resourceKey = new ResourceKey(this.name, Constant.KIND_DISK, adapterKind);
    // 设定唯一的标识,保证同名的资源可以正常显示
    ResourceIdentifierConfig dnIdentifier = new ResourceIdentifierConfig(Constant.ATTR_ID, id + this.uuid, true);
    resourceKey.addIdentifier(dnIdentifier);
    long timestamp = System.currentTimeMillis();
    List<MetricData> metricDataList = new ArrayList<>();
    // 写入resource属性
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_NAME), timestamp, this.name));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_LOCATION), timestamp, this.location));
    metricDataList.add(new MetricData(new MetricKey(false, Constant.ATTR_HEALTHSTATE), timestamp, ConvertUtils.convertHealthState(this.healthState)));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MOID), timestamp, this.moId));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_UUID), timestamp, this.uuid));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_PRESENTSTATE), timestamp, ConvertUtils.convertPresentState(this.presentState)));
    // 关联key和属性值
    metricsByResource.put(resourceKey, metricDataList);
    return resourceKey;
}
Also used : ResourceIdentifierConfig(com.integrien.alive.common.adapter3.config.ResourceIdentifierConfig) MetricKey(com.integrien.alive.common.adapter3.MetricKey) ArrayList(java.util.ArrayList) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey) MetricData(com.integrien.alive.common.adapter3.MetricData)

Example 9 with ResourceKey

use of com.integrien.alive.common.adapter3.ResourceKey in project Server_Management_Plugin_vRealize by Huawei.

the class MemoryBean method convert2Resource.

@Override
public ResourceKey convert2Resource(String id, String adapterKind, Map<ResourceKey, List<MetricData>> metricsByResource) {
    ResourceKey resourceKey = new ResourceKey(this.name, Constant.KIND_MEMORY, adapterKind);
    // 设定唯一的标识,保证同名的资源可以正常显示
    ResourceIdentifierConfig dnIdentifier = new ResourceIdentifierConfig(Constant.ATTR_ID, id + this.uuid, true);
    resourceKey.addIdentifier(dnIdentifier);
    long timestamp = System.currentTimeMillis();
    List<MetricData> metricDataList = new ArrayList<>();
    // 写入resource属性
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_NAME), timestamp, this.name));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_CAPACITY), timestamp, this.capacity));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MANUFACTURE), timestamp, this.manufacture));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_FREQUENCY), timestamp, this.frequency));
    metricDataList.add(new MetricData(new MetricKey(false, Constant.ATTR_HEALTHSTATE), timestamp, ConvertUtils.convertHealthState(this.healthState)));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MOID), timestamp, this.moId));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_UUID), timestamp, this.uuid));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_PRESENTSTATE), timestamp, ConvertUtils.convertPresentState(this.presentState)));
    // 关联key和属性值
    metricsByResource.put(resourceKey, metricDataList);
    return resourceKey;
}
Also used : ResourceIdentifierConfig(com.integrien.alive.common.adapter3.config.ResourceIdentifierConfig) MetricKey(com.integrien.alive.common.adapter3.MetricKey) ArrayList(java.util.ArrayList) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey) MetricData(com.integrien.alive.common.adapter3.MetricData)

Example 10 with ResourceKey

use of com.integrien.alive.common.adapter3.ResourceKey in project Server_Management_Plugin_vRealize by Huawei.

the class FanBean method convert2Resource.

@Override
public ResourceKey convert2Resource(String id, String adapterKind, Map<ResourceKey, List<MetricData>> metricsByResource) {
    ResourceKey resourceKey = new ResourceKey(this.name, Constant.KIND_FAN, adapterKind);
    // 设定唯一的标识,保证同名的资源可以正常显示
    ResourceIdentifierConfig dnIdentifier = new ResourceIdentifierConfig(Constant.ATTR_ID, id + this.uuid, true);
    resourceKey.addIdentifier(dnIdentifier);
    long timestamp = System.currentTimeMillis();
    List<MetricData> metricDataList = new ArrayList<>();
    // 写入resource属性
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_NAME), timestamp, this.name));
    metricDataList.add(new MetricData(new MetricKey(false, Constant.ATTR_HEALTHSTATE), timestamp, ConvertUtils.convertHealthState(this.healthState)));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_ROTATE), timestamp, this.rotate));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_ROTATEPERCENT), timestamp, ConvertUtils.convertRotatePercent(this.controlModel, this.rotatePercent)));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_CONTROLMODEL), timestamp, ConvertUtils.convertControlModel(this.controlModel)));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MOID), timestamp, this.moId));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_UUID), timestamp, this.uuid));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_PRESENTSTATE), timestamp, ConvertUtils.convertPresentState(this.presentState)));
    // 关联key和属性值
    metricsByResource.put(resourceKey, metricDataList);
    return resourceKey;
}
Also used : ResourceIdentifierConfig(com.integrien.alive.common.adapter3.config.ResourceIdentifierConfig) MetricKey(com.integrien.alive.common.adapter3.MetricKey) ArrayList(java.util.ArrayList) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey) MetricData(com.integrien.alive.common.adapter3.MetricData)

Aggregations

ResourceKey (com.integrien.alive.common.adapter3.ResourceKey)27 ArrayList (java.util.ArrayList)26 MetricData (com.integrien.alive.common.adapter3.MetricData)14 MetricKey (com.integrien.alive.common.adapter3.MetricKey)14 ResourceIdentifierConfig (com.integrien.alive.common.adapter3.config.ResourceIdentifierConfig)13 ChildBladeBean (com.huawei.esight.service.bean.ChildBladeBean)2 DiscoveryResult (com.integrien.alive.common.adapter3.DiscoveryResult)2 Relationships (com.integrien.alive.common.adapter3.Relationships)2 ResourceConfig (com.integrien.alive.common.adapter3.config.ResourceConfig)2 EsightException (com.huawei.esight.exception.EsightException)1 BoardBean (com.huawei.esight.service.bean.BoardBean)1 CPUBean (com.huawei.esight.service.bean.CPUBean)1 DiskBean (com.huawei.esight.service.bean.DiskBean)1 FanBean (com.huawei.esight.service.bean.FanBean)1 MemoryBean (com.huawei.esight.service.bean.MemoryBean)1 MezzBean (com.huawei.esight.service.bean.MezzBean)1 NetworkCardBean (com.huawei.esight.service.bean.NetworkCardBean)1 PCIEBean (com.huawei.esight.service.bean.PCIEBean)1 PSUBean (com.huawei.esight.service.bean.PSUBean)1 RAIDBean (com.huawei.esight.service.bean.RAIDBean)1