bipbip 0.6.11 → 0.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f26a60a16cdc9ad68e040be4fd444673ea47b3e5
4
- data.tar.gz: 674118be400d22430be96ebe0d03c41750b1db86
3
+ metadata.gz: 66c6f0dfc0b0a12acb0c6d112f633d1f9db8985e
4
+ data.tar.gz: 6a214d21ed9b4dbcb6c9b6fe0be55ab0cf96752c
5
5
  SHA512:
6
- metadata.gz: 69abfe7129067627d5c57a7e3656bc02c132c54502e6627412cbcc3b5f7cca9d8b1bb8420357f895857b8ded782677463007ab4b360065c7fd87c49ab9a2d5c4
7
- data.tar.gz: cfd7547f96c93aa3f3df78c461c18fac6941d2c04a4d85b074f9977e6cb9871bb76b1ea3122390a8a9d70fb8cacc295fe5d4710eaf5cf475915a087583baf2e3
6
+ metadata.gz: 7c8b723a7fd0386bcdacbe0c2760295ec875dbdc97c44329ff3d464979082df4257c4f3748194499ebeb0d08e300140d6c55b14d712dbcf0f9645f1099e062fc
7
+ data.tar.gz: 60b12b6455d6349c76c37afe6a19d0184b3515b9a76326dbafa8244e68e775dd5e7b655c185f163f938745f95ce4241076d40ae5b72065a46da382c85dbe101f
@@ -26,9 +26,9 @@ module Bipbip
26
26
  command_output.map do |metric, value|
27
27
  case detect_operation_mode(value)
28
28
  when :simple
29
- { name: "#{metric}", type: 'gauge' }
29
+ { name: metric.to_s, type: 'gauge' }
30
30
  when :advanced
31
- { name: "#{metric}", type: value['type'], unit: value['unit'] }
31
+ { name: metric.to_s, type: value['type'], unit: value['unit'] }
32
32
  end
33
33
  end
34
34
  end
