diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8c406b2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [0.1.10] - 2022-03-01 +### Added +- (client) More debug options. +- (plugins/linux) Re-enabled network socket-statistics extension. +### Changed +- Updated the oshi dependency to v. 6.1.4. +- (plugins/aix) Improved AIX lparstat parsing. +- (plugins/aix) More debug output from (Power) processor extension. +- (plugins/base) More debug output from plugins-base disk extension. + +## [0.1.9] - 2022-02-15 +### Changed +- Updated 3rd party dependencies. + +[0.1.10]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v0.1.10%0Dv0.1.9 +[0.1.9]: https://bitbucket.org/mnellemann/sysmon/branches/compare/v0.1.9%0Dv0.1.8 diff --git a/client/README.md b/client/README.md index db3eabd..ab2a609 100644 --- a/client/README.md +++ b/client/README.md @@ -1,6 +1,6 @@ # Client / Agent -This is the client component of SysMon. Install on the hosts where you want to collect metrics. +This is the client/agent component of SysMon, which you install (together with sysmon-plugins) on the hosts where you want to collect metrics. ## Installation diff --git a/client/src/main/java/sysmon/client/Application.java b/client/src/main/java/sysmon/client/Application.java index 7756c9d..c7c2111 100644 --- a/client/src/main/java/sysmon/client/Application.java +++ b/client/src/main/java/sysmon/client/Application.java @@ -28,9 +28,11 @@ public class Application implements Callable { @CommandLine.Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/sysmon-client.toml'].", paramLabel = "", defaultValue = "/etc/sysmon-client.toml") private File configurationFile; - @CommandLine.Option(names = { "-d", "--debug" }, description = "Enable debugging (default: ${DEFAULT_VALUE}).") - private boolean enableDebug = false; + //@CommandLine.Option(names = { "-d", "--debug" }, description = "Enable debugging (default: ${DEFAULT_VALUE}).") + //private boolean enableDebug = false; + @CommandLine.Option(names = { "-d", "--debug" }, description = "Enable debugging (default: ${DEFAULT_VALUE}).") + private boolean[] enableDebug = new boolean[0]; public static void main(String... args) { int exitCode = new CommandLine(new Application()).execute(args); @@ -42,10 +44,22 @@ public class Application implements Callable { public Integer call() { String sysmonDebug = System.getProperty("sysmon.debug"); - if(sysmonDebug != null || enableDebug) { + if(sysmonDebug != null) { System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO"); } + switch (enableDebug.length) { + case 1: + System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "INFO"); + break; + case 2: + System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG"); + break; + case 3: + System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE"); + break; + } + String sysmonCfgFile = System.getProperty("sysmon.cfgFile"); if(sysmonCfgFile != null) { configurationFile = new File(sysmonCfgFile); diff --git a/gradle.properties b/gradle.properties index 5fc029a..1612ce6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ pf4jVersion = 3.6.0 slf4jVersion = 1.7.36 camelVersion = 3.14.1 picocliVersion = 4.6.3 -oshiVersion = 6.1.3 \ No newline at end of file +oshiVersion = 6.1.4 \ No newline at end of file diff --git a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java index ee158a0..cb0fa0c 100644 --- a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java +++ b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorExtension.java @@ -94,6 +94,7 @@ public class AixProcessorExtension implements MetricExtension { log.error("lparstat error", e); } + log.debug("getMetrics() - tags: {}, fields: {}", tagsMap, fieldsMap); return new MetricResult(name, new Measurement(tagsMap, fieldsMap)); } diff --git a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorStat.java b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorStat.java index ecb316b..947b311 100644 --- a/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorStat.java +++ b/plugins/os-aix/src/main/java/sysmon/plugins/os_aix/AixProcessorStat.java @@ -52,6 +52,7 @@ public class AixProcessorStat { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); while(reader.ready()) { String line = reader.readLine(); + log.trace("AixProcessorStat() - {}", line); if (line.startsWith("System configuration:")) { Matcher matcher = patternAixShared.matcher(line); 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 499229e..0980272 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 @@ -94,6 +94,7 @@ public class BaseDiskExtension implements MetricExtension { put("queue", store.getCurrentQueueLength()); }}; + log.debug("getMetrics() - tags: {}, fields: {}", tagsMap, fieldsMap); measurementList.add(new Measurement(tagsMap, fieldsMap)); } diff --git a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSockstatExtension.java b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSocketExtension.java similarity index 82% rename from plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSockstatExtension.java rename to plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSocketExtension.java index 14af318..6526df5 100644 --- a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSockstatExtension.java +++ b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSocketExtension.java @@ -12,11 +12,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -// Disabled -//@Extension -public class LinuxSockstatExtension implements MetricExtension { +@Extension +public class LinuxSocketExtension implements MetricExtension { - private static final Logger log = LoggerFactory.getLogger(LinuxSockstatExtension.class); + private static final Logger log = LoggerFactory.getLogger(LinuxSocketExtension.class); // Extension details private final String name = "linux_network_sockets"; @@ -77,16 +76,17 @@ public class LinuxSockstatExtension implements MetricExtension { @Override public MetricResult getMetrics() { - LinuxNetworkSockStat sockStat = processSockOutput(PluginHelper.readFile("/proc/net/sockstat")); + LinuxSocketStat sockStat = processSockOutput(PluginHelper.readFile("/proc/net/sockstat")); HashMap tagsMap = sockStat.getTags(); HashMap fieldsMap = sockStat.getFields(); + log.debug("getMetrics() - tags: {}, fields: {}", tagsMap, fieldsMap); return new MetricResult(name, new Measurement(tagsMap, fieldsMap)); } - protected LinuxNetworkSockStat processSockOutput(List inputLines) { - return new LinuxNetworkSockStat(inputLines); + protected LinuxSocketStat processSockOutput(List inputLines) { + return new LinuxSocketStat(inputLines); } } diff --git a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetworkSockStat.java b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSocketStat.java similarity index 96% rename from plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetworkSockStat.java rename to plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSocketStat.java index 4d27d58..89ffd1b 100644 --- a/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxNetworkSockStat.java +++ b/plugins/os-linux/src/main/java/sysmon/plugins/os_linux/LinuxSocketStat.java @@ -8,9 +8,9 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class LinuxNetworkSockStat { +public class LinuxSocketStat { - private static final Logger log = LoggerFactory.getLogger(LinuxNetworkSockStat.class); + private static final Logger log = LoggerFactory.getLogger(LinuxSocketStat.class); private static final Pattern pattern1 = Pattern.compile("^sockets: used (\\d+)"); private static final Pattern pattern2 = Pattern.compile("^TCP: inuse (\\d+) orphan (\\d+) tw (\\d+) alloc (\\d+) mem (\\d+)"); @@ -35,7 +35,7 @@ public class LinuxNetworkSockStat { */ - LinuxNetworkSockStat(List lines) { + LinuxSocketStat(List lines) { Matcher matcher; for(String line : lines) { diff --git a/plugins/os-linux/src/test/groovy/LinuxNetworkTest.groovy b/plugins/os-linux/src/test/groovy/LinuxNetworkTest.groovy index 9e81d93..ae697ce 100644 --- a/plugins/os-linux/src/test/groovy/LinuxNetworkTest.groovy +++ b/plugins/os-linux/src/test/groovy/LinuxNetworkTest.groovy @@ -1,6 +1,6 @@ import spock.lang.Specification -import sysmon.plugins.os_linux.LinuxSockstatExtension -import sysmon.plugins.os_linux.LinuxNetworkSockStat +import sysmon.plugins.os_linux.LinuxSocketExtension +import sysmon.plugins.os_linux.LinuxSocketStat class LinuxNetworkTest extends Specification { @@ -11,8 +11,8 @@ class LinuxNetworkTest extends Specification { List lines = testFile.readLines("UTF-8") when: - LinuxSockstatExtension extension = new LinuxSockstatExtension() - LinuxNetworkSockStat stats = extension.processSockOutput(lines) + LinuxSocketExtension extension = new LinuxSocketExtension() + LinuxSocketStat stats = extension.processSockOutput(lines) then: stats.getFields().get("sockets") == 1238L diff --git a/server/src/main/java/sysmon/server/Application.java b/server/src/main/java/sysmon/server/Application.java index e95b5e7..9f80a0b 100644 --- a/server/src/main/java/sysmon/server/Application.java +++ b/server/src/main/java/sysmon/server/Application.java @@ -53,13 +53,6 @@ public class Application implements Callable { } InfluxDB influxDB = InfluxDBFactory.connect(influxUrl.toString(), influxUser, influxPass); - /* - try { - influxDB.query(new Query("CREATE DATABASE " + influxName)); - } catch (InfluxDBException e) { - System.err.println(e.getMessage()); - return -1; - }*/ Main main = new Main(); main.bind("myInfluxConnection", influxDB);