Node Stats: add available processors to OS info
This commit is contained in:
parent
33900476f4
commit
0d5530e55f
|
@ -37,6 +37,8 @@ public class OsInfo implements Streamable, Serializable, ToXContent {
|
||||||
|
|
||||||
long refreshInterval;
|
long refreshInterval;
|
||||||
|
|
||||||
|
int availableProcessors;
|
||||||
|
|
||||||
Cpu cpu = null;
|
Cpu cpu = null;
|
||||||
|
|
||||||
Mem mem = null;
|
Mem mem = null;
|
||||||
|
@ -54,6 +56,14 @@ public class OsInfo implements Streamable, Serializable, ToXContent {
|
||||||
return this.refreshInterval;
|
return this.refreshInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int availableProcessors() {
|
||||||
|
return this.availableProcessors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAvailableProcessors() {
|
||||||
|
return this.availableProcessors;
|
||||||
|
}
|
||||||
|
|
||||||
public Cpu cpu() {
|
public Cpu cpu() {
|
||||||
return this.cpu;
|
return this.cpu;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +91,7 @@ public class OsInfo implements Streamable, Serializable, ToXContent {
|
||||||
static final class Fields {
|
static final class Fields {
|
||||||
static final XContentBuilderString OS = new XContentBuilderString("os");
|
static final XContentBuilderString OS = new XContentBuilderString("os");
|
||||||
static final XContentBuilderString REFRESH_INTERVAL = new XContentBuilderString("refresh_interval");
|
static final XContentBuilderString REFRESH_INTERVAL = new XContentBuilderString("refresh_interval");
|
||||||
|
static final XContentBuilderString AVAILABLE_PROCESSORS = new XContentBuilderString("available_processors");
|
||||||
static final XContentBuilderString CPU = new XContentBuilderString("cpu");
|
static final XContentBuilderString CPU = new XContentBuilderString("cpu");
|
||||||
static final XContentBuilderString VENDOR = new XContentBuilderString("vendor");
|
static final XContentBuilderString VENDOR = new XContentBuilderString("vendor");
|
||||||
static final XContentBuilderString MODEL = new XContentBuilderString("model");
|
static final XContentBuilderString MODEL = new XContentBuilderString("model");
|
||||||
|
@ -101,6 +112,7 @@ public class OsInfo implements Streamable, Serializable, ToXContent {
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject(Fields.OS);
|
builder.startObject(Fields.OS);
|
||||||
builder.field(Fields.REFRESH_INTERVAL, refreshInterval);
|
builder.field(Fields.REFRESH_INTERVAL, refreshInterval);
|
||||||
|
builder.field(Fields.AVAILABLE_PROCESSORS, availableProcessors);
|
||||||
if (cpu != null) {
|
if (cpu != null) {
|
||||||
builder.startObject(Fields.CPU);
|
builder.startObject(Fields.CPU);
|
||||||
builder.field(Fields.VENDOR, cpu.vendor());
|
builder.field(Fields.VENDOR, cpu.vendor());
|
||||||
|
@ -138,6 +150,7 @@ public class OsInfo implements Streamable, Serializable, ToXContent {
|
||||||
@Override
|
@Override
|
||||||
public void readFrom(StreamInput in) throws IOException {
|
public void readFrom(StreamInput in) throws IOException {
|
||||||
refreshInterval = in.readLong();
|
refreshInterval = in.readLong();
|
||||||
|
availableProcessors = in.readInt();
|
||||||
if (in.readBoolean()) {
|
if (in.readBoolean()) {
|
||||||
cpu = Cpu.readCpu(in);
|
cpu = Cpu.readCpu(in);
|
||||||
}
|
}
|
||||||
|
@ -152,6 +165,7 @@ public class OsInfo implements Streamable, Serializable, ToXContent {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeLong(refreshInterval);
|
out.writeLong(refreshInterval);
|
||||||
|
out.writeInt(availableProcessors);
|
||||||
if (cpu == null) {
|
if (cpu == null) {
|
||||||
out.writeBoolean(false);
|
out.writeBoolean(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class OsService extends AbstractComponent {
|
||||||
|
|
||||||
this.info = probe.osInfo();
|
this.info = probe.osInfo();
|
||||||
this.info.refreshInterval = refreshInterval.millis();
|
this.info.refreshInterval = refreshInterval.millis();
|
||||||
|
this.info.availableProcessors = Runtime.getRuntime().availableProcessors();
|
||||||
this.cachedStats = probe.osStats();
|
this.cachedStats = probe.osStats();
|
||||||
|
|
||||||
logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
|
logger.debug("Using probe [{}] with refresh_interval [{}]", probe, refreshInterval);
|
||||||
|
|
Loading…
Reference in New Issue