Ensure hostname is provided, if it can't be properly detected.

This commit is contained in:
Mark Nellemann 2021-06-14 17:57:18 +02:00
parent 37a822b687
commit 3a89ab42f9
5 changed files with 26 additions and 5 deletions

View file

@ -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*. - 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 ## Components
### Client ### Client

View file

@ -41,8 +41,8 @@ public class Application implements Callable<Integer> {
try { try {
hostname = InetAddress.getLocalHost().getHostName(); hostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
log.warn(e.getMessage()); System.err.println("Could not detect hostname. Use the '-n' or '--hostname' option to specify it.");
hostname = "unknown"; return -1;
} }
} }

View file

@ -1,3 +1,3 @@
# System Monitor Plugins # System Monitor Plugins
Collection of sysmon plugins. Collection of standard sysmon plugins.

View file

@ -2,7 +2,6 @@ package sysmon.shared;
import org.pf4j.ExtensionPoint; import org.pf4j.ExtensionPoint;
import java.io.IOException;
public interface MetricExtension extends ExtensionPoint { public interface MetricExtension extends ExtensionPoint {

View file

@ -45,7 +45,7 @@ public class PluginHelper {
} }
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
e.printStackTrace(); log.warn("executeCommand() - exception: " + e.getMessage());
} }
return inputStream; return inputStream;