Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update process stats #12043

Merged
merged 1 commit into from
Jul 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,11 @@ public void addNodeStats(NodeStats nodeStats) {
return;
}
count++;
if (nodeStats.getProcess().cpu() != null) {
if (nodeStats.getProcess().getCpu() != null) {
// with no sigar, this may not be available
cpuPercent += nodeStats.getProcess().cpu().getPercent();
cpuPercent += nodeStats.getProcess().getCpu().getPercent();
}
long fd = nodeStats.getProcess().openFileDescriptors();
long fd = nodeStats.getProcess().getOpenFileDescriptors();
if (fd > 0) {
// fd can be -1 if not supported on platform
totalOpenFileDescriptors += fd;
Expand Down
16 changes: 12 additions & 4 deletions core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.monitor.process.JmxProcessProbe;
import org.elasticsearch.monitor.process.ProcessProbe;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.elasticsearch.node.internal.InternalSettingsPreparer;
Expand Down Expand Up @@ -143,14 +143,22 @@ public boolean handle(int code) {
StringHelper.randomId();
}

static void initializeProbes() {
// Force probes to be loaded
ProcessProbe.getInstance();
}

public static boolean isMemoryLocked() {
return Natives.isMemoryLocked();
}

private void setup(boolean addShutdownHook, Settings settings, Environment environment) throws Exception {
initializeNatives(settings.getAsBoolean("bootstrap.mlockall", false),
initializeNatives(settings.getAsBoolean("bootstrap.mlockall", false),
settings.getAsBoolean("bootstrap.ctrlhandler", true));

// initialize probes before the security manager is installed
initializeProbes();

if (addShutdownHook) {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
Expand All @@ -167,7 +175,7 @@ public void run() {

// look for jar hell
JarHell.checkJarHell();

// install SM after natives, shutdown hooks, etc.
setupSecurity(settings, environment);

Expand Down Expand Up @@ -262,7 +270,7 @@ public static void main(String[] args) {

if (System.getProperty("es.max-open-files", "false").equals("true")) {
ESLogger logger = Loggers.getLogger(Bootstrap.class);
logger.info("max_open_files [{}]", JmxProcessProbe.getMaxFileDescriptorCount());
logger.info("max_open_files [{}]", ProcessProbe.getInstance().getMaxFileDescriptorCount());
}

// warn if running using the client VM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.monitor.os.JmxOsProbe;
import org.elasticsearch.monitor.os.OsProbe;
import org.elasticsearch.monitor.os.OsService;
import org.elasticsearch.monitor.process.JmxProcessProbe;
import org.elasticsearch.monitor.process.ProcessProbe;
import org.elasticsearch.monitor.process.ProcessService;

Expand All @@ -50,7 +49,7 @@ public MonitorModule(Settings settings) {
@Override
protected void configure() {
// bind default implementations
bind(ProcessProbe.class).to(JmxProcessProbe.class).asEagerSingleton();
bind(ProcessProbe.class).toInstance(ProcessProbe.getInstance());
bind(OsProbe.class).to(JmxOsProbe.class).asEagerSingleton();
bind(FsProbe.class).asEagerSingleton();

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.monitor.process;

import org.elasticsearch.bootstrap.Bootstrap;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
Expand All @@ -29,27 +28,20 @@

import java.io.IOException;

/**
*
*/
public class ProcessInfo implements Streamable, ToXContent {

long refreshInterval;

private long id;

private long maxFileDescriptors = -1;

private boolean mlockall;

ProcessInfo() {

}

public ProcessInfo(long id, long maxFileDescriptors) {
public ProcessInfo(long id, boolean mlockall) {
this.id = id;
this.maxFileDescriptors = maxFileDescriptors;
this.mlockall = Bootstrap.isMemoryLocked();
this.mlockall = mlockall;
}

public long refreshInterval() {
Expand All @@ -60,30 +52,11 @@ public long getRefreshInterval() {
return this.refreshInterval;
}

/**
* The process id.
*/
public long id() {
return this.id;
}

/**
* The process id.
*/
public long getId() {
return id();
}

public long maxFileDescriptors() {
return this.maxFileDescriptors;
}

public long getMaxFileDescriptors() {
return maxFileDescriptors;
}

public boolean mlockAll() {
return mlockall;
return id;
}

public boolean isMlockall() {
Expand All @@ -95,7 +68,6 @@ static final class Fields {
static final XContentBuilderString REFRESH_INTERVAL = new XContentBuilderString("refresh_interval");
static final XContentBuilderString REFRESH_INTERVAL_IN_MILLIS = new XContentBuilderString("refresh_interval_in_millis");
static final XContentBuilderString ID = new XContentBuilderString("id");
static final XContentBuilderString MAX_FILE_DESCRIPTORS = new XContentBuilderString("max_file_descriptors");
static final XContentBuilderString MLOCKALL = new XContentBuilderString("mlockall");
}

Expand All @@ -104,7 +76,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
builder.startObject(Fields.PROCESS);
builder.timeValueField(Fields.REFRESH_INTERVAL_IN_MILLIS, Fields.REFRESH_INTERVAL, refreshInterval);
builder.field(Fields.ID, id);
builder.field(Fields.MAX_FILE_DESCRIPTORS, maxFileDescriptors);
builder.field(Fields.MLOCKALL, mlockall);
builder.endObject();
return builder;
Expand All @@ -120,15 +91,13 @@ public static ProcessInfo readProcessInfo(StreamInput in) throws IOException {
public void readFrom(StreamInput in) throws IOException {
refreshInterval = in.readLong();
id = in.readLong();
maxFileDescriptors = in.readLong();
mlockall = in.readBoolean();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeLong(refreshInterval);
out.writeLong(id);
out.writeLong(maxFileDescriptors);
out.writeBoolean(mlockall);
}
}
Loading