55 lines
1.5 KiB
Java
55 lines
1.5 KiB
Java
/*
|
|
* This Java source file was generated by the Gradle 'init' task.
|
|
*/
|
|
package org.sysmon.client;
|
|
|
|
import org.apache.camel.main.Main;
|
|
import picocli.CommandLine;
|
|
|
|
import java.io.IOException;
|
|
import java.net.InetAddress;
|
|
import java.net.URL;
|
|
import java.util.concurrent.Callable;
|
|
|
|
@CommandLine.Command(name = "sysmon-client", mixinStandardHelpOptions = true)
|
|
public class Application implements Callable<Integer> {
|
|
|
|
@CommandLine.Option(names = { "-s", "--server-url" }, description = "Server URL (default: ${DEFAULT-VALUE}).", defaultValue = "http://127.0.0.1:9925/metrics", paramLabel = "<url>")
|
|
private URL serverUrl;
|
|
|
|
@CommandLine.Option(names = { "-n", "--hostname" }, description = "Client hostname.", paramLabel = "<name>")
|
|
private String hostname;
|
|
|
|
|
|
public static void main(String... args) {
|
|
int exitCode = new CommandLine(new Application()).execute(args);
|
|
System.exit(exitCode);
|
|
}
|
|
|
|
|
|
@Override
|
|
public Integer call() throws IOException {
|
|
|
|
if(hostname == null || hostname.isEmpty()) {
|
|
hostname = InetAddress.getLocalHost().getHostName();
|
|
}
|
|
|
|
Main main = new Main();
|
|
main.bind("myServerUrl", serverUrl.toString());
|
|
main.bind("myHostname", hostname);
|
|
main.configure().addRoutesBuilder(ClientRouteBuilder.class);
|
|
|
|
// now keep the application running until the JVM is terminated (ctrl + c or sigterm)
|
|
try {
|
|
main.run();
|
|
} catch (Exception e) {
|
|
System.err.println(e.getMessage());
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|