From 3a89ab42f97ea71f5b1799e47059303c501cc1f8 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Mon, 14 Jun 2021 17:57:18 +0200 Subject: [PATCH] Ensure hostname is provided, if it can't be properly detected. --- README.md | 22 +++++++++++++++++++ .../main/java/sysmon/client/Application.java | 4 ++-- plugins/README.md | 2 +- .../java/sysmon/shared/MetricExtension.java | 1 - .../main/java/sysmon/shared/PluginHelper.java | 2 +- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 783b480..0227942 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,28 @@ Java based system monitoring solution with support for plugins. - Example Grafana [dashboard](https://bitbucket.org/mnellemann/sysmon/downloads/sysmon-example-dashboard.png) showing metrics from a host running *sysmon*. + + +## Known problems + +### Correct timezone and clock + +- Ensure you have **correct timezone and date/time** and NTPd (or similar) running to keep it accurate! + +### Naming collision + +You can't have hosts with the same name, as these cannot be distinguished when metrics are +written to InfluxDB (which uses the hostname as key). + +### Renaming hosts + +If you rename a host, the metrics in InfluxDB will still be available by the old hostname, and new metrics will be written with the new hostname. There is no easy way to migrate the old data, but you can delete it easily: + +```text +USE sysmon; +DELETE WHERE hostname = 'unknown'; +``` + ## Components ### Client diff --git a/client/src/main/java/sysmon/client/Application.java b/client/src/main/java/sysmon/client/Application.java index 67a6d3a..d134d6e 100644 --- a/client/src/main/java/sysmon/client/Application.java +++ b/client/src/main/java/sysmon/client/Application.java @@ -41,8 +41,8 @@ public class Application implements Callable { try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { - log.warn(e.getMessage()); - hostname = "unknown"; + System.err.println("Could not detect hostname. Use the '-n' or '--hostname' option to specify it."); + return -1; } } diff --git a/plugins/README.md b/plugins/README.md index 2a3341f..75d3ab9 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -1,3 +1,3 @@ # System Monitor Plugins -Collection of sysmon plugins. \ No newline at end of file +Collection of standard sysmon plugins. \ No newline at end of file diff --git a/shared/src/main/java/sysmon/shared/MetricExtension.java b/shared/src/main/java/sysmon/shared/MetricExtension.java index 4130a21..8e7f37f 100644 --- a/shared/src/main/java/sysmon/shared/MetricExtension.java +++ b/shared/src/main/java/sysmon/shared/MetricExtension.java @@ -2,7 +2,6 @@ package sysmon.shared; import org.pf4j.ExtensionPoint; -import java.io.IOException; public interface MetricExtension extends ExtensionPoint { diff --git a/shared/src/main/java/sysmon/shared/PluginHelper.java b/shared/src/main/java/sysmon/shared/PluginHelper.java index a1dc1d8..6e2ba1d 100644 --- a/shared/src/main/java/sysmon/shared/PluginHelper.java +++ b/shared/src/main/java/sysmon/shared/PluginHelper.java @@ -45,7 +45,7 @@ public class PluginHelper { } } catch (IOException | InterruptedException e) { - e.printStackTrace(); + log.warn("executeCommand() - exception: " + e.getMessage()); } return inputStream;