Add file descriptor details to cat/nodes

cat/nodes currently does not report any details related to file descriptors. This adds the current number in use, the maximum number available as well as their ratio (percentage) to cat/nodes as hidden-by-default metrics. In addition, this also adds current heap usage (as a non-percentage of ts max) and ram usage (as a non-percerntage of its max) to allow tools to provide more granularity.

Closes #7652
This commit is contained in:
Chris Earle 2014-09-09 00:04:59 -04:00
parent e88d42db2b
commit 2d8a140ed8
3 changed files with 71 additions and 3 deletions

View File

@ -90,10 +90,18 @@ k0zy 192.168.56.10 9300 {version} m
|`build` |`b` |No |Elasticsearch Build hash |5c03844 |`build` |`b` |No |Elasticsearch Build hash |5c03844
|`jdk` |`j` |No |Running Java version |1.8.0 |`jdk` |`j` |No |Running Java version |1.8.0
|`disk.avail` |`d`, `disk`, `diskAvail` |No |Available disk space |1.8gb |`disk.avail` |`d`, `disk`, `diskAvail` |No |Available disk space |1.8gb
|`heap.percent` |`hp`, `heapPercent` |No |Used heap percentage |7 |`heap.current` |`hc`, `heapCurrent` |No |Used heap |311.2mb
|`heap.percent` |`hp`, `heapPercent` |Yes |Used heap percentage |7
|`heap.max` |`hm`, `heapMax` |No |Maximum configured heap |1015.6mb |`heap.max` |`hm`, `heapMax` |No |Maximum configured heap |1015.6mb
|`ram.percent` |`rp`, `ramPercent` |No |Used total memory percentage |47 |`ram.current` |`rc`, `ramCurrent` |No |Used total memory |513.4mb
|`ram.percent` |`rp`, `ramPercent` |Yes |Used total memory percentage |47
|`ram.max` |`rm`, `ramMax` |No |Total memory |2.9gb |`ram.max` |`rm`, `ramMax` |No |Total memory |2.9gb
|`file_desc.current` |`fdc`, `fileDescriptorCurrent` |No |Used file
descriptors |123
|`file_desc.percent` |`fdp`, `fileDescriptorPercent` |Yes |Used file
descriptors percentage |1
|`file_desc.max` |`fdm`, `fileDescriptorMax` |No |Maximum number of file
descriptors |1024
|`load` |`l` |No |Most recent load average |0.22 |`load` |`l` |No |Most recent load average |0.22
|`uptime` |`u` |No |Node uptime |17.3m |`uptime` |`u` |No |Node uptime |17.3m
|`node.role` |`r`, `role`, `dc`, `nodeRole` |Yes |Data node (d); Client |`node.role` |`r`, `role`, `dc`, `nodeRole` |Yes |Data node (d); Client

View File

