Class: Opstat::Parsers::HpPdu
- Inherits:
-
Object
- Object
- Opstat::Parsers::HpPdu
show all
- Includes:
- Logging
- Defined in:
- lib/parsers/hp_pdu.rb
Instance Method Summary
collapse
Methods included from Logging
#log_level, #oplogger, #preconfig_logger
Instance Method Details
#parse_data(data:, time:) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/parsers/hp_pdu.rb', line 11
def parse_data(data:, time:)
return if data.nil? temp = {}
begin
ids = data.split("\n")
ids.each do |id|
k, v = id.split(' = ')
if self.snmp_ids.has_key?(k)
props = snmp_ids[k]
temp_key = "#{props[:meter_type]}#{props[:pdu]}"
temp[temp_key] ||= {:meter_type => props[:meter_type], :pdu => props[:pdu]}
temp[temp_key][props[:store_key]] = v.split(': ')[-1].to_i
end
end
rescue
return
end
reports = temp.values
return reports
end
|
#snmp_ids ⇒ Object
6
7
8
9
|
# File 'lib/parsers/hp_pdu.rb', line 6
def snmp_ids
@snmp_ids ||= YAML::load_file("#{File.dirname(File.expand_path(__FILE__))}/../data/hp_pdu.yml")
@snmp_ids
end
|