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()); }

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。