Supported Platforms: All. */ - public Percent percent() { - return new Percent(percent); + public short percent() { + return percent; } /** @@ -250,7 +283,7 @@ public class ProcessStats implements Streamable, Serializable { * *
Supported Platforms: All.
*/
- public Percent getPercent() {
+ public short getPercent() {
return percent();
}
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java
index ea7805e8855..0e1e7453fd7 100644
--- a/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java
+++ b/modules/elasticsearch/src/main/java/org/elasticsearch/monitor/process/SigarProcessProbe.java
@@ -49,7 +49,7 @@ public class SigarProcessProbe extends AbstractComponent implements ProcessProbe
try {
ProcCpu cpu = sigar.getProcCpu(sigar.getPid());
stats.cpu = new ProcessStats.Cpu();
- stats.cpu.percent = cpu.getPercent();
+ stats.cpu.percent = (short) (cpu.getPercent() * 100);
stats.cpu.sys = cpu.getSys();
stats.cpu.user = cpu.getUser();
} catch (SigarException e) {
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java
index 89e1bc9fa0f..57b3f41b69d 100644
--- a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java
+++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/RestActionModule.java
@@ -23,6 +23,7 @@ import org.elasticsearch.rest.action.admin.cluster.health.RestClusterHealthActio
import org.elasticsearch.rest.action.admin.cluster.node.info.RestNodesInfoAction;
import org.elasticsearch.rest.action.admin.cluster.node.restart.RestNodesRestartAction;
import org.elasticsearch.rest.action.admin.cluster.node.shutdown.RestNodesShutdownAction;
+import org.elasticsearch.rest.action.admin.cluster.node.stats.RestNodesStatsAction;
import org.elasticsearch.rest.action.admin.cluster.ping.broadcast.RestBroadcastPingAction;
import org.elasticsearch.rest.action.admin.cluster.ping.replication.RestReplicationPingAction;
import org.elasticsearch.rest.action.admin.cluster.ping.single.RestSinglePingAction;
@@ -58,6 +59,7 @@ public class RestActionModule extends AbstractModule {
bind(RestMainAction.class).asEagerSingleton();
bind(RestNodesInfoAction.class).asEagerSingleton();
+ bind(RestNodesStatsAction.class).asEagerSingleton();
bind(RestNodesShutdownAction.class).asEagerSingleton();
bind(RestNodesRestartAction.class).asEagerSingleton();
bind(RestClusterStateAction.class).asEagerSingleton();
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java
new file mode 100644
index 00000000000..ead7a1434f5
--- /dev/null
+++ b/modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/admin/cluster/node/stats/RestNodesStatsAction.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to Elastic Search and Shay Banon under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. Elastic Search licenses this
+ * file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.elasticsearch.rest.action.admin.cluster.node.stats;
+
+import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
+import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest;
+import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
+import org.elasticsearch.client.Client;
+import org.elasticsearch.rest.*;
+import org.elasticsearch.rest.action.support.RestActions;
+import org.elasticsearch.rest.action.support.RestXContentBuilder;
+import org.elasticsearch.util.guice.inject.Inject;
+import org.elasticsearch.util.settings.Settings;
+import org.elasticsearch.util.xcontent.builder.XContentBuilder;
+
+import java.io.IOException;
+
+/**
+ * @author kimchy (shay.banon)
+ */
+public class RestNodesStatsAction extends BaseRestHandler {
+
+ @Inject public RestNodesStatsAction(Settings settings, Client client, RestController controller) {
+ super(settings, client);
+ controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/stats", this);
+ controller.registerHandler(RestRequest.Method.GET, "/_cluster/nodes/{nodeId}/stats", this);
+ }
+
+ @Override public void handleRequest(final RestRequest request, final RestChannel channel) {
+ String[] nodesIds = RestActions.splitNodes(request.param("nodeId"));
+ NodesStatsRequest nodesStatsRequest = new NodesStatsRequest(nodesIds);
+ nodesStatsRequest.listenerThreaded(false);
+ client.admin().cluster().nodesStats(nodesStatsRequest, new ActionListener