Skip to content

Commit

Permalink
add update hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
lhpqaq committed Dec 16, 2024
1 parent b6bae5a commit c297683
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
@NoArgsConstructor
public class PrometheusParams extends InfraParams {

private final String PROMETHEUS_SELF_JOB_NAME = "prometheus";
private final String BM_AGENT_JOB_NAME = "bm-agent";
private final String BM_AGENT_PORT = "8081";
protected final String PROMETHEUS_SELF_JOB_NAME = "prometheus";
protected final String BM_AGENT_JOB_NAME = "bm-agent";
protected final String BM_AGENT_PORT = "8081";

private Map<String, Object> prometheusScrapeJob;
private Map<String, Object> agentScrapeJob;
Expand Down Expand Up @@ -78,7 +78,7 @@ public String getServiceName() {
return "prometheus";
}

private List<String> getAllHost() {
protected List<String> getAllHost() {
List<String> ips = LocalSettings.hosts().get("all");
List<String> hosts = new ArrayList<>();
for (String ip : ips) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,18 @@ public static ShellResult config(Params params) {
}
return ShellResult.success("Prometheus Configure success!");
}

public static ShellResult updateHosts(Params params) {
PrometheusParams prometheusParams = (PrometheusParams) params;
String user = prometheusParams.user();
String group = prometheusParams.group();
LinuxFileUtils.toFile(
ConfigType.JSON,
prometheusParams.targetsConfigFile(prometheusParams.PROMETHEUS_SELF_JOB_NAME),
user,
group,
Constants.PERMISSION_644,
prometheusParams.getAllHost());
return ShellResult.success("Update hosts success!");
}
}

0 comments on commit c297683

Please sign in to comment.