riemann-babbler 1.0.7.2 → 1.0.7.3

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.
@@ -1,5 +1,5 @@
1
1
  module Riemann
2
2
  class Babbler
3
- VERSION = '1.0.7.2'
3
+ VERSION = '1.0.7.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-babbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7.2
4
+ version: 1.0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -157,31 +157,21 @@ files:
157
157
  - bin/riemann-babbler
158
158
  - config.yml
159
159
  - lib/riemann/babbler/plugin.rb
160
- - lib/riemann/babbler/plugins/cloudclients.rb
161
- - lib/riemann/babbler/plugins/cloudrestreamerstatus.rb
162
160
  - lib/riemann/babbler/plugins/cpu.rb
163
161
  - lib/riemann/babbler/plugins/cpufan.rb
164
162
  - lib/riemann/babbler/plugins/cputemp.rb
165
- - lib/riemann/babbler/plugins/cuboxtemp.rb
166
163
  - lib/riemann/babbler/plugins/disk.rb
167
164
  - lib/riemann/babbler/plugins/dummy.rb
168
165
  - lib/riemann/babbler/plugins/exim4.rb
169
166
  - lib/riemann/babbler/plugins/http.rb
170
- - lib/riemann/babbler/plugins/je.rb
171
167
  - lib/riemann/babbler/plugins/la.rb
172
168
  - lib/riemann/babbler/plugins/mdadm.rb
173
169
  - lib/riemann/babbler/plugins/megacli.rb
174
170
  - lib/riemann/babbler/plugins/memory.rb
175
- - lib/riemann/babbler/plugins/mpeg2lander.rb
176
171
  - lib/riemann/babbler/plugins/net.rb
177
172
  - lib/riemann/babbler/plugins/netstat.rb
178
173
  - lib/riemann/babbler/plugins/nginx.rb
179
- - lib/riemann/babbler/plugins/nvidia.rb
180
- - lib/riemann/babbler/plugins/panels.rb
181
174
  - lib/riemann/babbler/plugins/runit.rb
182
- - lib/riemann/babbler/plugins/sdigrabber.rb
183
- - lib/riemann/babbler/plugins/selfupdate.rb
184
- - lib/riemann/babbler/plugins/uplay.rb
185
175
  - lib/riemann/babbler/support/deep_merge.rb
186
176
  - lib/riemann/babbler/support/monkey_patches.rb
187
177
  - lib/riemann/babbler/support/plugin_helpers.rb
