Search in sources :

Example 1 with JvmInfo

use of org.elasticsearch.monitor.jvm.JvmInfo in project crate by crate.

the class NodeEnvironment method maybeLogHeapDetails.

private void maybeLogHeapDetails() {
    JvmInfo jvmInfo = JvmInfo.jvmInfo();
    ByteSizeValue maxHeapSize = jvmInfo.getMem().getHeapMax();
    String useCompressedOops = jvmInfo.useCompressedOops();
    logger.info("heap size [{}], compressed ordinary object pointers [{}]", maxHeapSize, useCompressedOops);
}
Also used : JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Example 2 with JvmInfo

use of org.elasticsearch.monitor.jvm.JvmInfo in project elasticsearch by elastic.

the class NodeInfoStreamingTests method createNodeInfo.

private static NodeInfo createNodeInfo() {
    Build build = Build.CURRENT;
    DiscoveryNode node = new DiscoveryNode("test_node", buildNewFakeTransportAddress(), emptyMap(), emptySet(), VersionUtils.randomVersion(random()));
    Settings settings = randomBoolean() ? null : Settings.builder().put("test", "setting").build();
    OsInfo osInfo = null;
    if (randomBoolean()) {
        int availableProcessors = randomIntBetween(1, 64);
        int allocatedProcessors = randomIntBetween(1, availableProcessors);
        long refreshInterval = randomBoolean() ? -1 : randomNonNegativeLong();
        String name = randomAsciiOfLengthBetween(3, 10);
        String arch = randomAsciiOfLengthBetween(3, 10);
        String version = randomAsciiOfLengthBetween(3, 10);
        osInfo = new OsInfo(refreshInterval, availableProcessors, allocatedProcessors, name, arch, version);
    }
    ProcessInfo process = randomBoolean() ? null : new ProcessInfo(randomInt(), randomBoolean(), randomNonNegativeLong());
    JvmInfo jvm = randomBoolean() ? null : JvmInfo.jvmInfo();
    ThreadPoolInfo threadPoolInfo = null;
    if (randomBoolean()) {
        int numThreadPools = randomIntBetween(1, 10);
        List<ThreadPool.Info> threadPoolInfos = new ArrayList<>(numThreadPools);
        for (int i = 0; i < numThreadPools; i++) {
            threadPoolInfos.add(new ThreadPool.Info(randomAsciiOfLengthBetween(3, 10), randomFrom(ThreadPool.ThreadPoolType.values()), randomInt()));
        }
        threadPoolInfo = new ThreadPoolInfo(threadPoolInfos);
    }
    Map<String, BoundTransportAddress> profileAddresses = new HashMap<>();
    BoundTransportAddress dummyBoundTransportAddress = new BoundTransportAddress(new TransportAddress[] { buildNewFakeTransportAddress() }, buildNewFakeTransportAddress());
    profileAddresses.put("test_address", dummyBoundTransportAddress);
    TransportInfo transport = randomBoolean() ? null : new TransportInfo(dummyBoundTransportAddress, profileAddresses);
    HttpInfo httpInfo = randomBoolean() ? null : new HttpInfo(dummyBoundTransportAddress, randomLong());
    PluginsAndModules pluginsAndModules = null;
    if (randomBoolean()) {
        int numPlugins = randomIntBetween(0, 5);
        List<PluginInfo> plugins = new ArrayList<>();
        for (int i = 0; i < numPlugins; i++) {
            plugins.add(new PluginInfo(randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10)));
        }
        int numModules = randomIntBetween(0, 5);
        List<PluginInfo> modules = new ArrayList<>();
        for (int i = 0; i < numModules; i++) {
            modules.add(new PluginInfo(randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10), randomAsciiOfLengthBetween(3, 10)));
        }
        pluginsAndModules = new PluginsAndModules(plugins, modules);
    }
    IngestInfo ingestInfo = null;
    if (randomBoolean()) {
        int numProcessors = randomIntBetween(0, 5);
        List<ProcessorInfo> processors = new ArrayList<>(numProcessors);
        for (int i = 0; i < numProcessors; i++) {
            processors.add(new ProcessorInfo(randomAsciiOfLengthBetween(3, 10)));
        }
        ingestInfo = new IngestInfo(processors);
    }
    ByteSizeValue indexingBuffer = null;
    if (randomBoolean()) {
        // pick a random long that sometimes exceeds an int:
        indexingBuffer = new ByteSizeValue(random().nextLong() & ((1L << 40) - 1));
    }
    return new NodeInfo(VersionUtils.randomVersion(random()), build, node, settings, osInfo, process, jvm, threadPoolInfo, transport, httpInfo, pluginsAndModules, ingestInfo, indexingBuffer);
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) ProcessorInfo(org.elasticsearch.ingest.ProcessorInfo) HashMap(java.util.HashMap) PluginsAndModules(org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules) ArrayList(java.util.ArrayList) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) HttpInfo(org.elasticsearch.http.HttpInfo) OsInfo(org.elasticsearch.monitor.os.OsInfo) Build(org.elasticsearch.Build) IngestInfo(org.elasticsearch.ingest.IngestInfo) PluginInfo(org.elasticsearch.plugins.PluginInfo) Settings(org.elasticsearch.common.settings.Settings) ThreadPoolInfo(org.elasticsearch.threadpool.ThreadPoolInfo) TransportInfo(org.elasticsearch.transport.TransportInfo) ProcessInfo(org.elasticsearch.monitor.process.ProcessInfo) PluginInfo(org.elasticsearch.plugins.PluginInfo) OsInfo(org.elasticsearch.monitor.os.OsInfo) ThreadPoolInfo(org.elasticsearch.threadpool.ThreadPoolInfo) ProcessInfo(org.elasticsearch.monitor.process.ProcessInfo) IngestInfo(org.elasticsearch.ingest.IngestInfo) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) ProcessorInfo(org.elasticsearch.ingest.ProcessorInfo) HttpInfo(org.elasticsearch.http.HttpInfo) TransportInfo(org.elasticsearch.transport.TransportInfo) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress)

