Class: Opstat::Parsers::FreeswitchFifos
- Inherits:
-
Object
- Object
- Opstat::Parsers::FreeswitchFifos
- Includes:
- Logging
- Defined in:
- lib/parsers/freeswitch_fifos.rb
Instance Method Summary collapse
Methods included from Logging
#log_level, #oplogger, #preconfig_logger
Instance Method Details
#parse_data(data:, time:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/parsers/freeswitch_fifos.rb', line 16 def parse_data(data:, time:) reports = [] XmlHasher.parse(data)[:fifo_report][:fifo].each do |fifo| next if SKIP_FIFO_NAMES.include?(fifo[:name]) report = {} report[:OPSTAT_TAG_fifo_name] = fifo[:name] report[:waiting_calls] = fifo[:waiting_count].to_i report[:outbound_per_cycle] = fifo[:outbound_per_cycle].to_i if fifo[:outbound].nil? report[:operators] = 0 else if fifo[:outbound][:member].is_a?(String) report[:operators] = 1 else report[:operators] = fifo[:outbound][:member].count end end if fifo[:bridges].nil? report[:active_calls] = 0 else if fifo[:bridges].is_a?(Hash) report[:active_calls] = 1 else report[:active_calls] = fifo[:bridges][:bridge].count end end if fifo[:callers].nil? report[:queue_max_waiting_time] = 0 else if fifo[:callers][:caller].is_a?(Hash) = fifo[:callers][:caller][:timestamp] ||= time.to_s #due to some strange behaviour - there are data call without position and other needed params else = fifo[:callers][:caller].find{|call| call[:position].to_i == 1}[:timestamp] end report[:queue_max_waiting_time] = (time - Time.parse()).to_i end reports << report end return reports end |