Class: MiqVimPerfHistory
- Inherits:
-
Object
- Object
- MiqVimPerfHistory
- Includes:
- VMwareWebService::Logging
- Defined in:
- lib/VMwareWebService/MiqVimPerfHistory.rb
Instance Attribute Summary collapse
-
#invObj ⇒ Object
readonly
Returns the value of attribute invObj.
Instance Method Summary collapse
- #availMetricsForEntity(mor, *aa) ⇒ Object
- #cInfoMap ⇒ Object
- #getCounterInfo(group, name, rollupType, statsType = nil) ⇒ Object
- #groupInfo ⇒ Object
- #id2Counter ⇒ Object
-
#initialize(invObj) ⇒ MiqVimPerfHistory
constructor
A new instance of MiqVimPerfHistory.
- #intervalMap ⇒ Object
-
#intervals ⇒ Object
Interval processing.
-
#perfCounterInfo ⇒ Object
Counter processing.
-
#queryPerf(entnty, ah) ⇒ Object
Query an single metric from a single entity.
- #queryPerfComposite(entnty, ah) ⇒ Object
- #queryPerfMulti(aa) ⇒ Object
- #queryProviderSummary(mor) ⇒ Object
- #release ⇒ Object
Methods included from VMwareWebService::Logging
Constructor Details
#initialize(invObj) ⇒ MiqVimPerfHistory
Returns a new instance of MiqVimPerfHistory.
9 10 11 12 13 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 9 def initialize(invObj) @invObj = invObj @sic = invObj.sic @perfManager = @sic.perfManager end |
Instance Attribute Details
#invObj ⇒ Object (readonly)
Returns the value of attribute invObj.
7 8 9 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 7 def invObj @invObj end |
Instance Method Details
#availMetricsForEntity(mor, *aa) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 107 def availMetricsForEntity(mor, *aa) if aa.length > 0 ah = aa[0] intervalId = ah[:intervalId] || nil beginTime = ah[:beginTime] || nil endTime = ah[:endTime] || nil end logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).availMetricsForEntity: calling queryAvailablePerfMetric" pmids = @invObj.queryAvailablePerfMetric(@perfManager, mor, beginTime, endTime, intervalId) logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).availMetricsForEntity: returned from queryAvailablePerfMetric" (pmids) end |
#cInfoMap ⇒ Object
73 74 75 76 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 73 def cInfoMap perfCounterInfo if @cInfoMap.nil? @cInfoMap end |
#getCounterInfo(group, name, rollupType, statsType = nil) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 88 def getCounterInfo(group, name, rollupType, statsType = nil) raise "getCounterInfo: counter group #{group}, not found" unless (nh = cInfoMap[group]) raise "getCounterInfo: counter #{group}.#{name}, not found" unless (ca = nh[name]) ca.each do |ci| next if ci['rollupType'] != rollupType next if statsType && ci['statsType'] != statsType return ci end raise "getCounterInfo: counter #{group}.#{name}, no counter matching rollupType and statsType" end |
#groupInfo ⇒ Object
83 84 85 86 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 83 def groupInfo perfCounterInfo if @groupInfo.nil? @groupInfo end |
#id2Counter ⇒ Object
78 79 80 81 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 78 def id2Counter perfCounterInfo if @id2Counter.nil? @id2Counter end |
#intervalMap ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 27 def intervalMap if @intervalMap.nil? # Hash interval information by [name] and interval ID (samplingPeriod) @intervalMap = {} intervals.each do |i| @intervalMap[i['name']] = i # i['samplingPeriod'] = i['samplingPeriod'].to_i i['length'] = i['length'].to_i @intervalMap[i['samplingPeriod']] = i @intervalMap[i['samplingPeriod'].to_i] = i end end @intervalMap end |
#intervals ⇒ Object
Interval processing
19 20 21 22 23 24 25 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 19 def intervals if @intervals.nil? @intervals = @invObj.getMoProp(@perfManager, "historicalInterval")["historicalInterval"] @intervals = @intervals["PerfInterval"] if @intervals.kind_of?(Hash) end @intervals end |
#perfCounterInfo ⇒ Object
Counter processing
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 46 def perfCounterInfo if @perfCounterInfo.nil? @perfCounterInfo = @invObj.getMoProp(@perfManager, "perfCounter")['perfCounter'] @perfCounterInfo = @perfCounterInfo['PerfCounterInfo'] if @perfCounterInfo.kind_of?(Hash) # # Hash counter information by [group][name] and [counter ID]. # Also, hash counter group info by group key. # @cInfoMap = {} # Counter info hashed by [group][name] @id2Counter = {} # Counter info hashed by [id] @groupInfo = {} # Description of counter groups, hashed by group key @perfCounterInfo.each do |pci| # pci['key'] = pci['key'].to_i @id2Counter[pci['key']] = pci ginfo = pci['groupInfo'] @groupInfo[ginfo['key']] = ginfo group = ginfo['key'] @cInfoMap[group] = {} unless @cInfoMap[group] name = pci['nameInfo']['key'] @cInfoMap[group][name] = [] unless @cInfoMap[group][name] @cInfoMap[group][name] << pci end if @perfCounterInfo end @perfCounterInfo end |
#queryPerf(entnty, ah) ⇒ Object
Query an single metric from a single entity.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 123 def queryPerf(entnty, ah) ah[:entity] = entnty pqs = getPerfQuerySpec(ah) logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerf: calling queryPerf" umPem = @invObj.queryPerf(@perfManager, pqs)[0] logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerf: returned from queryPerf" # # Construct an array of (timestamp, value) pairs. # ra = [] return(ra) if !umPem || !umPem.xsiType return(ra) unless umPem.key?('value') return(ra) if umPem['value'].kind_of?(Hash) && !umPem['value'].key?('value') return(ra) unless umPem.key?('sampleInfo') va = umPem['value'] va = va[0] if va.kind_of?(Array) va = va['value'] umPem['sampleInfo'] = [umPem['sampleInfo']] unless umPem['sampleInfo'].kind_of?(Array) umPem['sampleInfo'].each_index do |i| si = umPem['sampleInfo'][i] ra << DateTime.parse(si['timestamp']) ra << va[i].to_i end (ra) end |
#queryPerfComposite(entnty, ah) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 167 def queryPerfComposite(entnty, ah) ah[:entity] = entnty pqs = getPerfQuerySpec(ah) logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfComposite: calling queryPerfComposite" umPem = @invObj.queryPerfComposite(@perfManager, pqs) logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfComposite: returned from queryPerfComposite" umPem['childEntity'] = [umPem['childEntity']] if umPem['childEntity'].kind_of? Hash (umPem) end |
#queryPerfMulti(aa) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 152 def queryPerfMulti(aa) querySpec = VimArray.new('ArrayOfPerfQuerySpec') do |pqsa| aa.each { |ah| pqsa << getPerfQuerySpec(ah) } end logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfMulti: calling queryPerf" pema = @invObj.queryPerf(@perfManager, querySpec) logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfMulti: returned from queryPerf" return(nil) unless pema pema = [pema] unless pema.kind_of? Array pema end |
#queryProviderSummary(mor) ⇒ Object
100 101 102 103 104 105 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 100 def queryProviderSummary(mor) logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryProviderSummary: calling queryPerfProviderSummary" psum = @invObj.queryPerfProviderSummary(@perfManager, mor) logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryProviderSummary: returned from queryPerfProviderSummary" (psum) end |
#release ⇒ Object
180 181 182 |
# File 'lib/VMwareWebService/MiqVimPerfHistory.rb', line 180 def release # @invObj.releaseObj(self) end |