@@ -0,0 +1,87 @@
1
+ require 'janus_gateway'
2
+ require 'eventmachine'
3
+
4
+ module Bipbip
5
+ class Plugin::JanusAudioroom < Plugin
6
+ def metrics_schema
7
+ [
8
+ { name: 'room_count', type: 'gauge', unit: 'Rooms' },
9
+ { name: 'participant_count', type: 'gauge', unit: 'Participants' },
10
+ { name: 'room_zero_participant_count', type: 'gauge', unit: 'Rooms' }
11
+ ]
12
+ end
13
+
14
+ def monitor
15
+ data = _fetch_data
16
+ audiorooms = data['data']['list']
17
+ {
18
+ 'room_count' => audiorooms.count,
19
+ 'participant_count' => audiorooms.map { |room| room['num_participants'] }.reduce(:+),
20
+ 'room_zero_participant_count' => audiorooms.count { |room| room['num_participants'] == 0 }
21
+ }
22
+ end
23
+
24
+ private
25
+
26
+ def _fetch_data
27
+ promise = Concurrent::Promise.new
28
+
29
+ EM.run do
30
+ EM.error_handler do |error|
31
+ promise.fail(error).execute
32
+ end
33
+
34
+ client = _create_client(config['url'] || 'http://127.0.0.1:8088/janus')
35
+
36
+ _create_session(client).then do |session|
37
+ _create_plugin(client, session).then do |plugin|
38
+ plugin.list.then do |list|
39
+ data = list['plugindata']
40
+
41
+ session.destroy.value
42
+ promise.set(data).execute
43
+ end.rescue do |error|
44
+ promise.fail("Failed to get list of audioroom: #{error}").execute
45
+ end
46
+ end.rescue do |error|
47
+ promise.fail("Failed to create audioroom plugin: #{error}").execute
48
+ end
49
+ end.rescue do |error|
50
+ promise.fail("Failed to create session: #{error}").execute
51
+ end
52
+
53
+ promise.then { EM.stop }
54
+ promise.rescue { EM.stop }
55
+ end
56
+
57
+ promise.rescue do |error|
58
+ fail(error)
59
+ end
60
+
61
+ promise.value
62
+ end
63
+
64
+ # @param [String] http_url
65
+ # @return [JanusGateway::Client]
66
+ def _create_client(http_url)
67
+ transport = JanusGateway::Transport::Http.new(http_url)
68
+ client = JanusGateway::Client.new(transport)
69
+ client
70
+ end
71
+
72
+ # @param [JanusGateway::Client] client
73
+ # @return [Concurrent::Promise]
74
+ def _create_session(client)
75
+ session = JanusGateway::Resource::Session.new(client)
76
+ session.create
77
+ end
78
+
79
+ # @param [JanusGateway::Client] client
80
+ # @param [JanusGateway::Resource::Session] session
81
+ # @return [Concurrent::Promise]
82
+ def _create_plugin(client, session)
83
+ plugin = JanusGateway::Plugin::Audioroom.new(client, session)
84
+ plugin.create
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,96 @@
1
+ require 'janus_gateway'
2
+
3
+ module Bipbip
4
+ class Plugin::JanusRtpbroadcast < Plugin
5
+ def metrics_schema
6
+ [
7
+ { name: 'mountpoint_count', type: 'gauge', unit: 'Mountpoints' },
8
+ { name: 'stream_count', type: 'gauge', unit: 'Streams' },
9
+ { name: 'streams_listener_count', type: 'gauge', unit: 'Listeners' },
10
+ { name: 'streams_waiter_count', type: 'gauge', unit: 'Waiters' },
11
+ { name: 'streams_bandwidth', type: 'gauge', unit: 'b/s' },
12
+ { name: 'streams_zero_fps_count', type: 'gauge', unit: 'Streams' },
13
+ { name: 'streams_zero_bitrate_count', type: 'gauge', unit: 'Streams' }
14
+ ]
15
+ end
16
+
17
+ def monitor
18
+ data = _fetch_data
19
+ mountpoints = data['data']['list']
20
+ streams = mountpoints.map { |mp| mp['streams'] }.flatten
21
+ {
22
+ 'mountpoint_count' => mountpoints.count,
23
+ 'stream_count' => streams.count,
24
+ 'streams_listener_count' => streams.map { |s| s['listeners'] || 0 }.reduce(:+),
25
+ 'streams_waiter_count' => streams.map { |s| s['waiters'] || 0 }.reduce(:+),
26
+ 'streams_bandwidth' => streams.map { |s| s['stats']['cur'] }.reduce(:+),
27
+ 'streams_zero_fps_count' => streams.count { |s| s['frame']['fps'] == 0 },
28
+ 'streams_zero_bitrate_count' => streams.count { |s| s['stats']['cur'] == 0 }
29
+ }
30
+ end
31
+
32
+ private
33
+
34
+ def _fetch_data
35
+ promise = Concurrent::Promise.new
36
+
37
+ EM.run do
38
+ EM.error_handler do |error|
39
+ promise.fail(error).execute
40
+ end
41
+
42
+ client = _create_client(config['url'] || 'http://127.0.0.1:8088/janus')
43
+
44
+ _create_session(client).then do |session|
45
+ _create_plugin(client, session).then do |plugin|
46
+ plugin.list.then do |list|
47
+ data = list['plugindata']
48
+
49
+ session.destroy.value
50
+ promise.set(data).execute
51
+ end.rescue do |error|
52
+ promise.fail("Failed to get list of mountpoints: #{error}").execute
53
+ end
54
+ end.rescue do |error|
55
+ promise.fail("Failed to create rtpbroadcast plugin: #{error}").execute
56
+ end
57
+ end.rescue do |error|
58
+ promise.fail("Failed to create session: #{error}").execute
59
+ end
60
+
61
+ promise.then { EM.stop }
62
+ promise.rescue { EM.stop }
63
+ end
64
+
65
+ promise.rescue do |error|
66
+ fail(error)
67
+ end
68
+
69
+ promise.value
70
+ end
71
+
72
+ # @param [String] http_url
73
+ # @param [String] session_data
74
+ # @return [JanusGateway::Client]
75
+ def _create_client(http_url)
76
+ transport = JanusGateway::Transport::Http.new(http_url)
77
+ client = JanusGateway::Client.new(transport)
78
+ client
79
+ end
80
+
81
+ # @param [JanusGateway::Client] client
82
+ # @return [Concurrent::Promise]
83
+ def _create_session(client)
84
+ session = JanusGateway::Resource::Session.new(client)
85
+ session.create
86
+ end
87
+
88
+ # @param [JanusGateway::Client] client
89
+ # @param [JanusGateway::Resource::Session] session
90
+ # @return [Concurrent::Promise]
91
+ def _create_plugin(client, session)
92
+ plugin = JanusGateway::Plugin::Rtpbroadcast.new(client, session)
93
+ plugin.create
94
+ end
95
+ end
96
+ end
@@ -66,11 +66,11 @@ module Bipbip
66
66
  metrics_schema.each do |metric|
