private void diskUage() { ClusterStateResponse stateResponse = client.admin().cluster().prepareState().get(); DiscoveryNodes nodes = stateResponse.getState().nodes(); NodesStatsResponse state = client.admin().cluster().prepareNodesStats().setFs(true).get(); System.out.println("hostIp " + "available " + "used " + "total " + "master"); for(DiscoveryNode node : nodes) { System.out.print(node.address() + " "); Path path = state.getNodesMap().get(node.id()).getFs().getTotal(); System.out.print(path.getAvailable().gb() + " "); System.out.print(path.getTotal().gb() - path.getFree().gb() + " "); System.out.print(path.getTotal().gb() + " "); System.out.println(nodes.getMasterNodeId().equals(node.id()) ? "m" : "-"); } }
显示结果:
hostIp available used total master 172.16.3.5:9300 null null 42 51 98 - 172.16.4.108:9300 null null 45 48 98 m
原文地址:https://www.cnblogs.com/woniu4/p/8312563.html
时间: 2024-10-15 21:44:52