diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkInfo.java b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkInfo.java index 33947d62d20..81b4f4d87ac 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkInfo.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkInfo.java @@ -35,8 +35,18 @@ public class NetworkInfo implements Streamable, Serializable, ToXContent { public static final Interface NA_INTERFACE = new Interface(); + long refreshInterval; + Interface primary = NA_INTERFACE; + public long refreshInterval() { + return this.refreshInterval; + } + + public long getRefreshInterval() { + return this.refreshInterval; + } + public Interface primaryInterface() { return primary; } @@ -47,6 +57,7 @@ public class NetworkInfo implements Streamable, Serializable, ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("network"); + builder.field("refresh_interval", refreshInterval); if (primary != NA_INTERFACE) { builder.startObject("primary_interface"); builder.field("address", primary.address()); @@ -65,10 +76,12 @@ public class NetworkInfo implements Streamable, Serializable, ToXContent { } @Override public void readFrom(StreamInput in) throws IOException { + refreshInterval = in.readLong(); primary = Interface.readNetworkInterface(in); } @Override public void writeTo(StreamOutput out) throws IOException { + out.writeLong(refreshInterval); primary.writeTo(out); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkService.java index a51b7a843d2..eda92d0d47e 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/network/NetworkService.java @@ -54,6 +54,7 @@ public class NetworkService extends AbstractComponent { logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval); this.info = probe.networkInfo(); + this.info.refreshInterval = refreshInterval.millis(); this.cachedStats = probe.networkStats(); if (logger.isDebugEnabled()) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsInfo.java b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsInfo.java index 80d0eb7d4b2..9bb1d8ce1ec 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsInfo.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsInfo.java @@ -34,6 +34,8 @@ import java.io.Serializable; */ public class OsInfo implements Streamable, Serializable, ToXContent { + long refreshInterval; + Cpu cpu = null; Mem mem = null; @@ -43,6 +45,14 @@ public class OsInfo implements Streamable, Serializable, ToXContent { OsInfo() { } + public long refreshInterval() { + return this.refreshInterval; + } + + public long getRefreshInterval() { + return this.refreshInterval; + } + public Cpu cpu() { return this.cpu; } @@ -69,6 +79,7 @@ public class OsInfo implements Streamable, Serializable, ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("os"); + builder.field("refresh_interval", refreshInterval); if (cpu != null) { builder.startObject("cpu"); builder.field("vendor", cpu.vendor()); @@ -104,6 +115,7 @@ public class OsInfo implements Streamable, Serializable, ToXContent { } @Override public void readFrom(StreamInput in) throws IOException { + refreshInterval = in.readLong(); if (in.readBoolean()) { cpu = Cpu.readCpu(in); } @@ -116,6 +128,7 @@ public class OsInfo implements Streamable, Serializable, ToXContent { } @Override public void writeTo(StreamOutput out) throws IOException { + out.writeLong(refreshInterval); if (cpu == null) { out.writeBoolean(false); } else { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsService.java index e4cffda2918..affeb64ab8f 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/os/OsService.java @@ -45,9 +45,10 @@ public class OsService extends AbstractComponent { this.probe = probe; this.timerService = timerService; - this.info = probe.osInfo(); - this.refreshInterval = componentSettings.getAsTime("refresh_interval", TimeValue.timeValueSeconds(5)); + + this.info = probe.osInfo(); + this.info.refreshInterval = refreshInterval.millis(); this.cachedStats = probe.osStats(); logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval); diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java index c11bc909e48..4dfb9e190d2 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java @@ -33,6 +33,8 @@ import java.io.Serializable; */ public class ProcessInfo implements Streamable, Serializable, ToXContent { + long refreshInterval; + private long id; ProcessInfo() { @@ -43,6 +45,14 @@ public class ProcessInfo implements Streamable, Serializable, ToXContent { this.id = id; } + public long refreshInterval() { + return this.refreshInterval; + } + + public long getRefreshInterval() { + return this.refreshInterval; + } + /** * The process id. */ @@ -59,6 +69,7 @@ public class ProcessInfo implements Streamable, Serializable, ToXContent { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("process"); + builder.field("refresh_interval", refreshInterval); builder.field("id", id); builder.endObject(); return builder; @@ -71,10 +82,12 @@ public class ProcessInfo implements Streamable, Serializable, ToXContent { } @Override public void readFrom(StreamInput in) throws IOException { + refreshInterval = in.readLong(); id = in.readLong(); } @Override public void writeTo(StreamOutput out) throws IOException { + out.writeLong(refreshInterval); out.writeLong(id); } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessService.java index aa3a70050c5..48a09787aa9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/ProcessService.java @@ -48,6 +48,7 @@ public class ProcessService extends AbstractComponent { this.refreshInterval = componentSettings.getAsTime("refresh_interval", TimeValue.timeValueSeconds(5)); this.info = probe.processInfo(); + this.info.refreshInterval = refreshInterval.millis(); this.cachedStats = probe.processStats(); logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);