diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1d2900a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [1.2.8] - 2022-02-28 +### Changed +- Sort measurement tags before writing to InfluxDB. +- Update 3rd party dependencies. + + +## [1.2.7] - 2022-02-24 +### Added +- Options to include/exclude Managed Systems and/or Logical Partitions. + +[1.2.8]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.2.8%0Dv1.2.7 +[1.2.7]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.2.7%0Dv1.2.6 +[1.2.6]: https://bitbucket.org/mnellemann/hmci/branches/compare/v1.2.6%0Dv1.2.5 diff --git a/build.gradle b/build.gradle index 23b0384..88e3762 100644 --- a/build.gradle +++ b/build.gradle @@ -23,24 +23,24 @@ targetCompatibility = projectJavaVersion dependencies { annotationProcessor 'info.picocli:picocli-codegen:4.6.2' - implementation 'info.picocli:picocli:4.6.1' + implementation 'info.picocli:picocli:4.6.3' implementation 'org.jsoup:jsoup:1.14.3' implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.squareup.moshi:moshi:1.13.0' implementation 'com.serjltt.moshi:moshi-lazy-adapters:2.2' implementation 'org.tomlj:tomlj:1.0.0' implementation 'org.influxdb:influxdb-java:2.22' - implementation 'org.slf4j:slf4j-api:1.7.35' - implementation 'org.slf4j:slf4j-simple:1.7.35' + implementation 'org.slf4j:slf4j-api:1.7.36' + implementation 'org.slf4j:slf4j-simple:1.7.36' testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0' testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.3' - testImplementation 'org.slf4j:slf4j-simple:1.7.35' + testImplementation 'org.slf4j:slf4j-simple:1.7.36' } application { mainClass.set('biz.nellemann.hmci.Application') - applicationDefaultJvmArgs = [ "-server", "-Xms256m", "-Xmx1024m", "-XX:+UseG1GC" ] + applicationDefaultJvmArgs = [ "-server", "-Xms64m", "-Xmx512m", "-XX:+UseG1GC" ] } test { diff --git a/gradle.properties b/gradle.properties index 67d4d27..8b310fa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ projectId = hmci projectGroup = biz.nellemann.hmci -projectVersion = 1.2.7 +projectVersion = 1.2.8 projectJavaVersion = 1.8 diff --git a/src/main/java/biz/nellemann/hmci/HmcInstance.java b/src/main/java/biz/nellemann/hmci/HmcInstance.java index b4bd601..249bef8 100644 --- a/src/main/java/biz/nellemann/hmci/HmcInstance.java +++ b/src/main/java/biz/nellemann/hmci/HmcInstance.java @@ -118,6 +118,7 @@ class HmcInstance implements Runnable { } } catch (Exception e) { log.error("run() - fatal error: {}", e.getMessage()); + keepRunning.set(false); throw new RuntimeException(e); } @@ -153,7 +154,7 @@ class HmcInstance implements Runnable { void discover() { - log.trace("discover()"); + log.info("discover() - Querying HMC for Managed Systems and Logical Partitions"); Map tmpPartitions = new HashMap<>(); @@ -167,13 +168,13 @@ class HmcInstance implements Runnable { // Check excludeSystems and includeSystems if(!excludeSystems.contains(system.name) && includeSystems.isEmpty()) { systems.put(systemId, system); - log.info("discover() - Adding ManagedSystem: {}", system); + log.info("discover() - ManagedSystem: {}", system); if (doEnergy) { hmcRestClient.enableEnergyMonitoring(system); } } else if(!includeSystems.isEmpty() && includeSystems.contains(system.name)) { systems.put(systemId, system); - log.info("discover() - Adding ManagedSystem (include): {}", system); + log.info("discover() - ManagedSystem (include): {}", system); if (doEnergy) { hmcRestClient.enableEnergyMonitoring(system); } @@ -193,10 +194,10 @@ class HmcInstance implements Runnable { tmpPartitions.forEach((lparKey, lpar) -> { if(!excludePartitions.contains(lpar.name) && includePartitions.isEmpty()) { partitions.put(lparKey, lpar); - log.info("discover() - Adding LogicalPartition: {}", lpar); + log.info("discover() - LogicalPartition: {}", lpar); } else if(!includePartitions.isEmpty() && includePartitions.contains(lpar.name)) { partitions.put(lparKey, lpar); - log.info("discover() - Adding LogicalPartition (include): {}", lpar); + log.info("discover() - LogicalPartition (include): {}", lpar); } else { log.debug("discover() - Skipping LogicalPartition: {}", lpar); } diff --git a/src/main/java/biz/nellemann/hmci/InfluxClient.java b/src/main/java/biz/nellemann/hmci/InfluxClient.java index 2175b0a..ec80723 100644 --- a/src/main/java/biz/nellemann/hmci/InfluxClient.java +++ b/src/main/java/biz/nellemann/hmci/InfluxClient.java @@ -21,13 +21,14 @@ import org.influxdb.InfluxDBException; import org.influxdb.InfluxDBFactory; import org.influxdb.dto.BatchPoints; import org.influxdb.dto.Point; -import org.influxdb.dto.Query; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.time.Instant; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.TreeMap; import java.util.concurrent.TimeUnit; import static java.lang.Thread.sleep; @@ -95,7 +96,7 @@ class InfluxClient { synchronized void writeBatchPoints() throws Exception { log.trace("writeBatchPoints()"); try { - influxDB.writeWithRetry(batchPoints); + influxDB.write(batchPoints); errorCounter = 0; } catch (InfluxDBException.DatabaseNotFoundException e) { log.error("writeBatchPoints() - database \"{}\" not found/created: can't write data", database); @@ -350,7 +351,7 @@ class InfluxClient { measurements.forEach( m -> { Point.Builder builder = Point.measurement(measurement) - .time(timestamp.toEpochMilli(), TimeUnit.MILLISECONDS); + .time(timestamp.getEpochSecond(), TimeUnit.SECONDS); // Iterate fields m.fields.forEach((fieldName, fieldValue) -> { @@ -368,8 +369,9 @@ class InfluxClient { } }); - // Iterate tags - m.tags.forEach((tagName, tagValue) -> { + // Iterate sorted tags + Map sortedTags = new TreeMap(m.tags); + sortedTags.forEach((tagName, tagValue) -> { log.trace("processMeasurementMap() {} - tagName: {}, tagValue: {}", measurement, tagName, tagValue); builder.tag(tagName, tagValue); }); @@ -381,5 +383,4 @@ class InfluxClient { return listOfPoints; } - }