67
67
  name = metric[:name]
68
68
  unit = metric[:unit]
69
- if 'Boolean' == unit
70
- data[name] = ('ON' === stats[name] || 'Yes' === stats[name]) ? 1 : 0
71
- else
72
- data[name] = stats[name].to_i
73
- end
69
+ data[name] = if 'Boolean' == unit
70
+ (('ON' === stats[name] || 'Yes' === stats[name]) ? 1 : 0)
71
+ else
72
+ stats[name].to_i
73
+ end
74
74
  end
75
75
  data
76
76
  end
@@ -33,12 +33,9 @@ module Bipbip
33
33
  data = {}
34
34
 
35
35
  metrics_names.each do |key|
36
- if !roundings[key].nil?
37
- data[key] = stats[key].to_f.round(roundings[key])
38
- else
39
- data[key] = stats[key].to_i
40
- end
36
+ data[key] = roundings[key].nil? ? stats[key].to_i : stats[key].to_f.round(roundings[key])
41
37
  end
38
+
42
39
  data
43
40
  end
44
41
  end
@@ -24,7 +24,7 @@ module Bipbip
24
24
  private
25
25
 
26
26
  def log(severity, message)
27
- Bipbip.logger.add(severity, message, "#{name}")
27
+ Bipbip.logger.add(severity, message, name.to_s)
28
28
  end
29
29
  end
30
30
  end
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.6.11'
2
+ VERSION = '0.6.12'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bipbip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
4
+ version: 0.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-06 00:00:00.000000000 Z
13
+ date: 2016-01-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: copperegg-revealmetrics
@@ -166,6 +166,34 @@ dependencies:
166
166
  - - "~>"
167
167
  - !ruby/object:Gem::Version
168
168
  version: 1.0.6
169
+ - !ruby/object:Gem::Dependency
170
+ name: janus_gateway
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - "~>"
174
+ - !ruby/object:Gem::Version
175
+ version: 0.0.10
176
+ type: :runtime
177
+ prerelease: false
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - "~>"
181
+ - !ruby/object:Gem::Version
182
+ version: 0.0.10
183
+ - !ruby/object:Gem::Dependency
184
+ name: eventmachine
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: 1.0.8
190
+ type: :runtime
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - "~>"
195
+ - !ruby/object:Gem::Version
196
+ version: 1.0.8
169
197
  - !ruby/object:Gem::Dependency
170
198
  name: rake
171
199
  requirement: !ruby/object:Gem::Requirement
@@ -247,6 +275,8 @@ files:
247
275
  - lib/bipbip/plugin/fastcgi_php_fpm.rb
248
276
  - lib/bipbip/plugin/fastcgi_php_opcache.rb
249
277
  - lib/bipbip/plugin/gearman.rb
278
+ - lib/bipbip/plugin/janus_audioroom.rb
279
+ - lib/bipbip/plugin/janus_rtpbroadcast.rb
250
280
  - lib/bipbip/plugin/log_parser.rb
251
281
  - lib/bipbip/plugin/memcached.rb
252
282
  - lib/bipbip/plugin/mongodb.rb