Example 3 with JvmInfo

use of org.elasticsearch.monitor.jvm.JvmInfo in project elasticsearch by elastic.

the class RestNodesAction method buildTable.

private Table buildTable(boolean fullId, RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
    DiscoveryNodes nodes = state.getState().nodes();
    String masterId = nodes.getMasterNodeId();
    Table table = getTableWithHeader(req);
    for (DiscoveryNode node : nodes) {
        NodeInfo info = nodesInfo.getNodesMap().get(node.getId());
        NodeStats stats = nodesStats.getNodesMap().get(node.getId());
        JvmInfo jvmInfo = info == null ? null : info.getJvm();
        JvmStats jvmStats = stats == null ? null : stats.getJvm();
        FsInfo fsInfo = stats == null ? null : stats.getFs();
        OsStats osStats = stats == null ? null : stats.getOs();
        ProcessStats processStats = stats == null ? null : stats.getProcess();
        NodeIndicesStats indicesStats = stats == null ? null : stats.getIndices();
        table.startRow();
        table.addCell(fullId ? node.getId() : Strings.substring(node.getId(), 0, 4));
        table.addCell(info == null ? null : info.getProcess().getId());
        table.addCell(node.getHostAddress());
        table.addCell(node.getAddress().address().getPort());
        final HttpInfo httpInfo = info == null ? null : info.getHttp();
        if (httpInfo != null) {
            TransportAddress transportAddress = httpInfo.getAddress().publishAddress();
            table.addCell(NetworkAddress.format(transportAddress.address()));
        } else {
            table.addCell("-");
        }
        table.addCell(node.getVersion().toString());
        table.addCell(info == null ? null : info.getBuild().shortHash());
        table.addCell(jvmInfo == null ? null : jvmInfo.version());
        table.addCell(fsInfo == null ? null : fsInfo.getTotal().getAvailable());
        table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsed());
        table.addCell(jvmStats == null ? null : jvmStats.getMem().getHeapUsedPercent());
        table.addCell(jvmInfo == null ? null : jvmInfo.getMem().getHeapMax());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsed());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getUsedPercent());
        table.addCell(osStats == null ? null : osStats.getMem() == null ? null : osStats.getMem().getTotal());
        table.addCell(processStats == null ? null : processStats.getOpenFileDescriptors());
        table.addCell(processStats == null ? null : calculatePercentage(processStats.getOpenFileDescriptors(), processStats.getMaxFileDescriptors()));
        table.addCell(processStats == null ? null : processStats.getMaxFileDescriptors());
        table.addCell(osStats == null ? null : Short.toString(osStats.getCpu().getPercent()));
        boolean hasLoadAverage = osStats != null && osStats.getCpu().getLoadAverage() != null;
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[0] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[0]));
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[1] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[1]));
        table.addCell(!hasLoadAverage || osStats.getCpu().getLoadAverage()[2] == -1 ? null : String.format(Locale.ROOT, "%.2f", osStats.getCpu().getLoadAverage()[2]));
        table.addCell(jvmStats == null ? null : jvmStats.getUptime());
        final String roles;
        if (node.getRoles().isEmpty()) {
            roles = "-";
        } else {
            roles = node.getRoles().stream().map(DiscoveryNode.Role::getAbbreviation).collect(Collectors.joining());
        }
        table.addCell(roles);
        table.addCell(masterId == null ? "x" : masterId.equals(node.getId()) ? "*" : "-");
        table.addCell(node.getName());
        CompletionStats completionStats = indicesStats == null ? null : stats.getIndices().getCompletion();
        table.addCell(completionStats == null ? null : completionStats.getSize());
        FieldDataStats fdStats = indicesStats == null ? null : stats.getIndices().getFieldData();
        table.addCell(fdStats == null ? null : fdStats.getMemorySize());
        table.addCell(fdStats == null ? null : fdStats.getEvictions());
        QueryCacheStats fcStats = indicesStats == null ? null : indicesStats.getQueryCache();
        table.addCell(fcStats == null ? null : fcStats.getMemorySize());
        table.addCell(fcStats == null ? null : fcStats.getEvictions());
        RequestCacheStats qcStats = indicesStats == null ? null : indicesStats.getRequestCache();
        table.addCell(qcStats == null ? null : qcStats.getMemorySize());
        table.addCell(qcStats == null ? null : qcStats.getEvictions());
        table.addCell(qcStats == null ? null : qcStats.getHitCount());
        table.addCell(qcStats == null ? null : qcStats.getMissCount());
        FlushStats flushStats = indicesStats == null ? null : indicesStats.getFlush();
        table.addCell(flushStats == null ? null : flushStats.getTotal());
        table.addCell(flushStats == null ? null : flushStats.getTotalTime());
        GetStats getStats = indicesStats == null ? null : indicesStats.getGet();
        table.addCell(getStats == null ? null : getStats.current());
        table.addCell(getStats == null ? null : getStats.getTime());
        table.addCell(getStats == null ? null : getStats.getCount());
        table.addCell(getStats == null ? null : getStats.getExistsTime());
        table.addCell(getStats == null ? null : getStats.getExistsCount());
        table.addCell(getStats == null ? null : getStats.getMissingTime());
        table.addCell(getStats == null ? null : getStats.getMissingCount());
        IndexingStats indexingStats = indicesStats == null ? null : indicesStats.getIndexing();
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCurrent());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteTime());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getDeleteCount());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCurrent());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexTime());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexCount());
        table.addCell(indexingStats == null ? null : indexingStats.getTotal().getIndexFailedCount());
        MergeStats mergeStats = indicesStats == null ? null : indicesStats.getMerge();
        table.addCell(mergeStats == null ? null : mergeStats.getCurrent());
        table.addCell(mergeStats == null ? null : mergeStats.getCurrentNumDocs());
        table.addCell(mergeStats == null ? null : mergeStats.getCurrentSize());
        table.addCell(mergeStats == null ? null : mergeStats.getTotal());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalNumDocs());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalSize());
        table.addCell(mergeStats == null ? null : mergeStats.getTotalTime());
        RefreshStats refreshStats = indicesStats == null ? null : indicesStats.getRefresh();
        table.addCell(refreshStats == null ? null : refreshStats.getTotal());
        table.addCell(refreshStats == null ? null : refreshStats.getTotalTime());
        table.addCell(refreshStats == null ? null : refreshStats.getListeners());
        ScriptStats scriptStats = stats == null ? null : stats.getScriptStats();
        table.addCell(scriptStats == null ? null : scriptStats.getCompilations());
        table.addCell(scriptStats == null ? null : scriptStats.getCacheEvictions());
        SearchStats searchStats = indicesStats == null ? null : indicesStats.getSearch();
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getFetchCount());
        table.addCell(searchStats == null ? null : searchStats.getOpenContexts());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getQueryCount());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getScrollCount());
        SegmentsStats segmentsStats = indicesStats == null ? null : indicesStats.getSegments();
        table.addCell(segmentsStats == null ? null : segmentsStats.getCount());
        table.addCell(segmentsStats == null ? null : segmentsStats.getMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getIndexWriterMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getVersionMapMemory());
        table.addCell(segmentsStats == null ? null : segmentsStats.getBitsetMemory());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCurrent());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestTime());
        table.addCell(searchStats == null ? null : searchStats.getTotal().getSuggestCount());
        table.endRow();
    }
    return table;
}
Also used : DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) RefreshStats(org.elasticsearch.index.refresh.RefreshStats) TransportAddress(org.elasticsearch.common.transport.TransportAddress) GetStats(org.elasticsearch.index.get.GetStats) SegmentsStats(org.elasticsearch.index.engine.SegmentsStats) HttpInfo(org.elasticsearch.http.HttpInfo) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) FsInfo(org.elasticsearch.monitor.fs.FsInfo) FlushStats(org.elasticsearch.index.flush.FlushStats) QueryCacheStats(org.elasticsearch.index.cache.query.QueryCacheStats) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) FieldDataStats(org.elasticsearch.index.fielddata.FieldDataStats) JvmStats(org.elasticsearch.monitor.jvm.JvmStats) ScriptStats(org.elasticsearch.script.ScriptStats) ProcessStats(org.elasticsearch.monitor.process.ProcessStats) Table(org.elasticsearch.common.Table) IndexingStats(org.elasticsearch.index.shard.IndexingStats) OsStats(org.elasticsearch.monitor.os.OsStats) SearchStats(org.elasticsearch.index.search.stats.SearchStats) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) MergeStats(org.elasticsearch.index.merge.MergeStats) NodeIndicesStats(org.elasticsearch.indices.NodeIndicesStats) RequestCacheStats(org.elasticsearch.index.cache.request.RequestCacheStats) CompletionStats(org.elasticsearch.search.suggest.completion.CompletionStats)

