Class: GRI::HRSWRunPerfPollingUnit

Inherits:
PollingUnit show all
Defined in:
lib/gri/polling_unit.rb

Constant Summary

Constants inherited from PollingUnit

PollingUnit::UNITS

Instance Attribute Summary

Attributes inherited from PollingUnit

#cat, #dhash, #name, #oids, #ophash, #options

Instance Method Summary collapse

Methods inherited from PollingUnit

all_units, #feed, #initialize, #inspect, #set_oids

Constructor Details

This class inherits a constructor from GRI::PollingUnit

Instance Method Details

#fix_workhash(workhash) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/gri/polling_unit.rb', line 104

def fix_workhash workhash
  re = (pat = options['hrSWRunPerf']) ? Regexp.new(pat) : nil
  wh2 = {}
  if (wh = workhash[:hrSWRunPerf])
    del_keys = []
    for k, v in wh
      sw = "#{v['hrSWRunPath']} #{v['hrSWRunParameters']}"
      if re =~ sw
        matched = $&
        idx = matched.gsub(/[\s\/]/, '_').gsub(/[^\w]/, '') #/
        h = (wh2[idx] ||= {})
        h['hrSWRunPerfMatched'] = matched
        h['hrSWRunPerfMem'] ||= 0
        h['hrSWRunPerfMem'] += v['hrSWRunPerfMem'].to_i * 1024
        h['hrSWRunPerfCPU'] ||= 0
        h['hrSWRunPerfCPU'] += v['hrSWRunPerfCPU'].to_i
      end
    end
    workhash[:hrSWRunPerf] = wh2
  end
  super
end