From 109f503a72c1864616baca83e7083b3191fe36dd Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Mon, 10 Jun 2024 09:47:49 +0200 Subject: [PATCH 1/3] Monitor sleep overrun --- CHANGELOG.md | 4 + client/doc/sysmon-client.toml | 4 +- gradle.properties | 2 +- .../plugins/base/BaseDiskExtension.java | 2 +- .../plugins/base/BaseFilesystemExtension.java | 2 +- .../plugins/base/BaseLatencyExtension.java | 104 ++++++++++++++++++ .../plugins/base/BaseLoadExtension.java | 2 +- .../plugins/base/BaseMemoryExtension.java | 2 +- .../plugins/base/BaseNetstatExtension.java | 2 +- .../plugins/base/BaseNetworkExtension.java | 2 +- .../plugins/base/BaseProcessorExtension.java | 2 +- 11 files changed, 118 insertions(+), 10 deletions(-) create mode 100644 plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java diff --git a/CHANGELOG.md b/CHANGELOG.md index baa56b9..b429f96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [1.1.9] - 2024-06-xx +- Adjust defaults intervals from 10s to 30s +- Send sleep overrun + ## [1.1.8] - 2024-05-14 - Update 3rd party dependencies - Avoid infinite timeout on http connections to server (max 1s now) diff --git a/client/doc/sysmon-client.toml b/client/doc/sysmon-client.toml index 279e67a..2ea8247 100644 --- a/client/doc/sysmon-client.toml +++ b/client/doc/sysmon-client.toml @@ -22,11 +22,11 @@ interval = '60m' [extension.base_disk] enabled = true -interval = '10s' +interval = '30s' [extension.base_filesystem] enabled = true -interval = '10s' +interval = '30s' exclude_type = [ "tmpfs", "ahafs" ] exclude_mount = [ "/boot/efi" ] diff --git a/gradle.properties b/gradle.properties index 28e0313..daa014e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ slf4jVersion = 2.0.12 camelVersion = 3.14.10 groovyVersion = 3.0.21 picocliVersion = 4.7.6 -oshiVersion = 6.6.0 +oshiVersion = 6.6.1 spockVersion = 2.3-groovy-3.0 tomljVersion = 1.1.1 osPackageVersion = 11.8.1 diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseDiskExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseDiskExtension.java index 1f0b484..7ba53fc 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseDiskExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseDiskExtension.java @@ -23,7 +23,7 @@ public class BaseDiskExtension implements MetricExtension { // Configuration / Options private boolean enabled = true; private boolean threaded = false; - private String interval = "10s"; + private String interval = "30s"; private HardwareAbstractionLayer hardwareAbstractionLayer; private List diskStores; diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseFilesystemExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseFilesystemExtension.java index bbfe1ac..22caade 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseFilesystemExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseFilesystemExtension.java @@ -23,7 +23,7 @@ public class BaseFilesystemExtension implements MetricExtension { // Configuration / Options private boolean enabled = true; private boolean threaded = false; - private String interval = "10s"; + private String interval = "60s"; private List excludeType = new ArrayList() {{ add("tmpfs"); add("ahafs"); diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java new file mode 100644 index 0000000..85b62e1 --- /dev/null +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java @@ -0,0 +1,104 @@ +package sysmon.plugins.base; + +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; + +import org.pf4j.Extension; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import oshi.SystemInfo; +import sysmon.shared.Measurement; +import sysmon.shared.MetricExtension; +import sysmon.shared.MetricResult; + +@Extension +public class BaseLatencyExtension implements MetricExtension { + + private static final Logger log = LoggerFactory.getLogger(BaseLatencyExtension.class); + + private final int sleepTimeMillis = 5000; + + // Extension details + private final String name = "base_latency"; + private final String description = "Base Latency Information"; + + // Configuration / Options + private boolean enabled = true; + private boolean threaded = true; + private String interval = "30s"; + private final HashMap tags = new HashMap<>(); + + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public boolean isThreaded() { + return threaded; + } + + @Override + public boolean isSupported() { + SystemInfo systemInfo = BasePlugin.getSystemInfo(); + return systemInfo != null; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getInterval() { return interval; } + + @Override + public String getDescription() { + return description; + } + + @Override + public void setConfiguration(Map map) { + if (map.containsKey("enabled")) { + enabled = (boolean) map.get("enabled"); + } + if (map.containsKey("threaded")) { + threaded = (boolean) map.get("threaded"); + } + if (map.containsKey("interval")) { + interval = (String) map.get("interval"); + } + } + + @Override + public MetricResult getMetrics() { + + // TODO: Calculate execution time for sysmon-client to monitor drift + // Available from Java 9 + //long pid = ProcessHandle.current().pid(); + + // Calculate sleep-overrun in milliseconds + long sleepOverrun = 0; + try { + long nanoTime1 = System.nanoTime(); + Thread.sleep(sleepTimeMillis); + long nanoTime2 = System.nanoTime(); + long nanoDiff = nanoTime2 - nanoTime1; + sleepOverrun = (nanoDiff / 1_000_000) - sleepTimeMillis; + log.warn("Sleep Overrun: {}", sleepOverrun); + } catch (InterruptedException e) { + log.error("getMetrics() - error: {}", e.getMessage()); + } + + long finalSleepOverrun = sleepOverrun; + TreeMap fieldsMap = new TreeMap() {{ + put("overrun", finalSleepOverrun); + }}; + return new MetricResult(name, new Measurement(tags, fieldsMap)); + + } + +} diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseLoadExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseLoadExtension.java index 7e61a77..1bfb9bd 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseLoadExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseLoadExtension.java @@ -23,7 +23,7 @@ public class BaseLoadExtension implements MetricExtension { // Configuration / Options private boolean enabled = true; private boolean threaded = false; - private String interval = "10s"; + private String interval = "30s"; private HardwareAbstractionLayer hardwareAbstractionLayer; diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseMemoryExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseMemoryExtension.java index 5a2f267..511d778 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseMemoryExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseMemoryExtension.java @@ -23,7 +23,7 @@ public class BaseMemoryExtension implements MetricExtension { // Configuration / Options private boolean enabled = true; private boolean threaded = false; - private String interval = "10s"; + private String interval = "30s"; private HardwareAbstractionLayer hardwareAbstractionLayer; diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseNetstatExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseNetstatExtension.java index eaac0f9..1cafbd2 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseNetstatExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseNetstatExtension.java @@ -22,7 +22,7 @@ public class BaseNetstatExtension implements MetricExtension { // Configuration / Options private boolean enabled = true; private boolean threaded = false; - private String interval = "10s"; + private String interval = "30s"; private SystemInfo systemInfo; diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseNetworkExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseNetworkExtension.java index 2c9d376..20a89c0 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseNetworkExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseNetworkExtension.java @@ -23,7 +23,7 @@ public class BaseNetworkExtension implements MetricExtension { // Configuration / Options private boolean enabled = true; private boolean threaded = false; - private String interval = "10s"; + private String interval = "30s"; private HardwareAbstractionLayer hardwareAbstractionLayer; private List interfaces; diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseProcessorExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseProcessorExtension.java index 545a053..375d985 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseProcessorExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseProcessorExtension.java @@ -25,7 +25,7 @@ public class BaseProcessorExtension implements MetricExtension { // Configuration / Options private boolean enabled = true; private boolean threaded = false; - private String interval = "10s"; + private String interval = "30s"; private HardwareAbstractionLayer hardwareAbstractionLayer; private long[] oldTicks; From abe96473d189da90a2e1e33351325b8df7a8b95d Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Sun, 30 Jun 2024 20:47:09 +0200 Subject: [PATCH 2/3] Renamed client to agent. --- .drone.yml | 4 ++-- CHANGELOG.md | 6 ++++-- README.md | 14 +++++++------- agent/README.md | 17 +++++++++++++++++ {client => agent}/build.gradle | 10 +++++----- {client => agent}/doc/readme-aix.md | 10 +++++----- {client => agent}/doc/readme-linux.md | 12 ++++++------ .../doc/scripts/ExampleScript.groovy | 0 {client => agent}/doc/scripts/README.md | 0 .../doc/sysmon-agent.service | 4 ++-- .../doc/sysmon-agent.sh | 6 +++--- .../doc/sysmon-agent.toml | 2 +- {client => agent}/scripts/install.sh | 8 ++++++-- {client => agent}/scripts/remove.sh | 4 ++-- agent/scripts/shared.sh | 7 +++++++ .../java/sysmon/agent/AgentRouteBuilder.java | 6 +++--- .../main/java/sysmon/agent}/Application.java | 8 ++++---- .../main/java/sysmon/agent}/ComboAppender.java | 2 +- .../main/java/sysmon/agent}/Configuration.java | 2 +- .../sysmon/agent}/ListOfResultsStrategy.java | 2 +- .../sysmon/agent}/MetricEnrichProcessor.java | 2 +- .../main/java/sysmon/agent}/ScriptWrapper.java | 2 +- .../src/main/resources/application.properties | 2 +- .../src/main/resources/simplelogger.properties | 0 .../test/groovy/sysmon/agent}/AppTest.groovy | 2 +- .../src/test/resources/simplelogger.properties | 0 build.gradle | 4 ++-- client/README.md | 17 ----------------- client/scripts/shared.sh | 7 ------- gradle.properties | 4 ++-- .../plugins/base/BaseLatencyExtension.java | 4 ++-- plugins/build.gradle | 4 ++-- server/doc/readme-aix.md | 2 +- server/scripts/install.sh | 5 ++--- server/scripts/remove.sh | 4 ++-- .../src/main/resources/application.properties | 2 +- settings.gradle | 2 +- 37 files changed, 96 insertions(+), 91 deletions(-) create mode 100644 agent/README.md rename {client => agent}/build.gradle (93%) rename {client => agent}/doc/readme-aix.md (51%) rename {client => agent}/doc/readme-linux.md (65%) rename {client => agent}/doc/scripts/ExampleScript.groovy (100%) rename {client => agent}/doc/scripts/README.md (100%) rename client/doc/sysmon-client.service => agent/doc/sysmon-agent.service (63%) rename client/doc/sysmon-client.sh => agent/doc/sysmon-agent.sh (96%) rename client/doc/sysmon-client.toml => agent/doc/sysmon-agent.toml (97%) rename {client => agent}/scripts/install.sh (78%) rename {client => agent}/scripts/remove.sh (90%) create mode 100644 agent/scripts/shared.sh rename client/src/main/java/sysmon/client/ClientRouteBuilder.java => agent/src/main/java/sysmon/agent/AgentRouteBuilder.java (97%) rename {client/src/main/java/sysmon/client => agent/src/main/java/sysmon/agent}/Application.java (91%) rename {client/src/main/java/sysmon/client => agent/src/main/java/sysmon/agent}/ComboAppender.java (94%) rename {client/src/main/java/sysmon/client => agent/src/main/java/sysmon/agent}/Configuration.java (99%) rename {client/src/main/java/sysmon/client => agent/src/main/java/sysmon/agent}/ListOfResultsStrategy.java (94%) rename {client/src/main/java/sysmon/client => agent/src/main/java/sysmon/agent}/MetricEnrichProcessor.java (97%) rename {client/src/main/java/sysmon/client => agent/src/main/java/sysmon/agent}/ScriptWrapper.java (98%) rename {client => agent}/src/main/resources/application.properties (97%) rename {client => agent}/src/main/resources/simplelogger.properties (100%) rename {client/src/test/groovy/sysmon/client => agent/src/test/groovy/sysmon/agent}/AppTest.groovy (77%) rename {client => agent}/src/test/resources/simplelogger.properties (100%) delete mode 100644 client/README.md delete mode 100644 client/scripts/shared.sh diff --git a/.drone.yml b/.drone.yml index 507f360..2492939 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,8 +17,8 @@ steps: - ./gradlew build packages shared:publishLibraryPublicationToGiteaRepository - for file in server/build/distributions/*.deb ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done - for file in server/build/distributions/*.rpm ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done - - for file in client/build/distributions/*.deb ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done - - for file in client/build/distributions/*.rpm ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done + - for file in agent/build/distributions/*.deb ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done + - for file in agent/build/distributions/*.rpm ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done - for file in plugins/build/distributions/*.deb ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done - for file in plugins/build/distributions/*.rpm ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done when: diff --git a/CHANGELOG.md b/CHANGELOG.md index b429f96..d23c2c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ All notable changes to this project will be documented in this file. -## [1.1.9] - 2024-06-xx +## [1.2.1] - 2024-07-xx - Adjust defaults intervals from 10s to 30s -- Send sleep overrun +- Measure sleep overrun +- Rename client to agent + - When upgrading, ensure any *client* related init-scripts are removed ## [1.1.8] - 2024-05-14 - Update 3rd party dependencies diff --git a/README.md b/README.md index 7a0bc24..783f8d4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This software is free to use and is licensed under the [Apache 2.0 License](LICE Some of my other related projects are: - [hmci](https://github.com/mnellemann/hmci) for agent-less monitoring of IBM Power servers -- [svci](https://github.com/mnellemann/svci) for monitoring IBM Spectrum Virtualize (Flashsystems / Storwize / SVC) +- [svci](https://github.com/mnellemann/svci) for monitoring IBM Storage Virtualize (Flashsystems / Storwize / SVC) - [syslogd](https://github.com/mnellemann/syslogd) for redirecting syslog and GELF to other logging destinations ## Screenshots @@ -26,18 +26,18 @@ Screenshots of other dashboards are available in the [doc/screenshots](doc/scree ### Server -The server component receives aggregated metrics from *clients* and saves these into InfluxDB. +The server component receives aggregated metrics from *agents* and saves these into InfluxDB. - Downloaded server package from [releases](https://github.com/mnellemann/sysmon/releases). - More information and documentation on the [sysmon-server](server/README.md). -### Client & Plugins +### Agent & Plugins -The client runs on all or some of your hosts and collects metrics, which are then sent to the central sysmon-server component. Plugins are loaded by the client at startup and should also be installed. +The agent runs on all or some of your hosts and collects metrics, which are then sent to the central sysmon-server component. Plugins are loaded by the agent at startup and should also be installed. -- Downloaded client & plugin packages from [releases](https://github.com/mnellemann/sysmon/releases). -- More information and documentation on the [sysmon-client](client/README.md). -. More information and documentation on the [sysmon-plugins](plugins/README.md). +- Downloaded agent & plugin packages from [releases](https://github.com/mnellemann/sysmon/releases). +- More information and documentation on the [sysmon-agent](agent/README.md). +- More information and documentation on the [sysmon-plugins](plugins/README.md). ## Known problems diff --git a/agent/README.md b/agent/README.md new file mode 100644 index 0000000..1a0e0b2 --- /dev/null +++ b/agent/README.md @@ -0,0 +1,17 @@ +# Agent + +This is the monitoring agent sysmon, which you install (together with sysmon-plugins) on your hosts. + +## Installation + +Download *.deb* or *.rpm* packages for sysmon-agent *and* sysmon-plugins, and install. + +## Development + +### Build & Test + +Use the gradle build tool, which will download all required dependencies: + +```shell +./gradlew clean build +``` diff --git a/client/build.gradle b/agent/build.gradle similarity index 93% rename from client/build.gradle rename to agent/build.gradle index 03e2ab7..d55c535 100644 --- a/client/build.gradle +++ b/agent/build.gradle @@ -36,17 +36,17 @@ dependencies { } -def projectName = "sysmon-client" +def projectName = "sysmon-agent" application { // Define the main class for the application. - mainClass.set('sysmon.client.Application') - applicationDefaultJvmArgs = [ "-Xms64m", "-Xmx64m", "-XX:+ExitOnOutOfMemoryError", "-XX:+AlwaysPreTouch" ] + mainClass.set('sysmon.agent.Application') + applicationDefaultJvmArgs = [ "-Xms16m", "-Xmx64m", "-XX:+ExitOnOutOfMemoryError", "-XX:+AlwaysPreTouch" ] } run { systemProperty 'sysmon.pluginsDir', '../plugins/output/' - systemProperty 'sysmon.cfgFile', 'doc/sysmon-client.toml' + systemProperty 'sysmon.cfgFile', 'doc/sysmon-agent.toml' systemProperty 'sysmon.debug', '1' } @@ -82,7 +82,7 @@ ospackage { user = 'root' packager = "Mark Nellemann " - into '/opt/sysmon/client' + into '/opt/sysmon/agent' from(shadowJar.outputs.files) { into 'lib' diff --git a/client/doc/readme-aix.md b/agent/doc/readme-aix.md similarity index 51% rename from client/doc/readme-aix.md rename to agent/doc/readme-aix.md index 3caa73e..2d68d31 100644 --- a/client/doc/readme-aix.md +++ b/agent/doc/readme-aix.md @@ -4,16 +4,16 @@ Works on IBM Power VIO (Virtual IO) servers, as well as regular IBM Power AIX in ## Installation -We require Java 8, which should already be installed on AIX, or is available to install. +Requires Java 8 (or later), which should already be installed on AIX, or is available to install. The RPM packages are *"noarch"* Java bytecode, so we can use the **--ignoreos** option to install: ```shell -rpm -ivh --ignoreos sysmon-client-*.rpm sysmon-plugins-*.rpm +rpm -ivh --ignoreos sysmon-agent-*.rpm sysmon-plugins-*.rpm ``` ## Configuration -Edit **/etc/sysmon-client.toml** and modify the server URL. +Edit **/etc/sysmon-agent.toml** and modify the server URL. ## Upgrades @@ -23,8 +23,8 @@ To upgrade the packages: rpm -Uvh --ignoreos sysmon-*.rpm ``` -To restart sysmon-client process after upgrade: +To restart sysmon-agent process after upgrade: ```shell -/etc/rc.d/init.d/sysmon-client stop; /etc/rc.d/init.d/sysmon-client start +/etc/rc.d/init.d/sysmon-agent stop; /etc/rc.d/init.d/sysmon-agent start ``` diff --git a/client/doc/readme-linux.md b/agent/doc/readme-linux.md similarity index 65% rename from client/doc/readme-linux.md rename to agent/doc/readme-linux.md index 3b3181d..68e2491 100644 --- a/client/doc/readme-linux.md +++ b/agent/doc/readme-linux.md @@ -11,13 +11,13 @@ Java 8 (or later) runtime is required. ## Installation -[Download](https://github.com/mnellemann/sysmon/releases) the latest client and plugins rpm or deb files. +[Download](https://github.com/mnellemann/sysmon/releases) the latest agent and plugins rpm/deb packages. ### RedHat Linux ```shell sudo dnf install java-11-openjdk-headless -sudo rpm -ivh sysmon-client-*.noarch.rpm sysmon-plugins-*.rpm +sudo rpm -ivh sysmon-agent-*.noarch.rpm sysmon-plugins-*.rpm ``` Use *yum* if *dnf* is not available. @@ -26,18 +26,18 @@ Use *yum* if *dnf* is not available. ```shell sudo zypper install java-11-openjdk-headless -sudo zypper install sysmon-client-*.noarch.rpm sysmon-plugins-*.rpm +sudo zypper install sysmon-agent-*.noarch.rpm sysmon-plugins-*.rpm ``` ### Debian/Ubuntu Linux ```shell sudo apt install default-jre-headless -sudo dpkg -i sysmon-client-*.deb sysmon-plugins-*.deb +sudo dpkg -i sysmon-agent-*.deb sysmon-plugins-*.deb ``` ## Configuration -Edit **/etc/sysmon-client.toml** and modify the server URL. +Edit **/etc/sysmon-agent.toml** and modify the server URL. -Check logs for errors with: ```journalctl -u sysmon-client``` +Check logs for errors with: ```journalctl -u sysmon-agent``` diff --git a/client/doc/scripts/ExampleScript.groovy b/agent/doc/scripts/ExampleScript.groovy similarity index 100% rename from client/doc/scripts/ExampleScript.groovy rename to agent/doc/scripts/ExampleScript.groovy diff --git a/client/doc/scripts/README.md b/agent/doc/scripts/README.md similarity index 100% rename from client/doc/scripts/README.md rename to agent/doc/scripts/README.md diff --git a/client/doc/sysmon-client.service b/agent/doc/sysmon-agent.service similarity index 63% rename from client/doc/sysmon-client.service rename to agent/doc/sysmon-agent.service index c66ee86..b7b0574 100644 --- a/client/doc/sysmon-client.service +++ b/agent/doc/sysmon-agent.service @@ -1,12 +1,12 @@ [Unit] -Description=Sysmon Client +Description=Sysmon Agent [Service] #User=nobody #Group=nobody TimeoutSec=20 Restart=on-failure -ExecStart=/opt/sysmon/client/bin/client +ExecStart=/opt/sysmon/agent/bin/agent [Install] WantedBy=default.target diff --git a/client/doc/sysmon-client.sh b/agent/doc/sysmon-agent.sh similarity index 96% rename from client/doc/sysmon-client.sh rename to agent/doc/sysmon-agent.sh index a9833e4..197a11b 100644 --- a/client/doc/sysmon-client.sh +++ b/agent/doc/sysmon-agent.sh @@ -9,12 +9,12 @@ # Description: Enable service provided by daemon. ### END INIT INFO -dir="/opt/sysmon/client" -cmd="/opt/sysmon/client/bin/client" +dir="/opt/sysmon/agent" +cmd="/opt/sysmon/agent/bin/agent" args="" user="" -name="sysmon-client" +name="sysmon-agent" pid_file="/var/run/$name.pid" stdout_log="/var/log/$name.log" stderr_log="/var/log/$name.err" diff --git a/client/doc/sysmon-client.toml b/agent/doc/sysmon-agent.toml similarity index 97% rename from client/doc/sysmon-client.toml rename to agent/doc/sysmon-agent.toml index 2ea8247..8d704be 100644 --- a/client/doc/sysmon-client.toml +++ b/agent/doc/sysmon-agent.toml @@ -1,5 +1,5 @@ ### -### Sysmon Client +### Sysmon Agent ### ### Example configuration with some default values. ### diff --git a/client/scripts/install.sh b/agent/scripts/install.sh similarity index 78% rename from client/scripts/install.sh rename to agent/scripts/install.sh index e0b2f9c..7c5a2ff 100644 --- a/client/scripts/install.sh +++ b/agent/scripts/install.sh @@ -1,6 +1,10 @@ #!/bin/sh install_config() { + # Migrate from old (name) configuration file + test -f "/etc/sysmon-client.toml" && mv "/etc/sysmon-client.toml" "/etc/${service_name}.toml" + + # Install default configuration file test -f "/etc/${service_name}.toml" || cp "${config_source}" "/etc/${service_name}.toml" } @@ -24,8 +28,8 @@ install_sysv_linux() { install_sysv_aix() { test -f "/etc/rc.d/init.d/${service_name}" || cp "${sysv_source}" "/etc/rc.d/init.d/${service_name}" chmod 0755 "/etc/rc.d/init.d/${service_name}" - ln -sf /etc/rc.d/init.d/sysmon-client /etc/rc.d/rc2.d/Ssysmon-client - ln -sf /etc/rc.d/init.d/sysmon-client /etc/rc.d/rc2.d/Ksysmon-client + ln -sf /etc/rc.d/init.d/sysmon-agent /etc/rc.d/rc2.d/Ssysmon-agent + ln -sf /etc/rc.d/init.d/sysmon-agent /etc/rc.d/rc2.d/Ksysmon-agent } install_sysv() { diff --git a/client/scripts/remove.sh b/agent/scripts/remove.sh similarity index 90% rename from client/scripts/remove.sh rename to agent/scripts/remove.sh index a21d03c..6303388 100644 --- a/client/scripts/remove.sh +++ b/agent/scripts/remove.sh @@ -19,8 +19,8 @@ remove_sysv_linux() { remove_sysv_aix() { /etc/rc.d/init.d/${service_name} stop - rm -f /etc/rc.d/init.d/sysmon-client /etc/rc.d/rc2.d/Ksysmon-client - rm -f /etc/rc.d/rc2.d/Ssysmon-client + rm -f /etc/rc.d/init.d/sysmon-agent /etc/rc.d/rc2.d/Ksysmon-agent + rm -f /etc/rc.d/rc2.d/Ssysmon-agent } remove_sysv() { diff --git a/agent/scripts/shared.sh b/agent/scripts/shared.sh new file mode 100644 index 0000000..4292bf3 --- /dev/null +++ b/agent/scripts/shared.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +service_name="sysmon-agent" +sysv_source="/opt/sysmon/agent/doc/sysmon-agent.sh" +config_source="/opt/sysmon/agent/doc/sysmon-agent.toml" +systemd_source="/opt/sysmon/agent/doc/sysmon-agent.service" + diff --git a/client/src/main/java/sysmon/client/ClientRouteBuilder.java b/agent/src/main/java/sysmon/agent/AgentRouteBuilder.java similarity index 97% rename from client/src/main/java/sysmon/client/ClientRouteBuilder.java rename to agent/src/main/java/sysmon/agent/AgentRouteBuilder.java index 81f3f8e..1abc5ce 100644 --- a/client/src/main/java/sysmon/client/ClientRouteBuilder.java +++ b/agent/src/main/java/sysmon/agent/AgentRouteBuilder.java @@ -1,4 +1,4 @@ -package sysmon.client; +package sysmon.agent; import org.apache.camel.Exchange; import org.apache.camel.LoggingLevel; @@ -26,9 +26,9 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -public class ClientRouteBuilder extends RouteBuilder { +public class AgentRouteBuilder extends RouteBuilder { - private static final Logger log = LoggerFactory.getLogger(ClientRouteBuilder.class); + private static final Logger log = LoggerFactory.getLogger(AgentRouteBuilder.class); private final Set scriptFiles = new HashSet<>(); diff --git a/client/src/main/java/sysmon/client/Application.java b/agent/src/main/java/sysmon/agent/Application.java similarity index 91% rename from client/src/main/java/sysmon/client/Application.java rename to agent/src/main/java/sysmon/agent/Application.java index ff9f149..0ef8730 100644 --- a/client/src/main/java/sysmon/client/Application.java +++ b/agent/src/main/java/sysmon/agent/Application.java @@ -1,7 +1,7 @@ /* * This Java source file was generated by the Gradle 'init' task. */ -package sysmon.client; +package sysmon.agent; import org.apache.camel.main.Main; import org.slf4j.simple.SimpleLogger; @@ -12,10 +12,10 @@ import java.net.UnknownHostException; import java.util.concurrent.Callable; -@CommandLine.Command(name = "sysmon-client", mixinStandardHelpOptions = true) +@CommandLine.Command(name = "sysmon-agent", mixinStandardHelpOptions = true) public class Application implements Callable { - @CommandLine.Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/sysmon-client.toml'].", paramLabel = "", defaultValue = "/etc/sysmon-client.toml") + @CommandLine.Option(names = { "-c", "--conf" }, description = "Configuration file [default: '/etc/sysmon-agent.toml'].", paramLabel = "", defaultValue = "/etc/sysmon-agent.toml") private File configurationFile; @CommandLine.Option(names = { "-d", "--debug" }, description = "Enable debugging (default: ${DEFAULT_VALUE}).") @@ -84,7 +84,7 @@ public Integer call() { main.bind("pluginPath", pluginPath); main.bind("myServerUrl", configuration.getServer()); main.bind("myHostname", hostname); - main.configure().addRoutesBuilder(ClientRouteBuilder.class); + main.configure().addRoutesBuilder(AgentRouteBuilder.class); // now keep the application running until the JVM is terminated (ctrl + c or sigterm) try { diff --git a/client/src/main/java/sysmon/client/ComboAppender.java b/agent/src/main/java/sysmon/agent/ComboAppender.java similarity index 94% rename from client/src/main/java/sysmon/client/ComboAppender.java rename to agent/src/main/java/sysmon/agent/ComboAppender.java index 5cc5b92..a200b52 100644 --- a/client/src/main/java/sysmon/client/ComboAppender.java +++ b/agent/src/main/java/sysmon/agent/ComboAppender.java @@ -1,4 +1,4 @@ -package sysmon.client; +package sysmon.agent; import sysmon.shared.ComboResult; import sysmon.shared.MetricResult; diff --git a/client/src/main/java/sysmon/client/Configuration.java b/agent/src/main/java/sysmon/agent/Configuration.java similarity index 99% rename from client/src/main/java/sysmon/client/Configuration.java rename to agent/src/main/java/sysmon/agent/Configuration.java index 0e81fc9..28e424c 100644 --- a/client/src/main/java/sysmon/client/Configuration.java +++ b/agent/src/main/java/sysmon/agent/Configuration.java @@ -1,4 +1,4 @@ -package sysmon.client; +package sysmon.agent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/client/src/main/java/sysmon/client/ListOfResultsStrategy.java b/agent/src/main/java/sysmon/agent/ListOfResultsStrategy.java similarity index 94% rename from client/src/main/java/sysmon/client/ListOfResultsStrategy.java rename to agent/src/main/java/sysmon/agent/ListOfResultsStrategy.java index 542266d..3f2e5a8 100644 --- a/client/src/main/java/sysmon/client/ListOfResultsStrategy.java +++ b/agent/src/main/java/sysmon/agent/ListOfResultsStrategy.java @@ -1,4 +1,4 @@ -package sysmon.client; +package sysmon.agent; import org.apache.camel.Exchange; import org.apache.camel.processor.aggregate.AbstractListAggregationStrategy; diff --git a/client/src/main/java/sysmon/client/MetricEnrichProcessor.java b/agent/src/main/java/sysmon/agent/MetricEnrichProcessor.java similarity index 97% rename from client/src/main/java/sysmon/client/MetricEnrichProcessor.java rename to agent/src/main/java/sysmon/agent/MetricEnrichProcessor.java index a007cf6..bef78cb 100644 --- a/client/src/main/java/sysmon/client/MetricEnrichProcessor.java +++ b/agent/src/main/java/sysmon/agent/MetricEnrichProcessor.java @@ -1,4 +1,4 @@ -package sysmon.client; +package sysmon.agent; import org.apache.camel.Exchange; import org.apache.camel.Processor; diff --git a/client/src/main/java/sysmon/client/ScriptWrapper.java b/agent/src/main/java/sysmon/agent/ScriptWrapper.java similarity index 98% rename from client/src/main/java/sysmon/client/ScriptWrapper.java rename to agent/src/main/java/sysmon/agent/ScriptWrapper.java index 1ebf031..ec4cbd3 100644 --- a/client/src/main/java/sysmon/client/ScriptWrapper.java +++ b/agent/src/main/java/sysmon/agent/ScriptWrapper.java @@ -1,4 +1,4 @@ -package sysmon.client; +package sysmon.agent; import groovy.lang.GroovyClassLoader; import groovy.lang.GroovyObject; diff --git a/client/src/main/resources/application.properties b/agent/src/main/resources/application.properties similarity index 97% rename from client/src/main/resources/application.properties rename to agent/src/main/resources/application.properties index 39b204a..125da34 100644 --- a/client/src/main/resources/application.properties +++ b/agent/src/main/resources/application.properties @@ -15,7 +15,7 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -camel.main.name = sysmon-client +camel.main.name = agent camel.main.jmxEnabled = false camel.main.lightweight = true camel.component.seda.queue-size = 100 diff --git a/client/src/main/resources/simplelogger.properties b/agent/src/main/resources/simplelogger.properties similarity index 100% rename from client/src/main/resources/simplelogger.properties rename to agent/src/main/resources/simplelogger.properties diff --git a/client/src/test/groovy/sysmon/client/AppTest.groovy b/agent/src/test/groovy/sysmon/agent/AppTest.groovy similarity index 77% rename from client/src/test/groovy/sysmon/client/AppTest.groovy rename to agent/src/test/groovy/sysmon/agent/AppTest.groovy index 3652b6a..4f7d4aa 100644 --- a/client/src/test/groovy/sysmon/client/AppTest.groovy +++ b/agent/src/test/groovy/sysmon/agent/AppTest.groovy @@ -1,4 +1,4 @@ -package sysmon.client +package sysmon.agent import spock.lang.Specification diff --git a/client/src/test/resources/simplelogger.properties b/agent/src/test/resources/simplelogger.properties similarity index 100% rename from client/src/test/resources/simplelogger.properties rename to agent/src/test/resources/simplelogger.properties diff --git a/build.gradle b/build.gradle index 323077c..500240a 100644 --- a/build.gradle +++ b/build.gradle @@ -37,8 +37,8 @@ subprojects { tasks.register("packages") { group "build" - dependsOn ":client:buildDeb" - dependsOn ":client:buildRpm" + dependsOn ":agent:buildDeb" + dependsOn ":agent:buildRpm" dependsOn ":server:buildDeb" dependsOn ":server:buildRpm" diff --git a/client/README.md b/client/README.md deleted file mode 100644 index d24f68e..0000000 --- a/client/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Client / Agent - -This is the client/agent component of sysmon, which you install (together with sysmon-plugins) on your hosts. - -## Installation - -Download *.deb* or *.rpm* packages for sysmon-client *and* sysmon-plugins, and install. - -## Development - -### Build & Test - -Use the gradle build tool, which will download all required dependencies: - -```shell -./gradlew clean build -``` diff --git a/client/scripts/shared.sh b/client/scripts/shared.sh deleted file mode 100644 index 0344041..0000000 --- a/client/scripts/shared.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -service_name="sysmon-client" -sysv_source="/opt/sysmon/client/doc/sysmon-client.sh" -config_source="/opt/sysmon/client/doc/sysmon-client.toml" -systemd_source="/opt/sysmon/client/doc/sysmon-client.service" - diff --git a/gradle.properties b/gradle.properties index daa014e..038b0d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ -version = 1.1.8 +version = 1.2.1 pf4jVersion = 3.11.1 slf4jVersion = 2.0.12 camelVersion = 3.14.10 -groovyVersion = 3.0.21 +groovyVersion = 3.0.22 picocliVersion = 4.7.6 oshiVersion = 6.6.1 spockVersion = 2.3-groovy-3.0 diff --git a/plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java b/plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java index 85b62e1..9fcf6ab 100644 --- a/plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java +++ b/plugins/base/src/main/java/sysmon/plugins/base/BaseLatencyExtension.java @@ -76,7 +76,7 @@ public void setConfiguration(Map map) { @Override public MetricResult getMetrics() { - // TODO: Calculate execution time for sysmon-client to monitor drift + // TODO: Calculate execution time for sysmon-agent to monitor drift // Available from Java 9 //long pid = ProcessHandle.current().pid(); @@ -88,7 +88,7 @@ public MetricResult getMetrics() { long nanoTime2 = System.nanoTime(); long nanoDiff = nanoTime2 - nanoTime1; sleepOverrun = (nanoDiff / 1_000_000) - sleepTimeMillis; - log.warn("Sleep Overrun: {}", sleepOverrun); + log.debug("getMetrics() - sleep Overrun: {}", sleepOverrun); } catch (InterruptedException e) { log.error("getMetrics() - error: {}", e.getMessage()); } diff --git a/plugins/build.gradle b/plugins/build.gradle index c207c3a..f6694f1 100644 --- a/plugins/build.gradle +++ b/plugins/build.gradle @@ -100,12 +100,12 @@ ospackage { buildDeb { subprojects.each { dependsOn("${it.name}:build") } - requires('sysmon-client', version, GREATER | EQUAL) + requires('sysmon-agent', version, GREATER | EQUAL) } buildRpm { subprojects.each { dependsOn("${it.name}:build") } - requires('sysmon-client', version, GREATER | EQUAL) + requires('sysmon-agent', version, GREATER | EQUAL) os Os.LINUX } diff --git a/server/doc/readme-aix.md b/server/doc/readme-aix.md index e5cf736..dc0a87e 100644 --- a/server/doc/readme-aix.md +++ b/server/doc/readme-aix.md @@ -2,7 +2,7 @@ ## Installation -We require Java 8, which should already be installed on AIX, or can be downloaded and installed. +Requires Java 8 (or later), which should already be installed on AIX, or can be downloaded and installed. The RPM packages are *"noarch"* Java bytecode, so we can use the **--ignoreos** option to install: ```shell diff --git a/server/scripts/install.sh b/server/scripts/install.sh index eb5a817..40fcc6b 100644 --- a/server/scripts/install.sh +++ b/server/scripts/install.sh @@ -24,9 +24,8 @@ install_sysv_linux() { install_sysv_aix() { test -f "/etc/rc.d/init.d/${service_name}" || cp "${sysv_source}" "/etc/rc.d/init.d/${service_name}" chmod 0755 "/etc/rc.d/init.d/${service_name}" - ln -sf /etc/rc.d/init.d/sysmon-client /etc/rc.d/rc2.d/Ssysmon-client - ln -sf /etc/rc.d/init.d/sysmon-client /etc/rc.d/rc2.d/Ksysmon-client - echo "Edit /etc/rc.d/init.d/${service_name} and modify server URL and other options" + ln -sf /etc/rc.d/init.d/sysmon-server /etc/rc.d/rc2.d/Ssysmon-server + ln -sf /etc/rc.d/init.d/sysmon-server /etc/rc.d/rc2.d/Ksysmon-server } install_sysv() { diff --git a/server/scripts/remove.sh b/server/scripts/remove.sh index 9aa0340..fb2d42c 100644 --- a/server/scripts/remove.sh +++ b/server/scripts/remove.sh @@ -19,8 +19,8 @@ remove_sysv_linux() { remove_sysv_aix() { /etc/rc.d/init.d/${service_name} stop - rm -f /etc/rc.d/init.d/sysmon-client /etc/rc.d/rc2.d/Ksysmon-client - rm -f /etc/rc.d/rc2.d/Ssysmon-client + rm -f /etc/rc.d/init.d/sysmon-server /etc/rc.d/rc2.d/Ksysmon-server + rm -f /etc/rc.d/rc2.d/Ssysmon-server } remove_sysv() { diff --git a/server/src/main/resources/application.properties b/server/src/main/resources/application.properties index fa39ff4..0e2ce1d 100644 --- a/server/src/main/resources/application.properties +++ b/server/src/main/resources/application.properties @@ -15,5 +15,5 @@ ## limitations under the License. ## --------------------------------------------------------------------------- -camel.main.name = sysmon-server +camel.main.name = server camel.main.lightweight = true diff --git a/settings.gradle b/settings.gradle index 3d2a33d..b4115f4 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,7 +8,7 @@ */ rootProject.name = 'sysmon' -include('shared', 'client', 'server', 'plugins') +include('shared', 'agent', 'server', 'plugins') new File(rootDir, "plugins").listFiles().each { From b2a3888b7d1492126b92db507a3cdcbecf53ae2d Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Mon, 5 Aug 2024 12:12:15 +0200 Subject: [PATCH 3/3] Update 3rd party deps. --- CHANGELOG.md | 3 ++- gradle.properties | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d23c2c2..746ac21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,12 @@ All notable changes to this project will be documented in this file. -## [1.2.1] - 2024-07-xx +## [1.2.1] - 2024-08-05 - Adjust defaults intervals from 10s to 30s - Measure sleep overrun - Rename client to agent - When upgrading, ensure any *client* related init-scripts are removed +- Updated 3rd party dependencies ## [1.1.8] - 2024-05-14 - Update 3rd party dependencies diff --git a/gradle.properties b/gradle.properties index 038b0d7..534a42f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ version = 1.2.1 -pf4jVersion = 3.11.1 -slf4jVersion = 2.0.12 +pf4jVersion = 3.12.0 +slf4jVersion = 2.0.13 camelVersion = 3.14.10 groovyVersion = 3.0.22 picocliVersion = 4.7.6 -oshiVersion = 6.6.1 +oshiVersion = 6.6.2 spockVersion = 2.3-groovy-3.0 tomljVersion = 1.1.1 osPackageVersion = 11.8.1