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

 

相关文章:

  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-09-29
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案