From 6ffc943a51c6623efcd2184c65020dd317712c6c Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Wed, 16 Nov 2022 12:21:33 +0100 Subject: [PATCH] Fix incorrect use of OSHI getDiskStores causing lots of reads on AIX. --- CHANGELOG.md | 5 + client/build.gradle | 2 +- client/doc/sysmon-client.service | 1 + client/doc/sysmon-client.sh | 6 +- .../src/main/resources/application.properties | 18 +-- doc/dashboards/Sysmon - Host Overview.json | 122 +++++++++++------- doc/dashboards/Sysmon - IBM Power.json | 34 ++++- doc/dashboards/Sysmon - Process Explorer.json | 20 ++- gradle.properties | 2 +- .../plugins/os_base/BaseDiskExtension.java | 9 +- .../os_base/BaseFilesystemExtension.java | 9 +- server/build.gradle | 2 +- .../src/main/resources/application.properties | 13 -- 13 files changed, 145 insertions(+), 98 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab59d31..9f1f81a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [1.0.24] - 2022-11-16 +- Fix incorrect use of OSHI getDiskStores() +- Update dashboards + ## [1.0.23] - 2022-11-07 - Update dashboards. - Lower default interval for most plugins. @@ -36,6 +40,7 @@ All notable changes to this project will be documented in this file. ### Changed - Updated 3rd party dependencies. +[1.0.24]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.0.24%0Dv0.1.23 [1.0.23]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.0.23%0Dv0.1.21 [1.0.21]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.0.21%0Dv0.1.18 [1.0.18]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v1.0.18%0Dv0.1.13 diff --git a/client/build.gradle b/client/build.gradle index 9bd0697..4f6b871 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -38,7 +38,7 @@ def projectName = "sysmon-client" application { // Define the main class for the application. mainClass.set('sysmon.client.Application') - applicationDefaultJvmArgs = [ "-server", "-Xms64m", "-Xmx64m", "-XX:+ExitOnOutOfMemoryError", "-XX:+AlwaysPreTouch" ] + applicationDefaultJvmArgs = [ "-Xms64m", "-Xmx64m", "-XX:+ExitOnOutOfMemoryError", "-XX:+AlwaysPreTouch" ] } run { diff --git a/client/doc/sysmon-client.service b/client/doc/sysmon-client.service index 56a310f..fe89b39 100644 --- a/client/doc/sysmon-client.service +++ b/client/doc/sysmon-client.service @@ -6,6 +6,7 @@ Description=Sysmon Client #Group=nobody TimeoutSec=20 Restart=on-failure +# BELOW: Specify sysmon-server URL, add '-n hostname' if needed ExecStart=/opt/sysmon/client/bin/client -s http://10.20.30.40:9925/metrics [Install] diff --git a/client/doc/sysmon-client.sh b/client/doc/sysmon-client.sh index 034682b..3cbce25 100644 --- a/client/doc/sysmon-client.sh +++ b/client/doc/sysmon-client.sh @@ -11,7 +11,7 @@ dir="/opt/sysmon/client" cmd="/opt/sysmon/client/bin/client" -args="-s http://10.20.30.40:9925/metrics" # Specify sysmon-server URL here, add '-n hostname' if needed +args="-s http://10.20.30.40:9925/metrics" # <- HERE: Specify sysmon-server URL, add '-n hostname' if needed user="" name="sysmon-client" @@ -21,7 +21,9 @@ stderr_log="/var/log/$name.err" # Uncomment if required #JAVA_HOME=/usr/java8_64 -#JAVA_HOME=/opt/ibm/ibm-semeru-certified-11-jre +#JAVA_HOME=/opt/ibm-semeru-open-8-jdk +#JAVA_HOME=/opt/ibm-semeru-open-11-jdk +#JAVA_HOME=/opt/ibm-semeru-open-17-jdk #export JAVA_HOME get_pid() { diff --git a/client/src/main/resources/application.properties b/client/src/main/resources/application.properties index b01e8aa..39b204a 100644 --- a/client/src/main/resources/application.properties +++ b/client/src/main/resources/application.properties @@ -15,21 +15,7 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -# to configure camel main -# here you can configure options on camel main (see MainConfigurationProperties class) camel.main.name = sysmon-client - -# enable tracing -#camel.main.tracing = true - -# bean introspection to log reflection based configuration -#camel.main.beanIntrospectionExtendedStatistics=true -#camel.main.beanIntrospectionLoggingLevel=INFO - -# run in lightweight mode to be tiny as possible +camel.main.jmxEnabled = false camel.main.lightweight = true -# and eager load classes -#camel.main.eager-classloading = true - -# limit the seda queue size -camel.component.seda.queue-size=10 \ No newline at end of file +camel.component.seda.queue-size = 100 diff --git a/doc/dashboards/Sysmon - Host Overview.json b/doc/dashboards/Sysmon - Host Overview.json index 0914685..0bd3d94 100644 --- a/doc/dashboards/Sysmon - Host Overview.json +++ b/doc/dashboards/Sysmon - Host Overview.json @@ -1457,7 +1457,7 @@ "type": "linear" }, "showPoints": "never", - "spanNulls": true, + "spanNulls": 3600000, "stacking": { "group": "A", "mode": "normal" @@ -1532,7 +1532,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -1554,16 +1554,18 @@ "params": [], "type": "mean" }, + { + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" + }, { "params": [ 5 ], "type": "moving_average" }, - { - "params": [], - "type": "non_negative_difference" - }, { "params": [ "read" @@ -1690,7 +1692,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -1712,16 +1714,18 @@ "params": [], "type": "mean" }, + { + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" + }, { "params": [ 5 ], "type": "moving_average" }, - { - "params": [], - "type": "non_negative_difference" - }, { "params": [ "write" @@ -1843,7 +1847,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -1872,8 +1876,10 @@ "type": "moving_average" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -1996,7 +2002,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -2025,8 +2031,10 @@ "type": "moving_average" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2230,11 +2238,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2252,11 +2262,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2274,11 +2286,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2296,11 +2310,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2318,11 +2334,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2340,15 +2358,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" - }, - { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2366,11 +2382,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2388,11 +2406,13 @@ }, { "params": [], - "type": "mean" + "type": "last" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -2545,14 +2565,16 @@ "type": "mean" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + 5 + ], + "type": "moving_average" }, { "params": [ - 10 + "$__interval" ], - "type": "moving_average" + "type": "non_negative_derivative" } ] ], @@ -3129,6 +3151,6 @@ "timezone": "", "title": "Sysmon - Host Overview", "uid": "QkVPjseMt", - "version": 15, + "version": 18, "weekStart": "" } \ No newline at end of file diff --git a/doc/dashboards/Sysmon - IBM Power.json b/doc/dashboards/Sysmon - IBM Power.json index 67201c3..f72cb18 100644 --- a/doc/dashboards/Sysmon - IBM Power.json +++ b/doc/dashboards/Sysmon - IBM Power.json @@ -196,7 +196,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -218,6 +218,12 @@ "params": [], "type": "mean" }, + { + "params": [ + 10 + ], + "type": "moving_average" + }, { "params": [ "5min" @@ -340,7 +346,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -361,6 +367,12 @@ { "params": [], "type": "mean" + }, + { + "params": [ + 10 + ], + "type": "moving_average" } ] ], @@ -478,7 +490,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -499,6 +511,12 @@ { "params": [], "type": "mean" + }, + { + "params": [ + 10 + ], + "type": "moving_average" } ] ], @@ -617,7 +635,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -638,6 +656,12 @@ { "params": [], "type": "mean" + }, + { + "params": [ + 10 + ], + "type": "moving_average" } ] ], @@ -709,6 +733,6 @@ "timezone": "", "title": "Sysmon - IBM Power", "uid": "3zPCIbN4z", - "version": 6, + "version": 7, "weekStart": "" } \ No newline at end of file diff --git a/doc/dashboards/Sysmon - Process Explorer.json b/doc/dashboards/Sysmon - Process Explorer.json index 05a5dc4..1f89ee5 100644 --- a/doc/dashboards/Sysmon - Process Explorer.json +++ b/doc/dashboards/Sysmon - Process Explorer.json @@ -697,7 +697,7 @@ }, { "params": [ - "null" + "none" ], "type": "fill" } @@ -722,8 +722,10 @@ "type": "sum" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -744,8 +746,10 @@ "type": "sum" }, { - "params": [], - "type": "non_negative_difference" + "params": [ + "$__interval" + ], + "type": "non_negative_derivative" }, { "params": [ @@ -961,7 +965,9 @@ "refresh": "1m", "schemaVersion": 37, "style": "dark", - "tags": [], + "tags": [ + "sysmon" + ], "templating": { "list": [ { @@ -1049,6 +1055,6 @@ "timezone": "", "title": "Sysmon - Process Explorer", "uid": "Vjut5mS7k", - "version": 3, + "version": 5, "weekStart": "" } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 7f28159..4a8b07b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version = 1.0.23 +version = 1.0.24 pf4jVersion = 3.7.0 slf4jVersion = 2.0.3 camelVersion = 3.14.5 diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java index 0ad3adf..9703cd1 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseDiskExtension.java @@ -27,6 +27,8 @@ public class BaseDiskExtension implements MetricExtension { private String interval = "10s"; private HardwareAbstractionLayer hardwareAbstractionLayer; + private List diskStores; + private int refreshCounter = 0; @Override @@ -82,10 +84,15 @@ public class BaseDiskExtension implements MetricExtension { public MetricResult getMetrics() { ArrayList measurementList = new ArrayList<>(); - List diskStores = hardwareAbstractionLayer.getDiskStores(); + if(diskStores == null || refreshCounter++ > 360) { + log.info("getMetrics() - refreshing list of disk stores"); + diskStores = hardwareAbstractionLayer.getDiskStores(); + refreshCounter = 0; + } for(HWDiskStore store : diskStores) { + store.updateAttributes(); String name = store.getName(); if (name.matches("h?disk[0-9]+") || //name.matches("/dev/dm-[0-9]+") || diff --git a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseFilesystemExtension.java b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseFilesystemExtension.java index a68d611..f6c460b 100644 --- a/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseFilesystemExtension.java +++ b/plugins/os-base/src/main/java/sysmon/plugins/os_base/BaseFilesystemExtension.java @@ -36,6 +36,8 @@ public class BaseFilesystemExtension implements MetricExtension { private HardwareAbstractionLayer hardwareAbstractionLayer; private SystemInfo systemInfo; + private List fileStores; + private int refreshCounter = 0; @Override @@ -103,7 +105,10 @@ public class BaseFilesystemExtension implements MetricExtension { ArrayList alreadyProcessed = new ArrayList<>(); ArrayList measurementList = new ArrayList<>(); - List fileStores = systemInfo.getOperatingSystem().getFileSystem().getFileStores(true); + + if(fileStores == null || refreshCounter++ > 360) { + fileStores = systemInfo.getOperatingSystem().getFileSystem().getFileStores(true); + } for(OSFileStore store : fileStores) { @@ -125,7 +130,9 @@ public class BaseFilesystemExtension implements MetricExtension { log.debug("Skipping name: " + name); continue; } + alreadyProcessed.add(name); + store.updateAttributes(); TreeMap tagsMap = new TreeMap() {{ put("name", name); diff --git a/server/build.gradle b/server/build.gradle index 669bc15..d63cdbb 100644 --- a/server/build.gradle +++ b/server/build.gradle @@ -28,7 +28,7 @@ def projectName = "sysmon-server" application { // Define the main class for the application. mainClass.set('sysmon.server.Application') - applicationDefaultJvmArgs = [ "-server", "-Xms64m", "-Xmx64m", "-XX:+ExitOnOutOfMemoryError", "-XX:+AlwaysPreTouch" ] + applicationDefaultJvmArgs = [ "-Xms64m", "-Xmx64m", "-XX:+ExitOnOutOfMemoryError", "-XX:+AlwaysPreTouch" ] } run { diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index cfdc8be..fa39ff4 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -15,18 +15,5 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -# to configure camel main -# here you can configure options on camel main (see MainConfigurationProperties class) camel.main.name = sysmon-server - -# enable tracing -#camel.main.tracing = true - -# bean introspection to log reflection based configuration -#camel.main.beanIntrospectionExtendedStatistics=true -#camel.main.beanIntrospectionLoggingLevel=INFO - -# run in lightweight mode to be tiny as possible camel.main.lightweight = true -# and eager load classes -#camel.main.eager-classloading = true