From a24401aa8aca541653adb87fd4d39009bcadf801 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Thu, 10 Jun 2021 12:31:44 +0200 Subject: [PATCH] Remove transmittedBytes from lpar generic adapter metrics, as value is always null. --- doc/readme-service.md | 2 +- .../biz/nellemann/hmci/HmcRestClient.java | 4 ++-- .../java/biz/nellemann/hmci/InfluxClient.java | 22 +++++++++---------- .../biz/nellemann/hmci/LogicalPartition.java | 1 - .../hmci/LogicalPartitionTest.groovy | 17 ++++++++++++++ 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/doc/readme-service.md b/doc/readme-service.md index 9d0e4f3..2a0813d 100644 --- a/doc/readme-service.md +++ b/doc/readme-service.md @@ -12,7 +12,7 @@ systemctl enable hmci.service systemctl restart hmci.service ``` -To read log output from the service, use: +To read log output from the service: ```shell journalctl -f -u hmci.service diff --git a/src/main/java/biz/nellemann/hmci/HmcRestClient.java b/src/main/java/biz/nellemann/hmci/HmcRestClient.java index 9a4fa3a..350bcd2 100644 --- a/src/main/java/biz/nellemann/hmci/HmcRestClient.java +++ b/src/main/java/biz/nellemann/hmci/HmcRestClient.java @@ -249,7 +249,7 @@ public class HmcRestClient { // Do not try to parse empty response if(responseBody == null || responseBody.isEmpty() || responseBody.length() <= 1) { responseErrors++; - log.warn("getPcmDataForManagedSystem() - empty response"); + log.warn("getPcmDataForManagedSystem() - empty response, skipping: " + system.name); return null; } @@ -287,7 +287,7 @@ public class HmcRestClient { // Do not try to parse empty response if(responseBody == null || responseBody.isEmpty() || responseBody.length() <= 1) { responseErrors++; - log.warn("getPcmDataForLogicalPartition() - empty response"); + log.warn("getPcmDataForLogicalPartition() - empty response, skipping: " + partition.name); return null; } diff --git a/src/main/java/biz/nellemann/hmci/InfluxClient.java b/src/main/java/biz/nellemann/hmci/InfluxClient.java index ad32b16..2b04681 100644 --- a/src/main/java/biz/nellemann/hmci/InfluxClient.java +++ b/src/main/java/biz/nellemann/hmci/InfluxClient.java @@ -122,13 +122,13 @@ class InfluxClient { void writeManagedSystem(ManagedSystem system) { if(system.metrics == null) { - log.trace("writeManagedSystem() - null metrics, skipping"); + log.trace("writeManagedSystem() - null metrics, skipping: " + system.name); return; } Instant timestamp = system.getTimestamp(); if(timestamp == null) { - log.warn("writeManagedSystem() - no timestamp, skipping"); + log.warn("writeManagedSystem() - no timestamp, skipping: " + system.name); return; } @@ -253,13 +253,13 @@ class InfluxClient { void writeLogicalPartition(LogicalPartition partition) { if(partition.metrics == null) { - log.warn("writeLogicalPartition() - null metrics, skipping"); + log.warn("writeLogicalPartition() - null metrics, skipping: " + partition.name); return; } Instant timestamp = partition.getTimestamp(); if(timestamp == null) { - log.warn("writeLogicalPartition() - no timestamp, skipping"); + log.warn("writeLogicalPartition() - no timestamp, skipping: " + partition.name); return; } @@ -311,21 +311,21 @@ class InfluxClient { */ - void writeSystemEnergy(SystemEnergy system) { + void writeSystemEnergy(SystemEnergy systemEnergy) { - if(system.metrics == null) { - log.trace("writeSystemEnergy() - null metrics, skipping"); + if(systemEnergy.metrics == null) { + log.trace("writeSystemEnergy() - null metrics, skipping: " + systemEnergy.system.name); return; } - Instant timestamp = system.getTimestamp(); + Instant timestamp = systemEnergy.getTimestamp(); if(timestamp == null) { - log.warn("writeSystemEnergy() - no timestamp, skipping"); + log.warn("writeSystemEnergy() - no timestamp, skipping: " + systemEnergy.system.name); return; } - getSystemEnergyPower(system, timestamp).forEach(it -> batchPoints.point(it) ); - getSystemEnergyTemperature(system, timestamp).forEach(it -> batchPoints.point(it) ); + getSystemEnergyPower(systemEnergy, timestamp).forEach(it -> batchPoints.point(it) ); + getSystemEnergyTemperature(systemEnergy, timestamp).forEach(it -> batchPoints.point(it) ); } private static List getSystemEnergyPower(SystemEnergy system, Instant timestamp) { diff --git a/src/main/java/biz/nellemann/hmci/LogicalPartition.java b/src/main/java/biz/nellemann/hmci/LogicalPartition.java index 73b13e8..4bcc2fb 100644 --- a/src/main/java/biz/nellemann/hmci/LogicalPartition.java +++ b/src/main/java/biz/nellemann/hmci/LogicalPartition.java @@ -181,7 +181,6 @@ class LogicalPartition extends MetaSystem { fieldsMap.put("numOfWrites", adapter.numOfWrites); fieldsMap.put("writeBytes", adapter.writeBytes); fieldsMap.put("readBytes", adapter.readBytes); - fieldsMap.put("transmittedBytes", adapter.transmittedBytes); fieldsMap.put("type", adapter.type); log.trace("getVirtualGenericAdapterMetrics() - fields: " + fieldsMap.toString()); diff --git a/src/test/groovy/biz/nellemann/hmci/LogicalPartitionTest.groovy b/src/test/groovy/biz/nellemann/hmci/LogicalPartitionTest.groovy index 95f9e7a..ec007a8 100644 --- a/src/test/groovy/biz/nellemann/hmci/LogicalPartitionTest.groovy +++ b/src/test/groovy/biz/nellemann/hmci/LogicalPartitionTest.groovy @@ -122,4 +122,21 @@ class LogicalPartitionTest extends Specification { } + void "test getVirtualGenericAdapterMetrics"() { + + setup: + def testFile = new File(getClass().getResource('/pcm-data-logical-partition.json').toURI()) + def testJson = testFile.getText('UTF-8') + ManagedSystem system = new ManagedSystem("e09834d1-c930-3883-bdad-405d8e26e166", "Test Name","Test Type", "Test Model", "Test S/N") + LogicalPartition lpar = new LogicalPartition("2DE05DB6-8AD5-448F-8327-0F488D287E82", "9Flash01", "OS400", system) + + when: + lpar.processMetrics(testJson) + List listOfMeasurements = lpar.getVirtualGenericAdapterMetrics() + + then: + listOfMeasurements.size() == 1 + listOfMeasurements.first().fields['readBytes'] == 0.0 + } + }