Java Code Examples for org.elasticsearch.action.admin.cluster.node.stats.NodeStats#getOs()
The following examples show how to use
org.elasticsearch.action.admin.cluster.node.stats.NodeStats#getOs() .
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: ClusterStatsNodes.java From Elasticsearch with Apache License 2.0 | 5 votes |
public void addNodeInfoStats(NodeInfo nodeInfo, NodeStats nodeStats) { availableProcessors += nodeInfo.getOs().getAvailableProcessors(); allocatedProcessors += nodeInfo.getOs().getAllocatedProcessors(); if (nodeInfo.getOs().getName() != null) { names.addTo(nodeInfo.getOs().getName(), 1); } if (nodeStats.getOs() != null && nodeStats.getOs().getMem() != null) { availableMemory += nodeStats.getOs().getMem().getFree().bytes(); } }
Example 2
Source File: OsStatsMonitor.java From Raigad with Apache License 2.0 | 4 votes |
@Override public void execute() throws Exception { // If Elasticsearch is started then only start the monitoring if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) { String exceptionMsg = "Elasticsearch is not yet started, check back again later"; logger.info(exceptionMsg); return; } OsStatsBean osStatsBean = new OsStatsBean(); 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("OS stats is not available (node stats is not available)"); return; } OsStats osStats = nodeStats.getOs(); if (osStats == null) { logger.info("OS stats is not available"); return; } //Memory osStatsBean.freeInBytes = osStats.getMem().getFree().getBytes(); osStatsBean.usedInBytes = osStats.getMem().getUsed().getBytes(); osStatsBean.actualFreeInBytes = osStats.getMem().getFree().getBytes(); osStatsBean.actualUsedInBytes = osStats.getMem().getUsed().getBytes(); osStatsBean.freePercent = osStats.getMem().getFreePercent(); osStatsBean.usedPercent = osStats.getMem().getUsedPercent(); //CPU osStatsBean.cpuSys = osStats.getCpu().getPercent(); osStatsBean.cpuUser = 0; osStatsBean.cpuIdle = 0; osStatsBean.cpuStolen = 0; //Swap osStatsBean.swapFreeInBytes = osStats.getSwap().getFree().getBytes(); osStatsBean.swapUsedInBytes = osStats.getSwap().getUsed().getBytes(); //Uptime osStatsBean.uptimeInMillis = 0; //Timestamp osStatsBean.osTimestamp = osStats.getTimestamp(); } catch (Exception e) { logger.warn("Failed to load OS stats data", e); } osStatsReporter.osStatsBean.set(osStatsBean); }