Class: RbVmomi::VIM::ComputeResource
- Inherits:
-
Object
- Object
- RbVmomi::VIM::ComputeResource
- Defined in:
- lib/rbvmomi/vim/ComputeResource.rb
Instance Method Summary collapse
-
#stats ⇒ Mhz, MB
Aggregate cluster information.
Instance Method Details
#stats ⇒ Mhz, MB
Note:
Values are returned in a hash.
Aggregate cluster information.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rbvmomi/vim/ComputeResource.rb', line 10 def stats filterSpec = RbVmomi::VIM.PropertyFilterSpec( :objectSet => [{ :obj => self, :selectSet => [ RbVmomi::VIM.TraversalSpec( :name => 'tsHosts', :type => 'ComputeResource', :path => 'host', :skip => false ) ] }], :propSet => [{ :pathSet => %w(name overallStatus summary.hardware.cpuMhz summary.hardware.numCpuCores summary.hardware.memorySize summary.quickStats.overallCpuUsage summary.quickStats.overallMemoryUsage), :type => 'HostSystem' }] ) result = @soap.propertyCollector.RetrieveProperties(:specSet => [filterSpec]) stats = { :totalCPU => 0, :totalMem => 0, :usedCPU => 0, :usedMem => 0, } result.each do |x| next if x['overallStatus'] == 'red' stats[:totalCPU] += x['summary.hardware.cpuMhz'] * x['summary.hardware.numCpuCores'] stats[:totalMem] += x['summary.hardware.memorySize'] / (1024*1024) stats[:usedCPU] += x['summary.quickStats.overallCpuUsage'] || 0 stats[:usedMem] += x['summary.quickStats.overallMemoryUsage'] || 0 end stats end |