Search in sources :

Example 1 with MetricData

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

the class ESightAdapter method collectResourceDataFromESight.

/**
 * 调用eSight REST API采集数据.
 *
 * @param host eSight服务器IP
 * @return ResourceKey列表
 */
private List<ResourceKey> collectResourceDataFromESight(String host) {
    List<ResourceKey> allResourceList = new ArrayList<>();
    String[] serverTypes = new String[] { Constant.TREE_SERVER_TYPE_RACK, Constant.TREE_SERVER_TYPE_BLADE, Constant.TREE_SERVER_TYPE_HIGHDENSITY, Constant.TREE_SERVER_TYPE_KUNLUN };
    // 服务器类型keyList
    List<ResourceKey> serverTypeKeyList = new ArrayList<>();
    for (String serverType : serverTypes) {
        List<ServerDeviceBean> serverList = service.getServerDeviceList(serverType);
        if (serverList.isEmpty()) {
            continue;
        }
        // 收集 devices key
        List<ResourceKey> serverDeviceKeyList = new ArrayList<>();
        // 服务器分类
        ResourceKey serverTypeKey = new ResourceKey(serverType, Constant.KIND_SERVER_TYPES, getAdapterKind());
        ResourceIdentifierConfig ipIdentifier = new ResourceIdentifierConfig(Constant.ATTR_ID, host + serverType, true);
        serverTypeKey.addIdentifier(ipIdentifier);
        List<String> serverTypeChildHealthList = new ArrayList<>();
        allResourceList.add(serverTypeKey);
        serverTypeKeyList.add(serverTypeKey);
        for (ServerDeviceBean deviceBean : serverList) {
            setConfig(host, allResourceList, serverDeviceKeyList, serverTypeChildHealthList, deviceBean);
        }
        // 设置服务器类型(如rack, blade)和server device关联关系
        relationshipsByResource.put(serverTypeKey, serverDeviceKeyList);
        setHealStatus4GroupObject(serverTypeKey, Constant.ATTR_HEALTHSTATE, serverTypeChildHealthList);
        logger.error(serverList.size() + " servers of type = " + serverType + " created.");
    }
    ResourceKey serverGroupKey = new ResourceKey(host, Constant.KIND_HOST_INSTANCE, getAdapterKind());
    long timestamp = System.currentTimeMillis();
    List<MetricData> metricDataList = new ArrayList<>();
    // 设置healthState为正常状态
    metricDataList.add(new MetricData(new MetricKey(false, Constant.ATTR_HEALTHSTATE), timestamp, ConvertUtils.convertHealthState(0)));
    metricsByResource.put(serverGroupKey, metricDataList);
    // eSight server IP和serverTypes的对应关系
    relationshipsByResource.put(serverGroupKey, serverTypeKeyList);
    allResourceList.add(serverGroupKey);
    return allResourceList;
}
Also used : ResourceIdentifierConfig(com.integrien.alive.common.adapter3.config.ResourceIdentifierConfig) ServerDeviceBean(com.huawei.esight.service.bean.ServerDeviceBean) ArrayList(java.util.ArrayList) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey) MetricKey(com.integrien.alive.common.adapter3.MetricKey) MetricData(com.integrien.alive.common.adapter3.MetricData)

Example 2 with MetricData

use of com.integrien.alive.common.adapter3.MetricData 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 3 with MetricData

use of com.integrien.alive.common.adapter3.MetricData 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 4 with MetricData

use of com.integrien.alive.common.adapter3.MetricData 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)

Example 5 with MetricData

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

the class ServerDeviceDetailBean method convert2Resource.

@Override
public ResourceKey convert2Resource(String id, String adapterKind, Map<ResourceKey, List<MetricData>> metricsByResource) {
    String resourceName = this.name;
    if (resourceName == null || resourceName.isEmpty()) {
        resourceName = this.ipAddress;
    }
    ResourceKey resourceKey = new ResourceKey(resourceName, Constant.KIND_SERVER_DEVICE, adapterKind);
    ResourceIdentifierConfig dnIdentifier = new ResourceIdentifierConfig(Constant.ATTR_ID, id + this.uuid, true);
    resourceKey.addIdentifier(dnIdentifier);
    long timestamp = System.currentTimeMillis();
    List<MetricData> metricDataList = new ArrayList<>();
    // 写入资源属性
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_DN), timestamp, this.dn));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_IP_ADDRESS), timestamp, this.ipAddress));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_NAME), timestamp, this.name));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_TYPE), timestamp, this.type));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_UUID), timestamp, this.uuid));
    metricDataList.add(new MetricData(new MetricKey(false, Constant.ATTR_STATUS), timestamp, ConvertUtils.convertHealthState(this.status)));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_DESC), timestamp, this.desc));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_PRODUCT_SN), timestamp, this.productSn));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MANUFACTURE), timestamp, this.manufacturer));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_VERSION), timestamp, this.version));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_LOCATION), timestamp, this.location));
    // 非机框服务器不需要写入以下属性
    if (this.memoryCapacity != null) {
        metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MEMORY_CAPACITY), timestamp, this.memoryCapacity));
        metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MODEL), timestamp, this.mode));
        metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_BMC_MAC_ADDR), timestamp, this.bmcMacAddr));
        metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_CPU_NUMS), timestamp, this.cpuNums));
        metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_CPU_CORES), timestamp, this.cpuCores));
    }
    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

MetricData (com.integrien.alive.common.adapter3.MetricData)14 MetricKey (com.integrien.alive.common.adapter3.MetricKey)14 ArrayList (java.util.ArrayList)14 ResourceKey (com.integrien.alive.common.adapter3.ResourceKey)13 ResourceIdentifierConfig (com.integrien.alive.common.adapter3.config.ResourceIdentifierConfig)12 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)5 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)5 Test (org.junit.Test)5 DataPoint (com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)3 ServerDeviceBean (com.huawei.esight.service.bean.ServerDeviceBean)1 DiscoveryResult (com.integrien.alive.common.adapter3.DiscoveryResult)1 Relationships (com.integrien.alive.common.adapter3.Relationships)1 ResourceConfig (com.integrien.alive.common.adapter3.config.ResourceConfig)1 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)1 DataPointType (com.microsoft.applicationinsights.smoketest.schemav2.DataPointType)1 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNull (org.junit.Assert.assertNull)1