Example 4 with JvmInfo

use of org.elasticsearch.monitor.jvm.JvmInfo in project elasticsearch by elastic.

the class NodeEnvironment method maybeLogHeapDetails.

private void maybeLogHeapDetails() {
    JvmInfo jvmInfo = JvmInfo.jvmInfo();
    ByteSizeValue maxHeapSize = jvmInfo.getMem().getHeapMax();
    String useCompressedOops = jvmInfo.useCompressedOops();
    logger.info("heap size [{}], compressed ordinary object pointers [{}]", maxHeapSize, useCompressedOops);
}
Also used : JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Example 5 with JvmInfo

use of org.elasticsearch.monitor.jvm.JvmInfo in project graylog2-server by Graylog2.

the class IndexerClusterCheckerThread method doRun.

@Override
public void doRun() {
    if (!notificationService.isFirst(Notification.Type.ES_OPEN_FILES)) {
        return;
    }
    try {
        cluster.health().getStatus();
    } catch (Exception e) {
        LOG.info("Indexer not fully initialized yet. Skipping periodic cluster check.");
        return;
    }
    boolean allHigher = true;
    final Map<String, NodeInfo> nodesInfos = cluster.getDataNodes();
    final Map<String, NodeStats> nodesStats = cluster.getNodesStats(nodesInfos.keySet().toArray(new String[nodesInfos.size()]));
    for (Map.Entry<String, NodeStats> entry : nodesStats.entrySet()) {
        final String nodeId = entry.getKey();
        final NodeStats nodeStats = entry.getValue();
        final NodeInfo nodeInfo = nodesInfos.get(nodeId);
        final String nodeName = nodeInfo.getNode().getName();
        // Check number of maximum open files.
        final ProcessStats processStats = nodeStats.getProcess();
        if (processStats == null) {
            LOG.debug("Couldn't read process stats of Elasticsearch node {}", nodeName);
            return;
        }
        final long maxFileDescriptors = processStats.getMaxFileDescriptors();
        final JvmInfo jvmInfo = nodeInfo.getJvm();
        if (jvmInfo == null) {
            LOG.debug("Couldn't read JVM info of Elasticsearch node {}", nodeName);
            return;
        }
        final String osName = jvmInfo.getSystemProperties().getOrDefault("os.name", "");
        if (osName.startsWith("Windows")) {
            LOG.debug("Skipping open file limit check for Indexer node <{}> on Windows", nodeName);
        } else if (maxFileDescriptors != -1 && maxFileDescriptors < MINIMUM_OPEN_FILES_LIMIT) {
            // Write notification.
            final Notification notification = notificationService.buildNow().addType(Notification.Type.ES_OPEN_FILES).addSeverity(Notification.Severity.URGENT).addDetail("hostname", nodeInfo.getHostname()).addDetail("max_file_descriptors", maxFileDescriptors);
            if (notificationService.publishIfFirst(notification)) {
                LOG.warn("Indexer node <{}> open file limit is too low: [{}]. Set it to at least {}.", nodeName, maxFileDescriptors, MINIMUM_OPEN_FILES_LIMIT);
            }
            allHigher = false;
        }
    }
    if (allHigher) {
        Notification notification = notificationService.build().addType(Notification.Type.ES_OPEN_FILES);
        notificationService.fixed(notification);
    }
}
Also used : ProcessStats(org.elasticsearch.monitor.process.ProcessStats) JvmInfo(org.elasticsearch.monitor.jvm.JvmInfo) Notification(org.graylog2.notifications.Notification) NodeStats(org.elasticsearch.action.admin.cluster.node.stats.NodeStats) NodeInfo(org.elasticsearch.action.admin.cluster.node.info.NodeInfo) Map(java.util.Map)

Aggregations

JvmInfo (org.elasticsearch.monitor.jvm.JvmInfo)5 NodeInfo (org.elasticsearch.action.admin.cluster.node.info.NodeInfo)3 ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)3 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)2 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)2 HttpInfo (org.elasticsearch.http.HttpInfo)2 ProcessStats (org.elasticsearch.monitor.process.ProcessStats)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Build (org.elasticsearch.Build)1 PluginsAndModules (org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules)1 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)1 Table (org.elasticsearch.common.Table)1 Settings (org.elasticsearch.common.settings.Settings)1 BoundTransportAddress (org.elasticsearch.common.transport.BoundTransportAddress)1 TransportAddress (org.elasticsearch.common.transport.TransportAddress)1 QueryCacheStats (org.elasticsearch.index.cache.query.QueryCacheStats)1 RequestCacheStats (org.elasticsearch.index.cache.request.RequestCacheStats)1 SegmentsStats (org.elasticsearch.index.engine.SegmentsStats)1