diff --git a/.gitignore b/.gitignore index 2322e64..0227c78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.vscode .gradle .project .classpath diff --git a/build.gradle b/build.gradle index 09ae6e5..4e2b20e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { // Code coverage of tests id 'jacoco' - id "com.github.johnrengelman.shadow" version "6.0.0" + id "com.github.johnrengelman.shadow" version "6.1.0" id "net.nemerosa.versioning" version "2.14.0" id "nebula.ospackage" version "8.4.1" } @@ -16,8 +16,8 @@ repositories { } dependencies { - annotationProcessor 'info.picocli:picocli-codegen:4.5.1' - implementation 'info.picocli:picocli:4.5.1' + annotationProcessor 'info.picocli:picocli-codegen:4.5.2' + implementation 'info.picocli:picocli:4.5.2' implementation 'org.jsoup:jsoup:1.13.1' implementation 'com.squareup.okhttp3:okhttp:4.9.0' implementation 'com.squareup.moshi:moshi:1.11.0' @@ -27,7 +27,7 @@ dependencies { implementation 'org.slf4j:slf4j-api:1.7.+' runtimeOnly 'ch.qos.logback:logback-classic:1.+' - testImplementation('org.spockframework:spock-core:2.0-M3-groovy-3.0') + testImplementation('org.spockframework:spock-core:2.0-M4-groovy-3.0') testImplementation('com.squareup.okhttp3:mockwebserver:4.9.0') testImplementation("org.slf4j:slf4j-simple:1.7.+") //implementation platform('org.testcontainers:testcontainers-bom:1.14.3') //import bom diff --git a/gradle.properties b/gradle.properties index ec5983c..862280e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ id = hmci group = biz.nellemann.hmci -version = 0.2.3 +version = 0.2.4 diff --git a/src/main/java/biz/nellemann/hmci/HmcClient.java b/src/main/java/biz/nellemann/hmci/HmcClient.java index ed4070a..fc14318 100644 --- a/src/main/java/biz/nellemann/hmci/HmcClient.java +++ b/src/main/java/biz/nellemann/hmci/HmcClient.java @@ -193,7 +193,7 @@ class HmcClient { Map getLogicalPartitionsForManagedSystem(ManagedSystem system) throws Exception { URL url = new URL(String.format("%s/rest/api/uom/ManagedSystem/%s/LogicalPartition", baseUrl, system.id)); String responseBody = getResponse(url); - Map partitionMap = new HashMap() {}; + Map partitionMap = new HashMap(); // Do not try to parse empty response if(responseBody == null || responseBody.isEmpty() || responseBody.length() <= 1) { diff --git a/src/main/java/biz/nellemann/hmci/LogicalPartition.java b/src/main/java/biz/nellemann/hmci/LogicalPartition.java index 3e64f45..87963a7 100644 --- a/src/main/java/biz/nellemann/hmci/LogicalPartition.java +++ b/src/main/java/biz/nellemann/hmci/LogicalPartition.java @@ -49,24 +49,14 @@ class LogicalPartition extends MetaSystem { List getAffinityScore() { List list = new ArrayList<>(); - //Map map = new HashMap() - Map tagsMap = new HashMap() { - { - put("system", system.name); - put("partition", name); - } - }; - - //map.put("tags", tagsMap) + Map tagsMap = new HashMap(); + tagsMap.put("system", system.name); + tagsMap.put("partition", name); log.debug("getAffinityScore() - tags: " + tagsMap.toString()); - Map fieldsMap = new HashMap() { - { - put("affinityScore", metrics.systemUtil.sample.lparsUtil.affinityScore); - } - }; - //map.put("fields", fieldsMap) + Map fieldsMap = new HashMap(); + fieldsMap.put("affinityScore", metrics.systemUtil.sample.lparsUtil.affinityScore); log.debug("getAffinityScore() - fields: " + fieldsMap.toString()); Measurement measurement = new Measurement(tagsMap, fieldsMap); @@ -78,27 +68,15 @@ class LogicalPartition extends MetaSystem { List getMemoryMetrics() { List list = new ArrayList<>(); - //Map map = new HashMap() - Map tagsMap = new HashMap() { - { - put("system", system.name); - put("partition", name); - } - }; - - //map.put("tags", tagsMap) + Map tagsMap = new HashMap(); + tagsMap.put("system", system.name); + tagsMap.put("partition", name); log.debug("getMemoryMetrics() - tags: " + tagsMap.toString()); - Map fieldsMap = new HashMap() { - { - put("logicalMem", metrics.systemUtil.sample.lparsUtil.memory.logicalMem); - put("backedPhysicalMem", metrics.systemUtil.sample.lparsUtil.memory.backedPhysicalMem); - } - }; - - - //map.put("fields", fieldsMap) + Map fieldsMap = new HashMap(); + fieldsMap.put("logicalMem", metrics.systemUtil.sample.lparsUtil.memory.logicalMem); + fieldsMap.put("backedPhysicalMem", metrics.systemUtil.sample.lparsUtil.memory.backedPhysicalMem); log.debug("getMemoryMetrics() - fields: " + fieldsMap.toString()); Measurement measurement = new Measurement(tagsMap, fieldsMap); @@ -111,35 +89,24 @@ class LogicalPartition extends MetaSystem { List getProcessorMetrics() { List list = new ArrayList<>(); - //Map map = new HashMap() - HashMap tagsMap = new HashMap() { - { - put("system", system.name); - put("partition", name); - } - }; - - //map.put("tags", tagsMap) + HashMap tagsMap = new HashMap(); + tagsMap.put("system", system.name); + tagsMap.put("partition", name); log.debug("getProcessorMetrics() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("utilizedProcUnits", metrics.systemUtil.sample.lparsUtil.processor.utilizedProcUnits); - put("maxVirtualProcessors", metrics.systemUtil.sample.lparsUtil.processor.maxVirtualProcessors); - put("currentVirtualProcessors", metrics.systemUtil.sample.lparsUtil.processor.currentVirtualProcessors); - //donatedProcUnits: metrics.systemUtil.utilSamples.first().lparsUtil.first().processor.donatedProcUnits.first(), - put("entitledProcUnits", metrics.systemUtil.sample.lparsUtil.processor.entitledProcUnits); - //idleProcUnits: metrics.systemUtil.utilSamples.first().lparsUtil.first().processor.idleProcUnits.first(), - //maxProcUnits: metrics.systemUtil.utilSamples.first().lparsUtil.first().processor.maxProcUnits.first(), - put("utilizedCappedProcUnits", metrics.systemUtil.sample.lparsUtil.processor.utilizedCappedProcUnits); - put("utilizedUncappedProcUnits", metrics.systemUtil.sample.lparsUtil.processor.utilizedUncappedProcUnits); - put("timePerInstructionExecution", metrics.systemUtil.sample.lparsUtil.processor.timeSpentWaitingForDispatch); - put("timeSpentWaitingForDispatch", metrics.systemUtil.sample.lparsUtil.processor.timePerInstructionExecution); - } - }; - - //map.put("fields", fieldsMap) + HashMap fieldsMap = new HashMap(); + fieldsMap.put("utilizedProcUnits", metrics.systemUtil.sample.lparsUtil.processor.utilizedProcUnits); + fieldsMap.put("maxVirtualProcessors", metrics.systemUtil.sample.lparsUtil.processor.maxVirtualProcessors); + fieldsMap.put("currentVirtualProcessors", metrics.systemUtil.sample.lparsUtil.processor.currentVirtualProcessors); + //fieldsMap.donatedProcUnits: metrics.systemUtil.utilSamples.first().lparsUtil.first().processor.donatedProcUnits.first(), + fieldsMap.put("entitledProcUnits", metrics.systemUtil.sample.lparsUtil.processor.entitledProcUnits); + //fieldsMap.idleProcUnits: metrics.systemUtil.utilSamples.first().lparsUtil.first().processor.idleProcUnits.first(), + //fieldsMap.maxProcUnits: metrics.systemUtil.utilSamples.first().lparsUtil.first().processor.maxProcUnits.first(), + fieldsMap.put("utilizedCappedProcUnits", metrics.systemUtil.sample.lparsUtil.processor.utilizedCappedProcUnits); + fieldsMap.put("utilizedUncappedProcUnits", metrics.systemUtil.sample.lparsUtil.processor.utilizedUncappedProcUnits); + fieldsMap.put("timePerInstructionExecution", metrics.systemUtil.sample.lparsUtil.processor.timeSpentWaitingForDispatch); + fieldsMap.put("timeSpentWaitingForDispatch", metrics.systemUtil.sample.lparsUtil.processor.timePerInstructionExecution); log.debug("getProcessorMetrics() - fields: " + fieldsMap.toString()); Measurement measurement = new Measurement(tagsMap, fieldsMap); @@ -154,26 +121,20 @@ class LogicalPartition extends MetaSystem { List list = new ArrayList<>(); metrics.systemUtil.sample.lparsUtil.network.virtualEthernetAdapters.forEach( adapter -> { - HashMap tagsMap = new HashMap() { - { - put("system", system.name); - put("partition", name); - put("sea", adapter.sharedEthernetAdapterId); - put("viosId", adapter.viosId.toString()); - put("vlanId", adapter.vlanId.toString()); - put("vswitchId", adapter.vswitchId.toString()); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("system", system.name); + tagsMap.put("partition", name); + tagsMap.put("sea", adapter.sharedEthernetAdapterId); + tagsMap.put("viosId", adapter.viosId.toString()); + tagsMap.put("vlanId", adapter.vlanId.toString()); + tagsMap.put("vswitchId", adapter.vswitchId.toString()); log.debug("getVirtualEthernetAdapterMetrics() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("receivedPhysicalBytes", adapter.receivedPhysicalBytes); - put("sentPhysicalBytes", adapter.sentPhysicalBytes); - put("receivedBytes", adapter.receivedBytes); - put("sentBytes", adapter.sentBytes); - } - }; + HashMap fieldsMap = new HashMap(); + fieldsMap.put("receivedPhysicalBytes", adapter.receivedPhysicalBytes); + fieldsMap.put("sentPhysicalBytes", adapter.sentPhysicalBytes); + fieldsMap.put("receivedBytes", adapter.receivedBytes); + fieldsMap.put("sentBytes", adapter.sentBytes); log.debug("getVirtualEthernetAdapterMetrics() - fields: " + fieldsMap.toString()); Measurement measurement = new Measurement(tagsMap, fieldsMap); @@ -190,29 +151,18 @@ class LogicalPartition extends MetaSystem { List list = new ArrayList<>(); metrics.systemUtil.sample.lparsUtil.storage.virtualFiberChannelAdapters.forEach( adapter -> { - //Map map = new HashMap() - HashMap tagsMap = new HashMap() { - { - put("system", system.name); - put("partition", name); - put("viosId", adapter.viosId.toString()); - put("wwpn", adapter.wwpn); - } - }; - - //map.put("tags", tagsMap) + HashMap tagsMap = new HashMap(); + tagsMap.put("system", system.name); + tagsMap.put("partition", name); + tagsMap.put("viosId", adapter.viosId.toString()); + tagsMap.put("wwpn", adapter.wwpn); log.debug("getVirtualFiberChannelAdaptersMetrics() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("transmittedBytes", adapter.transmittedBytes.get(0)); - put("writeBytes", adapter.writeBytes.get(0)); - put("readBytes", adapter.readBytes.get(0)); - } - }; - - //map.put("fields", fieldsMap) + HashMap fieldsMap = new HashMap(); + fieldsMap.put("transmittedBytes", adapter.transmittedBytes.get(0)); + fieldsMap.put("writeBytes", adapter.writeBytes.get(0)); + fieldsMap.put("readBytes", adapter.readBytes.get(0)); log.debug("getVirtualFiberChannelAdaptersMetrics() - fields: " + fieldsMap.toString()); Measurement measurement = new Measurement(tagsMap, fieldsMap); diff --git a/src/main/java/biz/nellemann/hmci/ManagedSystem.java b/src/main/java/biz/nellemann/hmci/ManagedSystem.java index afcb873..c211645 100644 --- a/src/main/java/biz/nellemann/hmci/ManagedSystem.java +++ b/src/main/java/biz/nellemann/hmci/ManagedSystem.java @@ -54,23 +54,17 @@ class ManagedSystem extends MetaSystem { List list = new ArrayList<>(); //Map map = new HashMap() - HashMap tagsMap = new HashMap() { - { - put("system", name); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("system", name); //map.put("tags", tagsMap) log.debug("getMemoryMetrics() - tags: " + tagsMap.toString()); - Map fieldsMap = new HashMap() { - { - put("totalMem", metrics.systemUtil.sample.serverUtil.memory.totalMem); - put("availableMem", metrics.systemUtil.sample.serverUtil.memory.availableMem); - put("configurableMem", metrics.systemUtil.sample.serverUtil.memory.configurableMem); - put("assignedMemToLpars", metrics.systemUtil.sample.serverUtil.memory.assignedMemToLpars); - } - }; + Map fieldsMap = new HashMap(); + fieldsMap.put("totalMem", metrics.systemUtil.sample.serverUtil.memory.totalMem); + fieldsMap.put("availableMem", metrics.systemUtil.sample.serverUtil.memory.availableMem); + fieldsMap.put("configurableMem", metrics.systemUtil.sample.serverUtil.memory.configurableMem); + fieldsMap.put("assignedMemToLpars", metrics.systemUtil.sample.serverUtil.memory.assignedMemToLpars); //map.put("fields", fieldsMap) log.debug("getMemoryMetrics() - fields: " + fieldsMap.toString()); @@ -87,24 +81,19 @@ class ManagedSystem extends MetaSystem { List list = new ArrayList<>(); //Map map = new HashMap<>() - HashMap tagsMap = new HashMap() { - { - put("system", name); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("system", name); //map.put("tags", tagsMap) //measurement.tags = tagsMap; log.debug("getProcessorMetrics() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("totalProcUnits", metrics.systemUtil.sample.serverUtil.processor.totalProcUnits); - put("utilizedProcUnits", metrics.systemUtil.sample.serverUtil.processor.utilizedProcUnits); - put("availableProcUnits", metrics.systemUtil.sample.serverUtil.processor.availableProcUnits); - put("configurableProcUnits", metrics.systemUtil.sample.serverUtil.processor.configurableProcUnits); - } - }; + HashMap fieldsMap = new HashMap(); + fieldsMap.put("totalProcUnits", metrics.systemUtil.sample.serverUtil.processor.totalProcUnits); + fieldsMap.put("utilizedProcUnits", metrics.systemUtil.sample.serverUtil.processor.utilizedProcUnits); + fieldsMap.put("availableProcUnits", metrics.systemUtil.sample.serverUtil.processor.availableProcUnits); + fieldsMap.put("configurableProcUnits", metrics.systemUtil.sample.serverUtil.processor.configurableProcUnits); + //map.put("fields", fieldsMap) //measurement.fields = fieldsMap; log.debug("getProcessorMetrics() - fields: " + fieldsMap.toString()); @@ -122,22 +111,16 @@ class ManagedSystem extends MetaSystem { metrics.systemUtil.sample.serverUtil.sharedProcessorPool.forEach(adapter -> { //Map map = new HashMap() - HashMap tagsMap = new HashMap() { - { - put("system", name); - put("pool", adapter.name); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("system", name); + tagsMap.put("pool", adapter.name); //map.put("tags", tagsMap) log.debug("getSharedProcessorPools() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("assignedProcUnits", adapter.assignedProcUnits); - put("availableProcUnits", adapter.availableProcUnits); - } - }; + HashMap fieldsMap = new HashMap(); + fieldsMap.put("assignedProcUnits", adapter.assignedProcUnits); + fieldsMap.put("availableProcUnits", adapter.availableProcUnits); //map.put("fields", fieldsMap) log.debug("getSharedProcessorPools() - fields: " + fieldsMap.toString()); @@ -159,25 +142,20 @@ class ManagedSystem extends MetaSystem { //Map map = new HashMap() Measurement measurement = new Measurement(); - HashMap tagsMap = new HashMap() { - { - put("system", name); - put("type", adapter.type); - put("vios", vios.name); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("system", name); + tagsMap.put("type", adapter.type); + tagsMap.put("vios", vios.name); //map.put("tags", tagsMap) measurement.tags = tagsMap; log.debug("getSystemSharedAdapters() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("sentBytes", adapter.sentBytes); - put("receivedBytes", adapter.receivedBytes); - put("transferredBytes", adapter.transferredBytes); - } - }; + HashMap fieldsMap = new HashMap(); + fieldsMap.put("sentBytes", adapter.sentBytes); + fieldsMap.put("receivedBytes", adapter.receivedBytes); + fieldsMap.put("transferredBytes", adapter.transferredBytes); + //map.put("fields", fieldsMap) measurement.fields = fieldsMap; log.debug("getSystemSharedAdapters() - fields: " + fieldsMap.toString()); @@ -201,27 +179,22 @@ class ManagedSystem extends MetaSystem { //HashMap map = new HashMap<>() Measurement measurement = new Measurement(); - HashMap tagsMap = new HashMap() { - { - put("id", adapter.id); - put("system", name); - put("wwpn", adapter.wwpn); - put("vios", vios.name); - put("device", adapter.physicalLocation); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("id", adapter.id); + tagsMap.put("system", name); + tagsMap.put("wwpn", adapter.wwpn); + tagsMap.put("vios", vios.name); + tagsMap.put("device", adapter.physicalLocation); //map.put("tags", tagsMap) measurement.tags = tagsMap; log.debug("getSystemFiberChannelAdapters() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("writeBytes", adapter.writeBytes); - put("readBytes", adapter.readBytes); - put("transmittedBytes", adapter.transmittedBytes); - } - }; + HashMap fieldsMap = new HashMap(); + fieldsMap.put("writeBytes", adapter.writeBytes); + fieldsMap.put("readBytes", adapter.readBytes); + fieldsMap.put("transmittedBytes", adapter.transmittedBytes); + //map.put("fields", fieldsMap) measurement.fields = fieldsMap; log.debug("getSystemFiberChannelAdapters() - fields: " + fieldsMap.toString()); @@ -245,25 +218,19 @@ class ManagedSystem extends MetaSystem { Measurement measurement = new Measurement(); - HashMap tagsMap = new HashMap() { - { - put("id", adapter.id); - put("system", name); - put("vios", vios.name); - put("device", adapter.physicalLocation); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("id", adapter.id); + tagsMap.put("system", name); + tagsMap.put("vios", vios.name); + tagsMap.put("device", adapter.physicalLocation); measurement.tags = tagsMap; log.debug("getSystemGenericPhysicalAdapters() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("writeBytes", adapter.writeBytes); - put("readBytes", adapter.readBytes); - put("transmittedBytes", adapter.transmittedBytes); - } - }; + HashMap fieldsMap = new HashMap(); + fieldsMap.put("writeBytes", adapter.writeBytes); + fieldsMap.put("readBytes", adapter.readBytes); + fieldsMap.put("transmittedBytes", adapter.transmittedBytes); measurement.fields = fieldsMap; log.debug("getSystemGenericPhysicalAdapters() - fields: " + fieldsMap.toString()); @@ -287,25 +254,19 @@ class ManagedSystem extends MetaSystem { Measurement measurement = new Measurement(); - HashMap tagsMap = new HashMap() { - { - put("id", adapter.id); - put("system", name); - put("vios", vios.name); - put("device", adapter.physicalLocation); - } - }; + HashMap tagsMap = new HashMap(); + tagsMap.put("id", adapter.id); + tagsMap.put("system", name); + tagsMap.put("vios", vios.name); + tagsMap.put("device", adapter.physicalLocation); measurement.tags = tagsMap; log.debug("getSystemGenericVirtualAdapters() - tags: " + tagsMap.toString()); - HashMap fieldsMap = new HashMap() { - { - put("writeBytes", adapter.writeBytes); - put("readBytes", adapter.readBytes); - put("transmittedBytes", adapter.transmittedBytes); - } - }; + HashMap fieldsMap = new HashMap(); + fieldsMap.put("writeBytes", adapter.writeBytes); + fieldsMap.put("readBytes", adapter.readBytes); + fieldsMap.put("transmittedBytes", adapter.transmittedBytes); measurement.fields = fieldsMap; log.debug("getSystemGenericVirtualAdapters() - fields: " + fieldsMap.toString()); diff --git a/src/main/java/biz/nellemann/hmci/MetaSystem.java b/src/main/java/biz/nellemann/hmci/MetaSystem.java index 70a7575..7f47185 100644 --- a/src/main/java/biz/nellemann/hmci/MetaSystem.java +++ b/src/main/java/biz/nellemann/hmci/MetaSystem.java @@ -95,7 +95,7 @@ abstract class MetaSystem { @FromJson Number fromJson(String string) { - return new Double(string); + return Double.parseDouble(string); } @ToJson