Add an `usage` key to the CPU section of OsStats.toXContent.

This is just the sum of existing `sys` and `user`

Closes #4374
This commit is contained in:
Boaz Leskes 2013-12-07 21:12:30 +01:00
parent ed5b3ace57
commit b7d6cce4c9
1 changed files with 2 additions and 0 deletions

View File

@ -116,6 +116,7 @@ public class OsStats implements Streamable, Serializable, ToXContent {
static final XContentBuilderString CPU = new XContentBuilderString("cpu"); static final XContentBuilderString CPU = new XContentBuilderString("cpu");
static final XContentBuilderString SYS = new XContentBuilderString("sys"); static final XContentBuilderString SYS = new XContentBuilderString("sys");
static final XContentBuilderString USER = new XContentBuilderString("user"); static final XContentBuilderString USER = new XContentBuilderString("user");
static final XContentBuilderString USAGE = new XContentBuilderString("usage");
static final XContentBuilderString IDLE = new XContentBuilderString("idle"); static final XContentBuilderString IDLE = new XContentBuilderString("idle");
static final XContentBuilderString STOLEN = new XContentBuilderString("stolen"); static final XContentBuilderString STOLEN = new XContentBuilderString("stolen");
@ -165,6 +166,7 @@ public class OsStats implements Streamable, Serializable, ToXContent {
builder.field(Fields.SYS, cpu.sys()); builder.field(Fields.SYS, cpu.sys());
builder.field(Fields.USER, cpu.user()); builder.field(Fields.USER, cpu.user());
builder.field(Fields.IDLE, cpu.idle()); builder.field(Fields.IDLE, cpu.idle());
builder.field(Fields.USAGE, cpu.user() + cpu.sys());
builder.field(Fields.STOLEN, cpu.stolen()); builder.field(Fields.STOLEN, cpu.stolen());
builder.endObject(); builder.endObject();
} }