Commit 1608bf81 authored by Matteo Melli's avatar Matteo Melli

Merge branch 'fix-prometheus-service' into 'master'

Version 1.0.3

See merge request ongresinc/pgio!10
parents 592f1e38 96fc2b37
Pipeline #30295 passed with stage
in 1 minute and 13 seconds
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<parent> <parent>
<artifactId>pgio-parent</artifactId> <artifactId>pgio-parent</artifactId>
<groupId>com.ongres.pgio</groupId> <groupId>com.ongres.pgio</groupId>
<version>1.0.1</version> <version>1.0.3</version>
</parent> </parent>
<artifactId>main</artifactId> <artifactId>main</artifactId>
......
...@@ -31,7 +31,6 @@ import com.ongres.pgio.main.stats.serializer.StatSerializer; ...@@ -31,7 +31,6 @@ import com.ongres.pgio.main.stats.serializer.StatSerializer;
import com.ongres.pgio.main.version.Version; import com.ongres.pgio.main.version.Version;
import fi.iki.elonen.NanoHTTPD; import fi.iki.elonen.NanoHTTPD;
import joptsimple.OptionException; import joptsimple.OptionException;
import joptsimple.OptionParser; import joptsimple.OptionParser;
import joptsimple.OptionSet; import joptsimple.OptionSet;
...@@ -48,6 +47,7 @@ import java.time.Duration; ...@@ -48,6 +47,7 @@ import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.util.Optional; import java.util.Optional;
import java.util.Scanner; import java.util.Scanner;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
...@@ -138,9 +138,12 @@ public class Main { ...@@ -138,9 +138,12 @@ public class Main {
return message; return message;
} }
private static void runPrometheusService(Config config) throws IOException { private static void runPrometheusService(Config config) throws Exception {
PrometheusService service = new PrometheusService(config); PrometheusService service = new PrometheusService(config);
service.start(NanoHTTPD.SOCKET_READ_TIMEOUT, false); service.start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
while (true) {
TimeUnit.MICROSECONDS.sleep(20);
}
} }
private static void runCollector(Config config) throws Exception, InterruptedException { private static void runCollector(Config config) throws Exception, InterruptedException {
...@@ -191,11 +194,11 @@ public class Main { ...@@ -191,11 +194,11 @@ public class Main {
"Run as a prometheus service (advanced option)") "Run as a prometheus service (advanced option)")
.availableIf("advanced"); .availableIf("advanced");
parser.acceptsAll(Lists.newArrayList("prometheus-bind"), parser.acceptsAll(Lists.newArrayList("prometheus-bind"),
"The bind address of prometheus service (advanced option)") "The bind address of prometheus service, default is localhost (advanced option)")
.availableIf("advanced") .availableIf("advanced")
.withRequiredArg(); .withRequiredArg();
parser.acceptsAll(Lists.newArrayList("prometheus-port"), parser.acceptsAll(Lists.newArrayList("prometheus-port"),
"The port of prometheus service (advanced option)") "The port of prometheus service, default is 9544 (advanced option)")
.availableIf("advanced") .availableIf("advanced")
.withRequiredArg(); .withRequiredArg();
parser.acceptsAll(Lists.newArrayList("ppid"), parser.acceptsAll(Lists.newArrayList("ppid"),
......
...@@ -112,7 +112,7 @@ public class Config { ...@@ -112,7 +112,7 @@ public class Config {
private Optional<Integer> ppid = Optional.empty(); private Optional<Integer> ppid = Optional.empty();
private boolean prometheusService; private boolean prometheusService;
private InetAddress prometheusBind; private InetAddress prometheusBind;
private int prometheusPort = 8000; private int prometheusPort = 9544;
private boolean noPrintHeader; private boolean noPrintHeader;
private boolean showSystem; private boolean showSystem;
private boolean showOther; private boolean showOther;
...@@ -122,7 +122,7 @@ public class Config { ...@@ -122,7 +122,7 @@ public class Config {
public Builder() { public Builder() {
try { try {
prometheusBind = InetAddress.getLocalHost(); prometheusBind = InetAddress.getByName("localhost");
} catch (UnknownHostException ex) { } catch (UnknownHostException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>com.ongres.pgio</groupId> <groupId>com.ongres.pgio</groupId>
<artifactId>pgio-parent</artifactId> <artifactId>pgio-parent</artifactId>
<version>1.0.1</version> <version>1.0.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<prerequisites> <prerequisites>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment