org.elasticsearch.monitor.process.ProcessStats Java Examples

The following examples show how to use org.elasticsearch.monitor.process.ProcessStats. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NodeStats.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public NodeStats(DiscoveryNode node, long timestamp, @Nullable NodeIndicesStats indices,
                 @Nullable OsStats os, @Nullable ProcessStats process, @Nullable JvmStats jvm, @Nullable ThreadPoolStats threadPool,
                 @Nullable FsInfo fs, @Nullable TransportStats transport, @Nullable HttpStats http,
                 @Nullable AllCircuitBreakerStats breaker,
                 @Nullable ScriptStats scriptStats) {
    super(node);
    this.timestamp = timestamp;
    this.indices = indices;
    this.os = os;
    this.process = process;
    this.jvm = jvm;
    this.threadPool = threadPool;
    this.fs = fs;
    this.transport = transport;
    this.http = http;
    this.breaker = breaker;
    this.scriptStats = scriptStats;
}
 
Example #2
Source File: GraphiteReporter.java    From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License 6 votes vote down vote up
private void sendNodeProcessStats(ProcessStats processStats) {
    String type = buildMetricName("node.process");

    sendInt(type, "openFileDescriptors", processStats.openFileDescriptors());
    if (processStats.cpu() != null) {
        sendInt(type + ".cpu", "percent", processStats.cpu().percent());
        sendInt(type + ".cpu", "sysSeconds", processStats.cpu().sys().seconds());
        sendInt(type + ".cpu", "totalSeconds", processStats.cpu().total().seconds());
        sendInt(type + ".cpu", "userSeconds", processStats.cpu().user().seconds());
    }

    if (processStats.mem() != null) {
        sendInt(type + ".mem", "totalVirtual", processStats.mem().totalVirtual().bytes());
        sendInt(type + ".mem", "resident", processStats.mem().resident().bytes());
        sendInt(type + ".mem", "share", processStats.mem().share().bytes());
    }
}
 
Example #3
Source File: NodeProcessExpression.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private void addChildImplementations(final ProcessStats processStats, ExtendedProcessCpuStats cpuStats) {
    childImplementations.put(OPEN_FILE_DESCRIPTORS, new SysNodeExpression<Long>() {
        @Override
        public Long value() {
            if (processStats != null) {
                return processStats.getOpenFileDescriptors();
            } else {
                return -1L;
            }
        }
    });
    childImplementations.put(MAX_OPEN_FILE_DESCRIPTORS, new SysNodeExpression<Long>() {
        @Override
        public Long value() {
            if (processStats != null) {
                return processStats.getMaxFileDescriptors();
            } else {
                return -1L;
            }
        }
    });
    childImplementations.put(PROBE_TIMESTAMP, new SysNodeExpression<Long>() {
        @Override
        public Long value() {
            if (processStats != null) {
                return processStats.getTimestamp();
            } else {
                return -1L;
            }
        }
    });
    childImplementations.put(SysNodesTableInfo.SYS_COL_PROCESS_CPU, new NodeProcessCpuExpression(cpuStats));
}
 
Example #4
Source File: NodeStats.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    timestamp = in.readVLong();
    if (in.readBoolean()) {
        indices = NodeIndicesStats.readIndicesStats(in);
    }
    if (in.readBoolean()) {
        os = OsStats.readOsStats(in);
    }
    if (in.readBoolean()) {
        process = ProcessStats.readProcessStats(in);
    }
    if (in.readBoolean()) {
        jvm = JvmStats.readJvmStats(in);
    }
    if (in.readBoolean()) {
        threadPool = ThreadPoolStats.readThreadPoolStats(in);
    }
    if (in.readBoolean()) {
        fs = FsInfo.readFsInfo(in);
    }
    if (in.readBoolean()) {
        transport = TransportStats.readTransportStats(in);
    }
    if (in.readBoolean()) {
        http = HttpStats.readHttpStats(in);
    }
    breaker = AllCircuitBreakerStats.readOptionalAllCircuitBreakerStats(in);
    scriptStats = in.readOptionalStreamable(new ScriptStats());

}
 
Example #5
Source File: PrometheusMetricsCollector.java    From elasticsearch-prometheus-exporter with Apache License 2.0 5 votes vote down vote up
private void updateProcessMetrics(ProcessStats ps) {
    if (ps != null) {
        catalog.setNodeGauge("process_cpu_percent", ps.getCpu().getPercent());
        catalog.setNodeGauge("process_cpu_time_seconds", ps.getCpu().getTotal().getSeconds());

        catalog.setNodeGauge("process_mem_total_virtual_bytes", ps.getMem().getTotalVirtual().getBytes());

        catalog.setNodeGauge("process_file_descriptors_open_number", ps.getOpenFileDescriptors());
        catalog.setNodeGauge("process_file_descriptors_max_number", ps.getMaxFileDescriptors());
    }
}
 
Example #6
Source File: NodeStatsContext.java    From crate with Apache License 2.0 5 votes vote down vote up
public NodeStatsContext(StreamInput in, boolean complete) throws IOException {
    this.complete = complete;
    this.id = DataTypes.STRING.readValueFrom(in);
    this.name = DataTypes.STRING.readValueFrom(in);
    this.hostname = DataTypes.STRING.readValueFrom(in);
    this.timestamp = in.readLong();
    this.version = in.readBoolean() ? Version.readVersion(in) : null;
    this.build = in.readBoolean() ? Build.readBuild(in) : null;
    this.restUrl = DataTypes.STRING.readValueFrom(in);
    this.pgPort = in.readOptionalVInt();
    this.httpPort = in.readOptionalVInt();
    this.transportPort = in.readOptionalVInt();
    this.jvmStats = in.readOptionalWriteable(JvmStats::new);
    this.osInfo = in.readOptionalWriteable(OsInfo::new);
    this.processStats = in.readOptionalWriteable(ProcessStats::new);
    this.osStats = in.readOptionalWriteable(OsStats::new);
    this.fsInfo = in.readOptionalWriteable(FsInfo::new);
    this.extendedOsStats = in.readOptionalWriteable(ExtendedOsStats::new);
    this.threadPools = in.readOptionalWriteable(ThreadPoolStats::new);
    this.httpStats = in.readOptionalWriteable(HttpStats::new);
    this.psqlStats = in.readOptionalWriteable(ConnectionStats::new);
    this.openTransportConnections = in.readLong();
    this.clusterStateVersion = in.readLong();

    this.osName = DataTypes.STRING.readValueFrom(in);
    this.osArch = DataTypes.STRING.readValueFrom(in);
    this.osVersion = DataTypes.STRING.readValueFrom(in);
    this.javaVersion = DataTypes.STRING.readValueFrom(in);
    this.jvmName = DataTypes.STRING.readValueFrom(in);
    this.jvmVendor = DataTypes.STRING.readValueFrom(in);
    this.jvmVersion = DataTypes.STRING.readValueFrom(in);
}
 
Example #7
Source File: NodeProcessExpression.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public NodeProcessExpression(ProcessStats processStats, ExtendedProcessCpuStats cpuStats) {
    addChildImplementations(processStats, cpuStats);
}
 
Example #8
Source File: NodeStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Process level statistics.
 */
@Nullable
public ProcessStats getProcess() {
    return process;
}
 
Example #9
Source File: ProcessStatsMonitor.java    From Raigad with Apache License 2.0 4 votes vote down vote up
@Override
public void execute() throws Exception {
    // Only start monitoring if Elasticsearch is started
    if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) {
        String exceptionMsg = "Elasticsearch is not yet started, check back again later";
        logger.info(exceptionMsg);
        return;
    }

    ProcessStatsBean processStatsBean = new ProcessStatsBean();

    try {
        NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config);
        NodeStats nodeStats = null;

        List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes();

        if (nodeStatsList.size() > 0) {
            nodeStats = nodeStatsList.get(0);
        }

        if (nodeStats == null) {
            logger.info("Process stats are not available (node stats is not available)");
            return;
        }

        ProcessStats processStats = nodeStats.getProcess();
        if (processStats == null) {
            logger.info("Process stats are not available");
            return;
        }

        //Memory
        processStatsBean.totalVirtualInBytes = processStats.getMem().getTotalVirtual().getBytes();

        //CPU
        processStatsBean.cpuPercent = processStats.getCpu().getPercent();
        processStatsBean.totalInMillis = processStats.getCpu().getTotal().getMillis();

        //Open file descriptors
        processStatsBean.openFileDescriptors = processStats.getOpenFileDescriptors();

        //Timestamp
        processStatsBean.cpuTimestamp = processStats.getTimestamp();
    } catch (Exception e) {
        logger.warn("Failed to load process stats data", e);
    }

    processStatsReporter.processStatsBean.set(processStatsBean);
}
 
Example #10
Source File: NodeStatsContext.java    From crate with Apache License 2.0 4 votes vote down vote up
public ProcessStats processStats() {
    return processStats;
}