@@ -1,18 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Cloudclients < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'cloud clients')
7
- plugin.set_default(:interval, 60)
8
- plugin.set_default(:url, 'http://localhost/client/all')
9
- end
10
-
11
- def collect
12
- clients = 0
13
- json = JSON.parse rest_get(plugin.url)
14
- json.each { |client| clients += 1 if client[1]["state"] == "ESTABLISHED" }
15
- {:service => plugin.service + " established", :description => "online clients in #{plugin.url}", :metric => clients, :state => 'ok' }
16
- end
17
-
18
- end
@@ -1,24 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Cloudrestreamerstatus < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'cloud restreamer clients')
7
- plugin.set_default(:interval, 60)
8
- plugin.set_default(:url, 'http://localhost/client/all')
9
- end
10
-
11
- def collect
12
- clients = 0
13
- json = JSON.parse rest_get(plugin.url)
14
- json.each do |worker|
15
- next unless worker.has_key? "processors"
16
- worker["processors"].each do |key, client_hash|
17
- next unless client_hash.has_key? "clients"
18
- client_hash["clients"].each {|key| clients += 1}
19
- end
20
- end
21
- {:service => plugin.service, :description => "Cloud restreamer clients in #{plugin.url}", :metric => clients, :state => 'ok' }
22
- end
23
-
24
- end
@@ -1,20 +0,0 @@
1
- class Riemann::Babbler::Cuboxtemp < Riemann::Babbler
2
-
3
- def init
4
- plugin.set_default(:service, 'cuboxtemp')
5
- plugin.set_default(:interval, 60)
6
- plugin.set_default(:cmd, "sensors | grep 'T-junction' | awk '{print $2}'")
7
- plugin.states.set_default(:warning, 90)
8
- plugin.states.set_default(:critical, 100)
9
- end
10
-
11
- def run_plugin
12
- File.exists? '/usr/bin/sensors'
13
- end
14
-
15
- def collect
16
- { :service => plugin.service, :metric => shell(plugin.cmd).to_i, :description => "Cubox temperature" }
17
- end
18
-
19
- end
20
-
@@ -1,22 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Je < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'je')
7
- plugin.set_default(:interval, 60)
8
- plugin.set_default(:url, 'http://localhost/status')
9
- plugin.states.set_default(:critical, 10)
10
- end
11
-
12
- def collect
13
- array = Array.new
14
- JSON.parse( rest_get( plugin.url ) ).each do |channel|
15
- timing = (unixnow - channel['moment'].to_i).abs
16
- sid = channel['sid']
17
- array << { :service => plugin.service + " status #{sid}", :metric => timing.to_i, :description => "Je timming sid #{sid}, in sec." }
18
- end
19
- array
20
- end
21
-
22
- end
@@ -1,25 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Mpeg2lander < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'mpeg2lander')
7
- plugin.set_default(:interval, 60)
8
- plugin.set_default(:url, 'http://localhost/status')
9
- plugin.states.set_default(:critical, 10)
10
- end
11
-
12
- def collect
13
- array = Array.new
14
- JSON.parse( rest_get( plugin.url ) )['streams'].each do |stream|
15
- stream['programs'].each do |programm|
16
- next unless programm['time_tracker']
17
- next unless programm['time_tracker']['current_time']
18
- timing = (programm['time_tracker']['current_time'].split('diff')[1].to_i).abs
19
- array << { :service => plugin.service + " status #{programm['name']}", :metric => timing.to_i, :description => "Mpeg2lander timming name #{programm['name']}" }
20
- end # end programm
21
- end # end stream
22
- array
23
- end
24
-
25
- end
@@ -1,27 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Nvidia < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'nvidia')
7
- plugin.set_default(:cmd, '/usr/bin/nvidia-info -j')
8
- plugin.set_default(:interval, 60)
9
- plugin.states.set_default(:warning, 70)
10
- plugin.states.set_default(:critical, 90)
11
- end
12
-
13
- def run_plugin
14
- File.exists? '/usr/bin/nvidia-info'
15
- end
16
-
17
-
18
- def collect
19
- hash = JSON.parse shell(plugin.cmd)
20
- array = Array.new
21
- hash.each do |info|
22
- array << { :service => plugin.service + ' memory usage', :metric => (1 - info['memory_usage']['free'].to_f/info['memory_usage']['total'].to_i) * 100, :description => "GPU memory usage in %" }
23
- end
24
- array
25
- end
26
-
27
- end
@@ -1,27 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Panels < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'panels')
7
- plugin.set_default(:interval, 60)
8
- plugin.set_default(:url, 'http://localhost/panel.json')
9
- plugin.states.set_default(:critical, 60)
10
- end
11
-
12
- def collect
13
-
14
- json = JSON.parse rest_get(plugin.url)
15
- good, bad = 0, 0
16
-
17
- json["panels"].each do |panel|
18
- panel["status"] == "offline" ? bad += 1 : good += 1
19
- end
20
-
21
- [
22
- {:service => plugin.service + " online", :description => "online panels in #{plugin.url}", :metric => good, :state => 'ok' },
23
- {:service => plugin.service + " all", :description => "all panels in #{plugin.url}", :metric => bad + good, :state => 'ok' }
24
- ]
25
- end
26
-
27
- end
@@ -1,26 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Sdigrabber < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'sdigrabber')
7
- plugin.set_default(:interval, 60)
8
- plugin.set_default(:url, 'http://localhost/status')
9
- plugin.states.set_default(:critical, 10)
10
- end
11
-
12
- def collect
13
- array = Array.new
14
- JSON.parse( rest_get( plugin.url ) ).each do |box|
15
- box['processors'].each do |processor, processor_options|
16
- next unless processor =~ /Proc\s+encoder/
17
- next unless processor_options['setup']['last-unit-pts']
18
- timing = (unixnow - processor_options['setup']['last-unit-pts'].to_i).abs
19
- cid = processor_options['setup']['cid']
20
- array << { :service => plugin.service + " status #{cid}", :metric => timing.to_i, :description => "Sdigrabber timming cid #{cid}" }
21
- end
22
- end
23
- array
24
- end
25
-
26
- end
@@ -1,19 +0,0 @@
1
- require 'json'
2
-
3
- class Riemann::Babbler::Selfupdate < Riemann::Babbler
4
-
5
- def init
6
- plugin.set_default(:service, 'self update')
7
- plugin.set_default(:file, '/var/run/status')
8
- end
9
-
10
- def collect
11
- json = JSON.parse File.read(plugin.file)
12
- if json["status"] == "ok"
13
- {:service => plugin.service, :description => "Self update status in #{plugin.file}, state: OK", :metric => 1, :state => 'ok' }
14
- else
15
- {:service => plugin.service, :description => "Self update status in #{plugin.file}, state: #{state['status']}, code: #{state['code']}", :metric => 0, :state => 'critical' }
16
- end
17
- end
18
-
19
- end
@@ -1,122 +0,0 @@
1
- require 'json'
2
- require 'socket'
3
-
4
- class Riemann::Babbler::Uplay < Riemann::Babbler
5
-
6
- def myip
7
- ip = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}
8
- myip = ip.ip_address if ip
9
- myip || '127.0.0.1'
10
- end
11
-
12
- def panel_id
13
- mac = File.read('/proc/sys/kernel/hostname').strip.downcase.split('-')[1]
14
- JSON.parse( rest_get(plugin.base_url + "/#{mac}.json") )['panel']['id']
15
- end
16
-
17
- def init
18
- plugin.set_default(:service, 'uplay')
19
- plugin.set_default(:file, '/var/run/status.json')
20
- plugin.set_default(:base_url, 'http://localhost/api/cubox/v1/panels' )
21
- plugin.statuses.set_default(:status_update_ts, 100)
22
- plugin.statuses.set_default(:application_uptime, 100)
23
- plugin.statuses.set_default(:video_unit_rate, 25)
24
- plugin.statuses.set_default(:player_state, 'Stream SPIF2')
25
- plugin.set_default(:interval, 60)
26
- @panel_id = panel_id
27
- end
28
-
29
- def run_plugin
30
- File.exists? plugin.file
31
- end
32
-
33
-
34
- def collect
35
- now = unixnow
36
- array = Array.new
37
- status = JSON.parse File.read(plugin.file)
38
-
39
- ip = myip
40
- info = ", ip: #{myip}, id: #{@panel_id}"
41
-
42
- # "status_update_ts" - время последнего обновления содержимого статусного файла в unix-timestamp
43
- if now - status['status_update_ts'] > plugin.statuses.status_update_ts
44
- array << { :service => plugin.service + ' status_update_ts', :description => 'update status very old' + info, :metric => now - status['status_update_ts'], :state => 'critical' }
45
- else
46
- array << { :service => plugin.service + ' status_update_ts', :description => 'update status time ok' + info, :metric => now - status['status_update_ts'], :state => 'ok' }
47
- end
48
-
49
- # "application_uptime" - время работы приложения, в секундах
50
- if now - status['application_uptime'] < plugin.statuses.application_uptime
51
- array << { :service => plugin.service + ' application_uptime', :description => "application uptime: (#{status['application_uptime']}) is very small" + info, :metric => now - status['application_uptime'], :state => 'critical' }
52
- else
53
- array << { :service => plugin.service + ' application_uptime', :description => 'application uptime ok' + info, :metric => now - status['application_uptime'], :state => 'ok' }
54
- end
55
-
56
- # "enough_decoded_frames" - достаточно ли фреймов успевает проходить через декодер (когда true, декодер не справляется), true/false
57
- unless status['enough_decoded_frames']
58
- array << { :service => plugin.service + ' enough_decoded_frames', :description => 'status enough_decoded_frames ok' + info, :metric => 0, :state => 'ok' }
59
- else
60
- array << { :service => plugin.service + ' enough_decoded_frames', :description => 'Uplay not cope with the load' + info, :metric => 1, :state => 'critical' }
61
- end
62
-
63
- # "enough_net_frames" - достаточно ли фреймов приходит по сети, true/false
64
- if status['enough_net_frames']
65
- array << { :service => plugin.service + ' enough_net_frames', :description => 'status enough_net_frames ok' + info, :metric => 0, :state => 'ok' }
66
- else
67
- array << { :service => plugin.service + ' enough_net_frames', :description => 'Not enough net frames to play' + info, :metric => 1, :state => 'critical' }
68
- end
69
-
70
- # "bytes_received" - общее количество принятых байтов от сервера, число, в байтах
71
- if status['bytes_received'] - @old_bytes_received > 0
72
- array << { :service => plugin.service + ' bytes_received', :description => 'status bytes_received ok' + info, :metric => status['bytes_received'], :state => 'ok' }
73
- else
74
- array << { :service => plugin.service + ' bytes_received', :description => "Uplay can't report about new bytes in bytes_received" + info, :metric => status['bytes_received'], :state => 'critical' }
75
- end if @old_bytes_received
76
- @old_bytes_received = status['bytes_received']
77
-
78
- # "bytes_sent" - общее количество отправленных байтов в управляющий канал, число, в байтах
79
- if status['bytes_sent'] - @old_bytes_sent > 0
80
- array << { :service => plugin.service + ' bytes_sent', :description => 'status bytes_sent ok' + info, :metric => status['bytes_sent'], :state => 'ok' }
81
- else
82
- array << { :service => plugin.service + ' bytes_sent', :description => "Uplay can't report about new bytes in bytes_sent" + info, :metric => status['bytes_sent'], :state => 'critical' }
83
- end if @old_bytes_sent
84
- @old_bytes_sent = status['bytes_sent']
85
-
86
- # "have_audio" - заявлено ли аудио в этом потоке
87
- if status['have_audio']
88
- array << { :service => plugin.service + ' have_audio', :description => 'status have_audio ok' + info, :metric => 0, :state => 'ok' }
89
- else
90
- array << { :service => plugin.service + ' have_audio', :description => 'Video dont have aduio' + info, :metric => 1, :state => 'critical' }
91
- end
92
-
93
- # "stream_bit_rate" - общий битрейт потока за последнюю секунду, кбит/сек.
94
- array << { :service => plugin.service + ' stream_bit_rate', :description => 'stream bitrate' + info, :metric => status['stream_bit_rate'], :state => 'ok' }
95
-
96
- # "have_audio" - заявлено ли аудио в этом потоке
97
- if status['have_audio']
98
- array << { :service => plugin.service + ' have_audio', :description => 'status have_audio ok' + info, :metric => 0, :state => 'ok' }
99
- else
100
- array << { :service => plugin.service + ' have_audio', :description => 'Video dont have audio' + info, :metric => 1, :state => 'critical' }
101
- end
102
-
103
- # "video_unit_rate" - количество выведенных (показанных) видеофреймов за последнюю секунду
104
- if status['video_unit_rate'] - plugin.statuses.video_unit_rate >= 0
105
- array << { :service => plugin.service + ' video_unit_rate', :description => 'status video_unit_rate ok' + info, :metric => status['video_unit_rate'], :state => 'ok' }
106
- else
107
- array << { :service => plugin.service + ' video_unit_rate', :description => "Video rate is low (<#{plugin.statuses.video_unit_rate})" + info, :metric => status['video_unit_rate'], :state => 'critical' }
108
- end
109
-
110
- # "player_state" - состояние проигрывания ("Stream SPIF2" - играет поток SPIF2,
111
- # "Dummy" - играет заставка, "Dummy (no video)"
112
- # - должна играть заставка, но файл не обнаружен или не указан)
113
- if status['player_state'].to_s.include? plugin.statuses.player_state
114
- array << { :service => plugin.service + ' player_state', :description => "current player state: #{status['player_state']}" + info, :metric => 0, :state => 'ok' }
115
- else
116
- array << { :service => plugin.service + ' player_state', :description => "current player state: #{status['player_state']}" + info, :metric => 1, :state => 'critical' }
117
- end
118
-
119
- array
120
- end
121
-
122
- end