Search in sources :

Example 16 with MetricData

use of com.microsoft.applicationinsights.smoketest.schemav2.MetricData in project Server_Management_Plugin_vRealize by Huawei.

the class CPUBean method convert2Resource.

@Override
public ResourceKey convert2Resource(String id, String adapterKind, Map<ResourceKey, List<MetricData>> metricsByResource) {
    ResourceKey resourceKey = new ResourceKey(this.name, Constant.KIND_CPU, 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_FREQUENCY), timestamp, this.frequency));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MANUFACTURE), timestamp, this.manufacture));
    metricDataList.add(new MetricData(new MetricKey(true, Constant.ATTR_MODEL), timestamp, this.model));
    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 17 with MetricData

use of com.microsoft.applicationinsights.smoketest.schemav2.MetricData in project Server_Management_Plugin_vRealize by Huawei.

the class ESightAdapter method setHealStatus4GroupObject.

/**
 * 设置健康状态
 *
 * @param resourceKey     ResourceKey
 * @param attrName        String
 * @param childStatusList Optional values are {OK, Unknown, Warning, Immediate, Critical}
 *                        Level from High to low is:  OK, Unknown, Warning, Immediate, Critical
 */
private void setHealStatus4GroupObject(ResourceKey resourceKey, String attrName, List<String> childStatusList) {
    String defaultStatus = "OK";
    for (String status : childStatusList) {
        switch(defaultStatus) {
            case "OK":
                {
                    defaultStatus = status;
                }
                break;
            case "Unknown":
                {
                    if ("Warning".equals(status) || "Immediate".equals(status) || "Critical".equals(status)) {
                        defaultStatus = status;
                    }
                }
                break;
            case "Warning":
                {
                    if ("Immediate".equals(status) || "Critical".equals(status)) {
                        defaultStatus = status;
                    }
                }
                break;
            case "Immediate":
                {
                    if ("Critical".equals(status)) {
                        defaultStatus = status;
                    }
                }
                break;
            case "Critical":
                {
                    break;
                }
            default:
                {
                    break;
                }
        }
    }
    if ("Unknown".equals(defaultStatus)) {
        defaultStatus = "Warning";
    }
    List<MetricData> metricDataList = new ArrayList<>();
    long timestamp = System.currentTimeMillis();
    metricDataList.add(new MetricData(new MetricKey(false, attrName), timestamp, defaultStatus));
    metricsByResource.put(resourceKey, metricDataList);
}
Also used : MetricKey(com.integrien.alive.common.adapter3.MetricKey) ArrayList(java.util.ArrayList) MetricData(com.integrien.alive.common.adapter3.MetricData)

Example 18 with MetricData

use of com.microsoft.applicationinsights.smoketest.schemav2.MetricData in project Server_Management_Plugin_vRealize by Huawei.

the class ESightAdapter method configEsight.

private void configEsight(String hostIp) {
    ResourceKey resourceKey = new ResourceKey(hostIp, Constant.KIND_HOST_INSTANCE, getAdapterKind());
    long timestamp = System.currentTimeMillis();
    List<MetricData> metricDataList = new ArrayList<>();
    // 设置eSight服务器的状态为离线状态
    metricDataList.add(new MetricData(new MetricKey(false, Constant.ATTR_HEALTHSTATE), timestamp, ConvertUtils.convertHealthState(-1)));
    metricsByResource.put(resourceKey, metricDataList);
    DiscoveryResult discoveryResult = collectResult.getDiscoveryResult(true);
    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);
    return;
}
Also used : DiscoveryResult(com.integrien.alive.common.adapter3.DiscoveryResult) MetricKey(com.integrien.alive.common.adapter3.MetricKey) Relationships(com.integrien.alive.common.adapter3.Relationships) ArrayList(java.util.ArrayList) ResourceConfig(com.integrien.alive.common.adapter3.config.ResourceConfig) ResourceKey(com.integrien.alive.common.adapter3.ResourceKey) MetricData(com.integrien.alive.common.adapter3.MetricData)

Example 19 with MetricData

use of com.microsoft.applicationinsights.smoketest.schemav2.MetricData in project ApplicationInsights-Java by microsoft.

the class PerfCountersDataTest method assertPerfMetric.

private void assertPerfMetric(MetricData perfMetric) {
    List<DataPoint> metrics = perfMetric.getMetrics();
    assertEquals(1, metrics.size());
    DataPoint dp = metrics.get(0);
    assertEquals(DataPointType.Measurement, dp.getKind());
}
Also used : DataPoint(com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)

Example 20 with MetricData

use of com.microsoft.applicationinsights.smoketest.schemav2.MetricData in project ApplicationInsights-Java by microsoft.

the class HeartBeatTest method testHeartBeat.

@Test
@TargetUri(value = "/index.jsp")
public void testHeartBeat() throws Exception {
    List<Envelope> metrics = mockedIngestion.waitForItems(getMetricPredicate("HeartbeatState"), 2, 70, TimeUnit.SECONDS);
    assertEquals(2, metrics.size());
    MetricData data = (MetricData) ((Data<?>) metrics.get(0).getData()).getBaseData();
    assertNotNull(data.getProperties().get("jreVersion"));
    assertNotNull(data.getProperties().get("sdkVersion"));
    assertNotNull(data.getProperties().get("osVersion"));
    assertNotNull(data.getProperties().get("processSessionId"));
    assertNotNull(data.getProperties().get("osType"));
    assertEquals(5, data.getProperties().size());
}
Also used : Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) Test(org.junit.Test)

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)4 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