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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations