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*.
## 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

View File

@ -41,8 +41,8 @@ public class Application implements Callable<Integer> {
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;
}
}

View File

@ -1,3 +1,3 @@
# 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 java.io.IOException;
public interface MetricExtension extends ExtensionPoint {

View File

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