|
@@ -19,11 +19,11 @@
|
|
|
|
|
|
package org.elasticsearch.monitor.os;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.Writeable;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
-import org.elasticsearch.common.xcontent.ToXContent.Params;
|
|
|
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
|
|
@@ -35,14 +35,23 @@ public class OsInfo implements Writeable, ToXContentFragment {
|
|
|
private final int availableProcessors;
|
|
|
private final int allocatedProcessors;
|
|
|
private final String name;
|
|
|
+ private final String prettyName;
|
|
|
private final String arch;
|
|
|
private final String version;
|
|
|
|
|
|
- public OsInfo(long refreshInterval, int availableProcessors, int allocatedProcessors, String name, String arch, String version) {
|
|
|
+ public OsInfo(
|
|
|
+ final long refreshInterval,
|
|
|
+ final int availableProcessors,
|
|
|
+ final int allocatedProcessors,
|
|
|
+ final String name,
|
|
|
+ final String prettyName,
|
|
|
+ final String arch,
|
|
|
+ final String version) {
|
|
|
this.refreshInterval = refreshInterval;
|
|
|
this.availableProcessors = availableProcessors;
|
|
|
this.allocatedProcessors = allocatedProcessors;
|
|
|
this.name = name;
|
|
|
+ this.prettyName = prettyName;
|
|
|
this.arch = arch;
|
|
|
this.version = version;
|
|
|
}
|
|
@@ -52,6 +61,11 @@ public class OsInfo implements Writeable, ToXContentFragment {
|
|
|
this.availableProcessors = in.readInt();
|
|
|
this.allocatedProcessors = in.readInt();
|
|
|
this.name = in.readOptionalString();
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
|
|
|
+ this.prettyName = in.readOptionalString();
|
|
|
+ } else {
|
|
|
+ this.prettyName = null;
|
|
|
+ }
|
|
|
this.arch = in.readOptionalString();
|
|
|
this.version = in.readOptionalString();
|
|
|
}
|
|
@@ -62,6 +76,9 @@ public class OsInfo implements Writeable, ToXContentFragment {
|
|
|
out.writeInt(availableProcessors);
|
|
|
out.writeInt(allocatedProcessors);
|
|
|
out.writeOptionalString(name);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
|
|
|
+ out.writeOptionalString(prettyName);
|
|
|
+ }
|
|
|
out.writeOptionalString(arch);
|
|
|
out.writeOptionalString(version);
|
|
|
}
|
|
@@ -82,6 +99,10 @@ public class OsInfo implements Writeable, ToXContentFragment {
|
|
|
return name;
|
|
|
}
|
|
|
|
|
|
+ public String getPrettyName() {
|
|
|
+ return prettyName;
|
|
|
+ }
|
|
|
+
|
|
|
public String getArch() {
|
|
|
return arch;
|
|
|
}
|
|
@@ -93,6 +114,7 @@ public class OsInfo implements Writeable, ToXContentFragment {
|
|
|
static final class Fields {
|
|
|
static final String OS = "os";
|
|
|
static final String NAME = "name";
|
|
|
+ static final String PRETTY_NAME = "pretty_name";
|
|
|
static final String ARCH = "arch";
|
|
|
static final String VERSION = "version";
|
|
|
static final String REFRESH_INTERVAL = "refresh_interval";
|
|
@@ -108,6 +130,9 @@ public class OsInfo implements Writeable, ToXContentFragment {
|
|
|
if (name != null) {
|
|
|
builder.field(Fields.NAME, name);
|
|
|
}
|
|
|
+ if (prettyName != null) {
|
|
|
+ builder.field(Fields.PRETTY_NAME, prettyName);
|
|
|
+ }
|
|
|
if (arch != null) {
|
|
|
builder.field(Fields.ARCH, arch);
|
|
|
}
|