riemann-babbler 1.0.5.6 → 1.0.5.7
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.
- data/lib/riemann/babbler/plugins/uplay.rb +68 -20
- data/lib/riemann/version.rb +1 -1
- metadata +2 -2
@@ -1,11 +1,3 @@
|
|
1
|
-
# играет заставку или нормальное видео
|
2
|
-
# давно ли играет видео
|
3
|
-
# аптайм приложение
|
4
|
-
|
5
|
-
# "player_state":"Dummy", но при этом с rendg есть соединение
|
6
|
-
# "player_state":"Stream SPIF2" -
|
7
|
-
|
8
|
-
|
9
1
|
require 'json'
|
10
2
|
require 'socket'
|
11
3
|
|
@@ -17,12 +9,21 @@ class Riemann::Babbler::Uplay < Riemann::Babbler
|
|
17
9
|
myip || '127.0.0.1'
|
18
10
|
end
|
19
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
|
+
|
20
17
|
def init
|
21
18
|
plugin.set_default(:service, 'uplay')
|
22
19
|
plugin.set_default(:file, '/var/run/status.json')
|
20
|
+
plugin.set_default(:base_url, 'http://localhost/api/cubox/v1/panels' )
|
23
21
|
plugin.statuses.set_default(:status_update_ts, 100)
|
24
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
25
|
plugin.set_default(:interval, 60)
|
26
|
+
@panel_id = panel_id
|
26
27
|
end
|
27
28
|
|
28
29
|
def run_plugin
|
@@ -35,40 +36,87 @@ class Riemann::Babbler::Uplay < Riemann::Babbler
|
|
35
36
|
array = Array.new
|
36
37
|
status = JSON.parse File.read(plugin.file)
|
37
38
|
|
38
|
-
|
39
|
-
|
39
|
+
ip = myip
|
40
|
+
info = ", ip: #{myip}, id: #{@panel_id}"
|
40
41
|
|
41
42
|
# "status_update_ts" - время последнего обновления содержимого статусного файла в unix-timestamp
|
42
43
|
if now - status['status_update_ts'] > plugin.statuses.status_update_ts
|
43
|
-
array << { :service => plugin.service + ' status_update_ts', :description => 'update status very old', :metric => now - status['status_update_ts'], :state => 'critical' }
|
44
|
+
array << { :service => plugin.service + ' status_update_ts', :description => 'update status very old' + info, :metric => now - status['status_update_ts'], :state => 'critical' }
|
44
45
|
else
|
45
|
-
array << { :service => plugin.service + ' status_update_ts', :description => 'update status time ok', :metric => now - status['status_update_ts'], :state => 'ok' }
|
46
|
+
array << { :service => plugin.service + ' status_update_ts', :description => 'update status time ok' + info, :metric => now - status['status_update_ts'], :state => 'ok' }
|
46
47
|
end
|
47
48
|
|
48
49
|
# "application_uptime" - время работы приложения, в секундах
|
49
50
|
if now - status['application_uptime'] < plugin.statuses.application_uptime
|
50
|
-
array << { :service => plugin.service + ' application_uptime', :description => "application uptime: (#{status['application_uptime']}) is very small", :metric => now - status['application_uptime'], :state => 'critical' }
|
51
|
+
array << { :service => plugin.service + ' application_uptime', :description => "application uptime: (#{status['application_uptime']}) is very small" + info, :metric => now - status['application_uptime'], :state => 'critical' }
|
51
52
|
else
|
52
|
-
array << { :service => plugin.service + ' application_uptime', :description => 'application uptime ok', :metric => now - status['application_uptime'], :state => 'ok' }
|
53
|
+
array << { :service => plugin.service + ' application_uptime', :description => 'application uptime ok' + info, :metric => now - status['application_uptime'], :state => 'ok' }
|
53
54
|
end
|
54
55
|
|
55
56
|
# "enough_decoded_frames" - достаточно ли фреймов успевает проходить через декодер (когда true, декодер не справляется), true/false
|
56
57
|
unless status['enough_decoded_frames']
|
57
|
-
array << { :service => plugin.service + ' enough_decoded_frames', :description => 'status enough_decoded_frames ok', :metric => 0, :state => 'ok' }
|
58
|
+
array << { :service => plugin.service + ' enough_decoded_frames', :description => 'status enough_decoded_frames ok' + info, :metric => 0, :state => 'ok' }
|
58
59
|
else
|
59
|
-
array << { :service => plugin.service + ' enough_decoded_frames', :description => 'Uplay not cope with the load', :metric => 1, :state => 'critical' }
|
60
|
+
array << { :service => plugin.service + ' enough_decoded_frames', :description => 'Uplay not cope with the load' + info, :metric => 1, :state => 'critical' }
|
60
61
|
end
|
61
62
|
|
62
63
|
# "enough_net_frames" - достаточно ли фреймов приходит по сети, true/false
|
63
64
|
if status['enough_net_frames']
|
64
|
-
array << { :service => plugin.service + ' enough_net_frames', :description => 'status enough_net_frames ok', :metric => 0, :state => 'ok' }
|
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' }
|
65
99
|
else
|
66
|
-
array << { :service => plugin.service + '
|
100
|
+
array << { :service => plugin.service + ' have_audio', :description => 'Video dont have audio' + info, :metric => 1, :state => 'critical' }
|
67
101
|
end
|
68
102
|
|
69
|
-
|
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
|
70
118
|
|
71
119
|
array
|
72
120
|
end
|
73
121
|
|
74
|
-
end
|
122
|
+
end
|
data/lib/riemann/version.rb
CHANGED
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.5.
|
4
|
+
version: 1.0.5.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: riemann-client
|