@ -0,0 +1,39 @@
---
"Test cat nodes output":
- do:
cat.nodes: {}
- match:
$body: |
/ #host ip heap.percent ram.percent load node.role master name
^ (\S+ \s+ (\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ \d* \s+ [-dc] \s+ [-*mx] \s+ \S+ \s+ \n)+ $/
- do:
cat.nodes:
v: true
- match:
$body: |
/^ host \s+ ip \s+ heap\.percent \s+ ram\.percent \s+ load \s+ node\.role \s+ master \s+ name \s+ \n
(\S+ \s+ (\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ \d* \s+ [-dc] \s+ [-*mx] \s+ \S+ \s+ \n)+ $/
- do:
cat.nodes:
h: heap.current,heap.percent,heap.max
v: true
- match:
$body: |
/^ heap\.current \s+ heap\.percent \s+ heap\.max \s+ \n
(\s+ \d+(\.\d+)?[ptgmk]?b \s+ \d+ \s+ \d+(\.\d+)?[ptgmk]?b \s+ \n)+ $/
- do:
cat.nodes:
h: file_desc.current,file_desc.percent,file_desc.max
v: true
- match:
$body: |
/^ file_desc\.current \s+ file_desc\.percent \s+ file_desc\.max \s+ \n
(\s+ \d+ \s+ \d+ \s+ \d+ \s+ \n)+ $/

View File

@ -73,7 +73,7 @@ public class RestNodesAction extends AbstractCatAction {
@Override @Override
public void processResponse(final NodesInfoResponse nodesInfoResponse) { public void processResponse(final NodesInfoResponse nodesInfoResponse) {
NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(); NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true); nodesStatsRequest.clear().jvm(true).os(true).fs(true).indices(true).process(true);
client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) { client.admin().cluster().nodesStats(nodesStatsRequest, new RestResponseListener<NodesStatsResponse>(channel) {
@Override @Override
public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception { public RestResponse buildResponse(NodesStatsResponse nodesStatsResponse) throws Exception {
@ -100,10 +100,15 @@ public class RestNodesAction extends AbstractCatAction {
table.addCell("build", "default:false;alias:b;desc:es build hash"); table.addCell("build", "default:false;alias:b;desc:es build hash");
table.addCell("jdk", "default:false;alias:j;desc:jdk version"); table.addCell("jdk", "default:false;alias:j;desc:jdk version");
table.addCell("disk.avail", "default:false;alias:d,disk,diskAvail;text-align:right;desc:available disk space"); table.addCell("disk.avail", "default:false;alias:d,disk,diskAvail;text-align:right;desc:available disk space");
table.addCell("heap.current", "default:false;alias:hc,heapCurrent;text-align:right;desc:used heap");
table.addCell("heap.percent", "alias:hp,heapPercent;text-align:right;desc:used heap ratio"); table.addCell("heap.percent", "alias:hp,heapPercent;text-align:right;desc:used heap ratio");
table.addCell("heap.max", "default:false;alias:hm,heapMax;text-align:right;desc:max configured heap"); table.addCell("heap.max", "default:false;alias:hm,heapMax;text-align:right;desc:max configured heap");
table.addCell("ram.current", "default:false;alias:rc,ramCurrent;text-align:right;desc:used machine memory");
table.addCell("ram.percent", "alias:rp,ramPercent;text-align:right;desc:used machine memory ratio"); table.addCell("ram.percent", "alias:rp,ramPercent;text-align:right;desc:used machine memory ratio");
table.addCell("ram.max", "default:false;alias:rm,ramMax;text-align:right;desc:total machine memory"); table.addCell("ram.max", "default:false;alias:rm,ramMax;text-align:right;desc:total machine memory");
table.addCell("file_desc.current", "default:false;alias:fdc,fileDescriptorCurrent;text-align:right;desc:used file descriptors");
table.addCell("file_desc.percent", "default:false;alias:fdp,fileDescriptorPercent;text-align:right;desc:used file descriptor ratio");
table.addCell("file_desc.max", "default:false;alias:fdm,fileDescriptorMax;text-align:right;desc:max file descriptors");
table.addCell("load", "alias:l;text-align:right;desc:most recent load avg"); table.addCell("load", "alias:l;text-align:right;desc:most recent load avg");
table.addCell("uptime", "default:false;alias:u;text-align:right;desc:node uptime"); table.addCell("uptime", "default:false;alias:u;text-align:right;desc:node uptime");
@ -211,10 +216,16 @@ public class RestNodesAction extends AbstractCatAction {
table.addCell(info == null ? null : info.getBuild().hashShort()); table.addCell(info == null ? null : info.getBuild().hashShort());
table.addCell(info == null ? null : info.getJvm().version()); table.addCell(info == null ? null : info.getJvm().version());
table.addCell(stats == null ? null : stats.getFs() == null ? null : stats.getFs().total().getAvailable()); table.addCell(stats == null ? null : stats.getFs() == null ? null : stats.getFs().total().getAvailable());
table.addCell(stats == null ? null : stats.getJvm().getMem().getHeapUsed());
table.addCell(stats == null ? null : stats.getJvm().getMem().getHeapUsedPrecent()); table.addCell(stats == null ? null : stats.getJvm().getMem().getHeapUsedPrecent());
table.addCell(info == null ? null : info.getJvm().getMem().getHeapMax()); table.addCell(info == null ? null : info.getJvm().getMem().getHeapMax());
table.addCell(stats == null ? null : stats.getOs().mem() == null ? null : stats.getOs().mem().used());
table.addCell(stats == null ? null : stats.getOs().mem() == null ? null : stats.getOs().mem().usedPercent()); table.addCell(stats == null ? null : stats.getOs().mem() == null ? null : stats.getOs().mem().usedPercent());
table.addCell(info == null ? null : info.getOs().mem() == null ? null : info.getOs().mem().total()); // sigar fails to load in IntelliJ table.addCell(info == null ? null : info.getOs().mem() == null ? null : info.getOs().mem().total()); // sigar fails to load in IntelliJ
table.addCell(stats == null ? null : stats.getProcess().getOpenFileDescriptors());
table.addCell(stats == null || info == null ? null :
calculatePercentage(stats.getProcess().getOpenFileDescriptors(), info.getProcess().getMaxFileDescriptors()));
table.addCell(info == null ? null : info.getProcess().getMaxFileDescriptors());
table.addCell(stats == null ? null : stats.getOs() == null ? null : stats.getOs().getLoadAverage().length < 1 ? null : String.format(Locale.ROOT, "%.2f", stats.getOs().getLoadAverage()[0])); table.addCell(stats == null ? null : stats.getOs() == null ? null : stats.getOs().getLoadAverage().length < 1 ? null : String.format(Locale.ROOT, "%.2f", stats.getOs().getLoadAverage()[0]));
table.addCell(stats == null ? null : stats.getJvm().uptime()); table.addCell(stats == null ? null : stats.getJvm().uptime());
@ -296,4 +307,14 @@ public class RestNodesAction extends AbstractCatAction {
return table; return table;
} }
/**
* Calculate the percentage of {@code used} from the {@code max} number.
* @param used The currently used number.
* @param max The maximum number.
* @return 0 if {@code max} is 0. Otherwise 100 * {@code used} / {@code max}.
*/
private short calculatePercentage(long used, long max) {
return max == 0 ? 0 : (short)((100d * used) / max);
}
} }