zoukankan      html  css  js  c++  java
  • VMware之主机数据获取

    前面写了存储器,群集的数据获取,现在还有主机与具体VM机的数据未写出来。现在先写出主机概要数据吧。

    //前面的代码我就不写了。因为大致一样
     for (ManagedEntity managedEntity : esxs) {
    HostSystem hs=(HostSystem) managedEntity;
    
    ////////////
                            HostHardwareInfo hwi=hs.getHardware();
                            HostListSummary hsr=hs.getSummary();
                            HostStorageSystem hd=hs.getHostStorageSystem();
                            HostSnmpSystem hif=hs.getHostSnmpSystem();
                              HostHealthStatusSystem pf=hs.getHealthStatusSystem();
                            
                            //
                            /*主机信息的获取
                            System.out.println("cpu uuid:"+hsr.getHardware().uuid);
                            
                            System.out.println("cpu :"+hsr.getHardware().cpuMhz);
                            
                            System.out.println("overallMemoryUsage:已消耗的内存"+hsr.getQuickStats().overallMemoryUsage);
                            System.out.println("distributedMemoryFairness:"+hsr.getQuickStats().distributedMemoryFairness);
                            System.out.println("overallCpuUsage:"+hsr.getQuickStats().overallCpuUsage);
                            System.out.println("distributedMemoryFairness:"+hsr.getQuickStats().distributedCpuFairness);
                            System.out.println("处理器插槽 :"+hsr.getHardware().numCpuPkgs);
                            System.out.println(    "CPU核心:"+hsr.getHardware().numCpuCores/2);
                            System.out.println("逻辑处理器 :"+hsr.getHardware().numCpuThreads);
                            System.out.println("memorySize :"+hsr.getHardware().memorySize);
                            System.out.println("vendor :"+hsr.getHardware().vendor);
                            System.out.println("cpuModel :"+hsr.getHardware().cpuModel);
                            System.out.println("identifierValue :"+hsr.getHardware().otherIdentifyingInfo[0].identifierType);
                            System.out.println("hsr.getHost().type :"+hsr.getHost().type);
                            System.out.println("hsr.getHost().val:"+hsr.getHost().val);*/
                            
                            long hz=hwi.cpuInfo.hz;
                            long e9 = 1000000000;
    //cpu获取的数值需要转换
    double hzd = new java.math.BigDecimal(((double) hz) / e9).setScale(2, java.math.BigDecimal.ROUND_HALF_UP) .doubleValue(); //主机信息 System.out.println("----"); System.out.println("1 主机信息:"+hs.getName()); System.out.println("2:"+String.valueOf(hzd)+"GHZ"); System.out.println("3:连接人信息:"+hs.getServerConnection().getUsername()); System.out.println("4:"+hs.getServerConnection().getSessionStr()); System.out.println("5:"+hs.getServerConnection().getServiceInstance().getAboutInfo().name); System.out.println("6:"+hs.getServerConnection().getServiceInstance().getAlarmManager()); System.out.println("7:"+hs.getServerConnection().getServiceInstance().getAboutInfo()); System.out.println("8:当前世界"+hs.getServerConnection().getServiceInstance().currentTime().getTime()); System.out.println("9:"+hs.getServerConnection().getServiceInstance().getCustomFieldsManager().getField()); System.out.println("容量 :"+hsr.getHardware().memorySize/1024/1024); System.out.println("11:"+hs.getCustomValue()); System.out.println("12:"+hs.getCapability().maxHostRunningVms); System.out.println("==========="); System.out.println("13:"+hs.getAvailableField()[0].name); System.out.println("15:"+hs.getAvailableField()[0].managedObjectType); System.out.println("16:"+hs.getAvailableField()[0].type); System.out.println("==========="); System.out.println("17:"+hs.getAvailableField()[1].name); System.out.println("18:"+hs.getAvailableField()[1].managedObjectType); System.out.println("19:"+hs.getAvailableField()[1].type); System.out.println("15:"+hs.getCapability()); }
  • 相关阅读:
    典型用户和用户场景
    每日站立会议个人博客(冲刺周)-Tuesday
    WPS中VB编辑器的安装
    WARN hdfs.DataStreamer: Caught exception
    java.net.ConnectException: Your endpoint configuration is wrong; For more details see: http://wiki.apache.org/hadoop/UnsetHostnameOrPort
    “初始化 Java 工具”期间发生了内部错误, java.lang.NullPointerException
    在Github上搭建个人主页
    关于新版的MySQL安装教程
    stopping hbasecat:/tmp/hbase-root-master.pid:No such file or directory
    途牛订单的服务化演进
  • 原文地址:https://www.cnblogs.com/jimw/p/4463398.html
Copyright © 2011-2022 走看看