Class: Bipbip::Plugin::Coturn
- Inherits:
-
Bipbip::Plugin
- Object
- Bipbip::Plugin
- Bipbip::Plugin::Coturn
- Defined in:
- lib/bipbip/plugin/coturn.rb
Instance Attribute Summary
Attributes inherited from Bipbip::Plugin
#config, #frequency, #metric_group, #name, #tags
Instance Method Summary collapse
Methods inherited from Bipbip::Plugin
factory, factory_from_plugin, #initialize, #metrics_names, #run, #source_identifier
Methods included from InterruptibleSleep
#interrupt_sleep, #interruptible_sleep
Constructor Details
This class inherits a constructor from Bipbip::Plugin
Instance Method Details
#metrics_schema ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/bipbip/plugin/coturn.rb', line 5 def metrics_schema [ { name: 'total_sessions_count', type: 'gauge', unit: 'Sessions' }, { name: 'total_bitrate_outgoing', type: 'gauge', unit: 'b/s' }, { name: 'total_bitrate_incoming', type: 'gauge', unit: 'b/s' } ] end |
#monitor ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bipbip/plugin/coturn.rb', line 13 def monitor data = _fetch_session_data begin metrics_data = { 'total_sessions_count' => data.match(/Total sessions: (.*)/)[1].to_i, 'total_bitrate_outgoing' => (data.scan(/ s=(\d+),/).flatten.map(&:to_i).reduce(:+) || 0) * 8, 'total_bitrate_incoming' => (data.scan(/ r=(\d+),/).flatten.map(&:to_i).reduce(:+) || 0) * 8 } rescue => e raise("Cannot prepare metrics for malformed response: `#{data}`. Error: `#{e.}`") end metrics_data end |