Class: Opstat::Parsers::Nagios
- Inherits:
-
Object
- Object
- Opstat::Parsers::Nagios
- Includes:
- Logging
- Defined in:
- lib/parsers/nagios.rb,
lib/plugins/nagios.rb
Instance Method Summary collapse
Methods included from Logging
#log_level, #oplogger, #preconfig_logger
Instance Method Details
#parse_data(data) ⇒ 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/nagios.rb', line 6 def parse_data(data:, time:) report = {} begin data.compact.each do |elem| v = elem.strip.split(':') next if v.length == 0 next if v.count != 2 key = v[0].strip val = v[1].strip report[key] = val end rescue #TODO add errors to gui - bad data return end report["Hosts Up"], report["Hosts Down"], report["Hosts Unreachable"] = report["Hosts Up/Down/Unreach"].split('/') report["Services Ok"], report["Services Warning"], report["Services Unknown"], report["Services Critical"] = report["Services Ok/Warn/Unk/Crit"].split('/') return [{ :services_total => report["Total Services"], :hosts_total => report["Total Hosts"], :services_checked => report["Services Checked"], :hosts_checked => report["Hosts Checked"], :services_ok => report["Services Ok"], :services_warning => report["Services Warning"], :services_critical => report["Services Critical"], :services_unknown => report["Services Unknown"], :hosts_up => report["Hosts Up"], :hosts_down => report["Hosts Down"], :hosts_unreachable => report ["Hosts Unreachable"] }] end |