mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Merge pull request #130 from weideng1/master
fixed a number of bugs with docker-metrics on Mac
This commit is contained in:
@@ -186,11 +186,9 @@ public class NBCLI {
|
|||||||
logger.info("Docker metrics is enabled. Docker must be installed for this to work");
|
logger.info("Docker metrics is enabled. Docker must be installed for this to work");
|
||||||
DockerMetricsManager dmh = new DockerMetricsManager();
|
DockerMetricsManager dmh = new DockerMetricsManager();
|
||||||
dmh.startMetrics();
|
dmh.startMetrics();
|
||||||
String info = "Docker Containers are started, for grafana and prometheus, hit" +
|
String warn = "Docker Containers are started, for grafana and prometheus, hit" +
|
||||||
"these urls in your browser: http://<host>:3000 and http://<host>:9090" +
|
"these urls in your browser: http://<host>:3000 and http://<host>:9090";
|
||||||
"the default grafana creds are admin/admin";
|
logger.warn(warn);
|
||||||
logger.info(info);
|
|
||||||
System.out.println(info);
|
|
||||||
if (reportGraphiteTo != null) {
|
if (reportGraphiteTo != null) {
|
||||||
logger.warn(String.format("Docker metrics are enabled (--docker-metrics)" +
|
logger.warn(String.format("Docker metrics are enabled (--docker-metrics)" +
|
||||||
" but graphite reporting (--report-graphite-to) is set to %s \n" +
|
" but graphite reporting (--report-graphite-to) is set to %s \n" +
|
||||||
|
|||||||
@@ -213,7 +213,11 @@ public class DockerHelper {
|
|||||||
logger.info(String.format("Hupping config"));
|
logger.info(String.format("Hupping config"));
|
||||||
|
|
||||||
if (reload != null) {
|
if (reload != null) {
|
||||||
|
try {
|
||||||
post(reload, null, false, "reloading config");
|
post(reload, null, false, "reloading config");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(String.format("Unexpected config/state for docker container %s, consider removing the container", name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return runningContainers.get(0);
|
return runningContainers.get(0);
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ public class DockerMetricsManager {
|
|||||||
String name = "grafana";
|
String name = "grafana";
|
||||||
List<Integer> port = Arrays.asList(3000);
|
List<Integer> port = Arrays.asList(3000);
|
||||||
|
|
||||||
|
boolean grafanaFilesExist = grafanaFilesExist();
|
||||||
|
if (!grafanaFilesExist) {
|
||||||
setupGrafanaFiles(ip);
|
setupGrafanaFiles(ip);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> volumeDescList = Arrays.asList(
|
List<String> volumeDescList = Arrays.asList(
|
||||||
userHome + "/.nosqlbench/grafana:/var/lib/grafana:rw"
|
userHome + "/.nosqlbench/grafana:/var/lib/grafana:rw"
|
||||||
@@ -80,8 +83,10 @@ public class DockerMetricsManager {
|
|||||||
|
|
||||||
logger.info("grafana container started, http listening");
|
logger.info("grafana container started, http listening");
|
||||||
|
|
||||||
|
if (!grafanaFilesExist) {
|
||||||
configureGrafana();
|
configureGrafana();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void startPrometheus(String ip) {
|
private void startPrometheus(String ip) {
|
||||||
|
|
||||||
@@ -91,7 +96,9 @@ public class DockerMetricsManager {
|
|||||||
String name = "prom";
|
String name = "prom";
|
||||||
List<Integer> port = Arrays.asList(9090);
|
List<Integer> port = Arrays.asList(9090);
|
||||||
|
|
||||||
|
if (!promFilesExist()) {
|
||||||
setupPromFiles(ip);
|
setupPromFiles(ip);
|
||||||
|
}
|
||||||
|
|
||||||
List<String> volumeDescList = Arrays.asList(
|
List<String> volumeDescList = Arrays.asList(
|
||||||
//cwd+"/docker-metrics/prometheus:/prometheus",
|
//cwd+"/docker-metrics/prometheus:/prometheus",
|
||||||
@@ -170,6 +177,9 @@ public class DockerMetricsManager {
|
|||||||
"/prometheus");
|
"/prometheus");
|
||||||
|
|
||||||
Set<PosixFilePermission> perms = new HashSet<>();
|
Set<PosixFilePermission> perms = new HashSet<>();
|
||||||
|
perms.add(PosixFilePermission.OWNER_READ);
|
||||||
|
perms.add(PosixFilePermission.OWNER_WRITE);
|
||||||
|
perms.add(PosixFilePermission.OWNER_EXECUTE);
|
||||||
perms.add(PosixFilePermission.OTHERS_READ);
|
perms.add(PosixFilePermission.OTHERS_READ);
|
||||||
perms.add(PosixFilePermission.OTHERS_WRITE);
|
perms.add(PosixFilePermission.OTHERS_WRITE);
|
||||||
perms.add(PosixFilePermission.OTHERS_EXECUTE);
|
perms.add(PosixFilePermission.OTHERS_EXECUTE);
|
||||||
@@ -215,6 +225,24 @@ public class DockerMetricsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean grafanaFilesExist() {
|
||||||
|
File nosqlbenchDir = new File(userHome, "/.nosqlbench/");
|
||||||
|
boolean exists = nosqlbenchDir.exists();
|
||||||
|
if (exists) {
|
||||||
|
File grafana = new File(userHome, "/.nosqlbench/grafana");
|
||||||
|
exists = grafana.exists();
|
||||||
|
}
|
||||||
|
return exists;
|
||||||
|
}
|
||||||
|
private boolean promFilesExist() {
|
||||||
|
File nosqlbenchDir = new File(userHome, "/.nosqlbench/");
|
||||||
|
boolean exists = nosqlbenchDir.exists();
|
||||||
|
if (exists) {
|
||||||
|
File prom = new File(userHome, "/.nosqlbench/grafana");
|
||||||
|
exists = prom.exists();
|
||||||
|
}
|
||||||
|
return exists;
|
||||||
|
}
|
||||||
|
|
||||||
private void setupGrafanaFiles(String ip) {
|
private void setupGrafanaFiles(String ip) {
|
||||||
|
|
||||||
@@ -243,6 +271,7 @@ public class DockerMetricsManager {
|
|||||||
private void configureGrafana() {
|
private void configureGrafana() {
|
||||||
post("http://localhost:3000/api/dashboards/db", "docker/dashboards/analysis.json", true, "load analysis dashboard");
|
post("http://localhost:3000/api/dashboards/db", "docker/dashboards/analysis.json", true, "load analysis dashboard");
|
||||||
post("http://localhost:3000/api/datasources", "docker/datasources/prometheus-datasource.yaml", true, "configure data source");
|
post("http://localhost:3000/api/datasources", "docker/datasources/prometheus-datasource.yaml", true, "configure data source");
|
||||||
|
logger.warn("default grafana creds are admin/admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user