Class: Opstat::Parsers::Xen
- Inherits:
-
Object
- Object
- Opstat::Parsers::Xen
- Includes:
- Logging
- Defined in:
- lib/parsers/xen.rb
Instance Method Summary collapse
Methods included from Logging
#log_level, #oplogger, #preconfig_logger
Instance Method Details
#parse_data(data:, time:) ⇒ Object
6 7 8 9 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 |
# File 'lib/parsers/xen.rb', line 6 def parse_data(data:, time:) return if data.nil? domains = [] begin data.split("\n")[1..-1].each do |line| oplogger.debug "parsing line #{line}" domain = {} stats = line.split domain['domain'] = stats[0] domain['cpu'] = stats[3].to_i domain['memory'] = stats[4].to_i domain['memory_max'] = stats[6].to_i domain['nettx'] = stats[10].to_i domain['netrx'] = stats[11].to_i domain['vbd_oo'] = stats[13].to_i domain['vbd_rd'] = stats[14].to_i domain['vbd_wr'] = stats[15].to_i domain['vbd_rsect'] = stats[16].to_i domain['vbd_wsect'] = stats[17].to_i domains << domain end rescue #TODO find best way to deal with that kind of problems #TODO check if timestamp > prev return end #TODO batch import? return domains end |