sensu-dashboard-sonian 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sensu-dashboard/app.rb +371 -355
- data/lib/sensu-dashboard/version.rb +1 -1
- data/sensu-dashboard.gemspec +1 -1
- metadata +9 -7
data/lib/sensu-dashboard/app.rb
CHANGED
@@ -1,448 +1,464 @@
|
|
1
|
-
require '
|
2
|
-
require 'sinatra/async'
|
1
|
+
require 'sensu/config'
|
3
2
|
require 'em-http-request'
|
4
3
|
require 'em-websocket'
|
4
|
+
require 'sinatra/async'
|
5
5
|
require 'sass'
|
6
|
-
require 'json'
|
7
|
-
require 'sensu/config'
|
8
|
-
|
9
|
-
options = Sensu::Config.read_arguments(ARGV)
|
10
|
-
config = Sensu::Config.new(options)
|
11
|
-
SETTINGS = config.settings
|
12
6
|
|
13
|
-
|
7
|
+
class Dashboard < Sinatra::Base
|
8
|
+
register Sinatra::Async
|
14
9
|
|
15
|
-
|
10
|
+
def self.run(options={})
|
11
|
+
EM::run do
|
12
|
+
self.setup(options)
|
13
|
+
self.websocket_server
|
14
|
+
self.run!(:port => $settings.dashboard.port)
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
api_server = 'http://' + SETTINGS['api']['host'] + ':' + SETTINGS['api']['port'].to_s
|
23
|
-
|
24
|
-
use Rack::Auth::Basic do |user, password|
|
25
|
-
user == SETTINGS['dashboard']['user'] && password == SETTINGS['dashboard']['password']
|
16
|
+
%w[INT TERM].each do |signal|
|
17
|
+
Signal.trap(signal) do
|
18
|
+
self.stop(signal)
|
19
|
+
end
|
20
|
+
end
|
26
21
|
end
|
22
|
+
end
|
27
23
|
|
28
|
-
|
29
|
-
|
24
|
+
def self.setup(options={})
|
25
|
+
config = Sensu::Config.new(options)
|
26
|
+
$settings = config.settings
|
27
|
+
$logger = config.logger || config.open_log
|
28
|
+
unless $settings.key?('dashboard')
|
29
|
+
raise config.invalid_config('missing the following key: dashboard')
|
30
30
|
end
|
31
|
-
|
32
|
-
|
33
|
-
content_type 'text/html'
|
34
|
-
@js = erb :event_templates, :layout => false
|
35
|
-
body erb :index
|
31
|
+
unless $settings.dashboard.port.is_a?(Integer)
|
32
|
+
raise config.invalid_config('dashboard must have a port')
|
36
33
|
end
|
37
|
-
|
38
|
-
|
39
|
-
content_type 'text/html'
|
40
|
-
@js = erb :client_templates, :layout => false
|
41
|
-
body erb :clients
|
34
|
+
unless $settings.dashboard.user.is_a?(String) && $settings.dashboard.password.is_a?(String)
|
35
|
+
raise config.invalid_config('dashboard must have a user and password')
|
42
36
|
end
|
43
|
-
|
44
|
-
|
45
|
-
content_type 'text/html'
|
46
|
-
@js = erb :stash_templates, :layout => false
|
47
|
-
body erb :stashes
|
37
|
+
if options[:daemonize]
|
38
|
+
Process.daemonize
|
48
39
|
end
|
49
|
-
|
50
|
-
|
51
|
-
content_type 'text/css'
|
52
|
-
body sass :sonian
|
40
|
+
if options[:pid_file]
|
41
|
+
Process.write_pid(options[:pid_file])
|
53
42
|
end
|
43
|
+
$api_server = 'http://' + $settings.api.host + ':' + $settings.api.port.to_s
|
44
|
+
end
|
54
45
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
status 404
|
62
|
-
body '{"error":"could not retrieve events from the sensu api"}'
|
63
|
-
end
|
64
|
-
|
65
|
-
http.errback do
|
66
|
-
status 404
|
67
|
-
body '{"error":"could not retrieve events from the sensu api"}'
|
46
|
+
def self.websocket_server
|
47
|
+
$websocket_connections = []
|
48
|
+
EM::WebSocket.start(:host => '0.0.0.0', :port => 9000) do |websocket|
|
49
|
+
websocket.onopen do
|
50
|
+
$logger.info('[websocket] -- client connected to websocket')
|
51
|
+
$websocket_connections.push(websocket)
|
68
52
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
body http.response
|
53
|
+
websocket.onclose do
|
54
|
+
$logger.info('[websocket] -- client disconnected from websocket')
|
55
|
+
$websocket_connections.delete(websocket)
|
73
56
|
end
|
74
57
|
end
|
58
|
+
end
|
75
59
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
requests = [
|
81
|
-
"#{api_server}/events",
|
82
|
-
"#{api_server}/clients"
|
83
|
-
]
|
60
|
+
set :root, File.dirname(__FILE__)
|
61
|
+
set :static, true
|
62
|
+
set :public_folder, Proc.new { File.join(root, 'public') }
|
84
63
|
|
85
|
-
|
86
|
-
|
87
|
-
|
64
|
+
use Rack::Auth::Basic do |user, password|
|
65
|
+
user == $settings.dashboard.user && password == $settings.dashboard.password
|
66
|
+
end
|
88
67
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
multi.responses[:succeeded].each do |request|
|
94
|
-
body = JSON.parse(request.response)
|
95
|
-
case body
|
96
|
-
when Hash
|
97
|
-
events = body
|
98
|
-
when Array
|
99
|
-
clients = body
|
100
|
-
end
|
101
|
-
end
|
68
|
+
before do
|
69
|
+
content_type 'application/json'
|
70
|
+
end
|
102
71
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
# searching by client
|
110
|
-
clients.each do |client|
|
111
|
-
client_name = client['name']
|
112
|
-
if events.include?(client_name)
|
113
|
-
autocomplete.push({:value => [client_name], :type => 'client', :name => client_name})
|
114
|
-
client['subscriptions'].each do |subscription|
|
115
|
-
subscriptions[subscription] ||= []
|
116
|
-
subscriptions[subscription].push(client_name)
|
117
|
-
end
|
118
|
-
events[client_name].each do |check, event|
|
119
|
-
|
120
|
-
case event['status']
|
121
|
-
when 1
|
122
|
-
statuses[:warning].push(event['status'])
|
123
|
-
when 2
|
124
|
-
statuses[:critical].push(event['status'])
|
125
|
-
else
|
126
|
-
statuses[:unknown].push(event['status'])
|
127
|
-
end
|
128
|
-
checks.push(check)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
72
|
+
aget '/' do
|
73
|
+
content_type 'text/html'
|
74
|
+
@js = erb :event_templates, :layout => false
|
75
|
+
body erb :index
|
76
|
+
end
|
132
77
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
78
|
+
aget '/clients' do
|
79
|
+
content_type 'text/html'
|
80
|
+
@js = erb :client_templates, :layout => false
|
81
|
+
body erb :clients
|
82
|
+
end
|
137
83
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
84
|
+
aget '/stashes' do
|
85
|
+
content_type 'text/html'
|
86
|
+
@js = erb :stash_templates, :layout => false
|
87
|
+
body erb :stashes
|
88
|
+
end
|
142
89
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
90
|
+
aget '/css/sonian.css' do
|
91
|
+
content_type 'text/css'
|
92
|
+
body sass :sonian
|
93
|
+
end
|
147
94
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
95
|
+
apost '/events.json' do
|
96
|
+
$logger.debug('[events] -- ' + request.ip + ' -- POST -- triggering dashboard refresh')
|
97
|
+
unless $websocket_connections.empty?
|
98
|
+
$websocket_connections.each do |websocket|
|
99
|
+
websocket.send '{"update":"true"}'
|
153
100
|
end
|
154
101
|
end
|
102
|
+
body '{"success":"triggered dashboard refresh"}'
|
103
|
+
end
|
155
104
|
|
156
|
-
|
157
|
-
|
158
|
-
http = EventMachine::HttpRequest.new("#{api_server}/clients").get
|
159
|
-
rescue => e
|
160
|
-
puts e
|
161
|
-
status 404
|
162
|
-
body '{"error":"could not retrieve clients from the sensu api"}'
|
163
|
-
end
|
105
|
+
aget '/autocomplete.json' do
|
106
|
+
multi = EM::MultiRequest.new
|
164
107
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
108
|
+
requests = [
|
109
|
+
$api_server + '/events',
|
110
|
+
$api_server + '/clients'
|
111
|
+
]
|
169
112
|
|
170
|
-
|
171
|
-
|
172
|
-
body http.response
|
173
|
-
end
|
113
|
+
requests.each do |url|
|
114
|
+
multi.add EM::HttpRequest.new(url).get
|
174
115
|
end
|
175
116
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
multi.callback do
|
189
|
-
events = {}
|
190
|
-
clients = []
|
191
|
-
|
192
|
-
multi.responses[:succeeded].each do |request|
|
193
|
-
body = JSON.parse(request.response)
|
194
|
-
case body
|
195
|
-
when Array
|
196
|
-
clients = body
|
197
|
-
end
|
117
|
+
multi.callback do
|
118
|
+
events = {}
|
119
|
+
clients = []
|
120
|
+
|
121
|
+
multi.responses[:succeeded].each do |request|
|
122
|
+
body = JSON.parse(request.response)
|
123
|
+
case body
|
124
|
+
when Hash
|
125
|
+
events = body
|
126
|
+
when Array
|
127
|
+
clients = body
|
198
128
|
end
|
129
|
+
end
|
199
130
|
|
200
|
-
|
201
|
-
|
202
|
-
|
131
|
+
if events && clients
|
132
|
+
autocomplete = []
|
133
|
+
statuses = {:warning => [], :critical => [], :unknown => []}
|
134
|
+
subscriptions = {}
|
135
|
+
checks = []
|
203
136
|
|
204
|
-
|
205
|
-
|
206
|
-
|
137
|
+
# searching by client
|
138
|
+
clients.each do |client|
|
139
|
+
client_name = client['name']
|
140
|
+
if events.include?(client_name)
|
207
141
|
autocomplete.push({:value => [client_name], :type => 'client', :name => client_name})
|
208
142
|
client['subscriptions'].each do |subscription|
|
209
143
|
subscriptions[subscription] ||= []
|
210
144
|
subscriptions[subscription].push(client_name)
|
211
145
|
end
|
146
|
+
events[client_name].each do |check, event|
|
147
|
+
case event['status']
|
148
|
+
when 1
|
149
|
+
statuses[:warning].push(event['status'])
|
150
|
+
when 2
|
151
|
+
statuses[:critical].push(event['status'])
|
152
|
+
else
|
153
|
+
statuses[:unknown].push(event['status'])
|
154
|
+
end
|
155
|
+
checks.push(check)
|
156
|
+
end
|
212
157
|
end
|
158
|
+
end
|
213
159
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
160
|
+
# searching by subscription
|
161
|
+
subscriptions.each do |k, v|
|
162
|
+
autocomplete.push({:value => v.uniq, :type => 'subscription', :name => k})
|
163
|
+
end
|
218
164
|
|
219
|
-
|
220
|
-
|
221
|
-
status
|
222
|
-
body '{"error":"could not retrieve clients from the sensu api"}'
|
165
|
+
# searching by status
|
166
|
+
statuses.each do |k, v|
|
167
|
+
autocomplete.push({:value => v.uniq, :type => 'status', :name => k})
|
223
168
|
end
|
224
|
-
end
|
225
|
-
end
|
226
169
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
puts e
|
232
|
-
status 404
|
233
|
-
body '{"error":"could not retrieve client from the sensu api"}'
|
234
|
-
end
|
170
|
+
# searching by check
|
171
|
+
checks.uniq.each do |v|
|
172
|
+
autocomplete.push({:value => [v], :type => 'check', :name => v})
|
173
|
+
end
|
235
174
|
|
236
|
-
|
175
|
+
body autocomplete.to_json
|
176
|
+
else
|
237
177
|
status 404
|
238
|
-
body '{"error":"could not retrieve
|
178
|
+
body '{"error":"could not retrieve events and/or clients from the sensu api"}'
|
239
179
|
end
|
180
|
+
end
|
181
|
+
end
|
240
182
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
183
|
+
aget '/clients/autocomplete.json' do
|
184
|
+
multi = EM::MultiRequest.new
|
185
|
+
|
186
|
+
requests = [
|
187
|
+
$api_server + '/clients'
|
188
|
+
]
|
189
|
+
|
190
|
+
requests.each do |url|
|
191
|
+
multi.add EM::HttpRequest.new(url).get
|
245
192
|
end
|
246
193
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
body
|
194
|
+
multi.callback do
|
195
|
+
events = {}
|
196
|
+
clients = []
|
197
|
+
|
198
|
+
multi.responses[:succeeded].each do |request|
|
199
|
+
body = JSON.parse(request.response)
|
200
|
+
case body
|
201
|
+
when Array
|
202
|
+
clients = body
|
203
|
+
end
|
254
204
|
end
|
255
205
|
|
256
|
-
|
206
|
+
if clients
|
207
|
+
autocomplete = []
|
208
|
+
subscriptions = {}
|
209
|
+
|
210
|
+
# searching by client
|
211
|
+
clients.each do |client|
|
212
|
+
client_name = client['name']
|
213
|
+
autocomplete.push({:value => [client_name], :type => 'client', :name => client_name})
|
214
|
+
client['subscriptions'].each do |subscription|
|
215
|
+
subscriptions[subscription] ||= []
|
216
|
+
subscriptions[subscription].push(client_name)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
# searching by subscription
|
221
|
+
subscriptions.each do |k, v|
|
222
|
+
autocomplete.push({:value => v.uniq, :type => 'subscription', :name => k})
|
223
|
+
end
|
224
|
+
|
225
|
+
body autocomplete.to_json
|
226
|
+
else
|
257
227
|
status 404
|
258
|
-
body '{"error":"could not
|
228
|
+
body '{"error":"could not retrieve clients from the sensu api"}'
|
259
229
|
end
|
230
|
+
end
|
231
|
+
end
|
260
232
|
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
233
|
+
#
|
234
|
+
# API Proxy
|
235
|
+
#
|
236
|
+
|
237
|
+
aget '/events.json' do
|
238
|
+
begin
|
239
|
+
http = EM::HttpRequest.new($api_server + '/events').get
|
240
|
+
rescue => e
|
241
|
+
$logger.warning(e)
|
242
|
+
status 404
|
243
|
+
body '{"error":"could not retrieve events from the sensu api"}'
|
265
244
|
end
|
266
245
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
puts e
|
272
|
-
status 404
|
273
|
-
body '{"error":"could not retrieve a stash from the sensu api"}'
|
274
|
-
end
|
246
|
+
http.errback do
|
247
|
+
status 404
|
248
|
+
body '{"error":"could not retrieve events from the sensu api"}'
|
249
|
+
end
|
275
250
|
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
251
|
+
http.callback do
|
252
|
+
status http.response_header.status
|
253
|
+
body http.response
|
254
|
+
end
|
255
|
+
end
|
280
256
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
257
|
+
aget '/clients.json' do
|
258
|
+
begin
|
259
|
+
http = EM::HttpRequest.new($api_server + '/clients').get
|
260
|
+
rescue => e
|
261
|
+
$logger.warning(e)
|
262
|
+
status 404
|
263
|
+
body '{"error":"could not retrieve clients from the sensu api"}'
|
285
264
|
end
|
286
265
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
:head => {
|
292
|
-
'content-type' => 'application/json'
|
293
|
-
}
|
294
|
-
}
|
295
|
-
http = EventMachine::HttpRequest.new("#{api_server}/stash/#{path}").post request_options
|
296
|
-
rescue => e
|
297
|
-
puts e
|
298
|
-
status 404
|
299
|
-
body '{"error":"could not create a stash with the sensu api"}'
|
300
|
-
end
|
266
|
+
http.errback do
|
267
|
+
status 404
|
268
|
+
body '{"error":"could not retrieve clients from the sensu api"}'
|
269
|
+
end
|
301
270
|
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
271
|
+
http.callback do
|
272
|
+
status http.response_header.status
|
273
|
+
body http.response
|
274
|
+
end
|
275
|
+
end
|
306
276
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
277
|
+
aget '/client/:id.json' do |id|
|
278
|
+
begin
|
279
|
+
http = EM::HttpRequest.new($api_server + '/client/' + id).get
|
280
|
+
rescue => e
|
281
|
+
$logger.warning(e)
|
282
|
+
status 404
|
283
|
+
body '{"error":"could not retrieve client from the sensu api"}'
|
311
284
|
end
|
312
285
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
puts e
|
318
|
-
status 404
|
319
|
-
body '{"error":"could not delete a stash with the sensu api"}'
|
320
|
-
end
|
286
|
+
http.errback do
|
287
|
+
status 404
|
288
|
+
body '{"error":"could not retrieve client from the sensu api"}'
|
289
|
+
end
|
321
290
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
291
|
+
http.callback do
|
292
|
+
status http.response_header.status
|
293
|
+
body http.response
|
294
|
+
end
|
295
|
+
end
|
326
296
|
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
297
|
+
adelete '/client/:id.json' do |id|
|
298
|
+
begin
|
299
|
+
http = EventMachine::HttpRequest.new($api_server + '/client/' + id).delete
|
300
|
+
rescue => e
|
301
|
+
$logger.warning(e)
|
302
|
+
status 404
|
303
|
+
body '{"error":"could not delete client from the sensu api"}'
|
331
304
|
end
|
332
305
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
:head => {
|
338
|
-
'content-type' => 'application/json'
|
339
|
-
}
|
340
|
-
}
|
341
|
-
http = EventMachine::HttpRequest.new("#{api_server}/event/resolve").post request_options
|
342
|
-
rescue => e
|
343
|
-
puts e
|
344
|
-
status 404
|
345
|
-
body '{"error":"could not resolve an event with the sensu api"}'
|
346
|
-
end
|
306
|
+
http.errback do
|
307
|
+
status 404
|
308
|
+
body '{"error":"could not delete client from the sensu api"}'
|
309
|
+
end
|
347
310
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
311
|
+
http.callback do
|
312
|
+
status http.response_header.status
|
313
|
+
body http.response
|
314
|
+
end
|
315
|
+
end
|
352
316
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
317
|
+
aget '/stash/*.json' do |path|
|
318
|
+
begin
|
319
|
+
http = EM::HttpRequest.new($api_server + '/stash/' + path).get
|
320
|
+
rescue => e
|
321
|
+
$logger.warning(e)
|
322
|
+
status 404
|
323
|
+
body '{"error":"could not retrieve a stash from the sensu api"}'
|
324
|
+
end
|
325
|
+
|
326
|
+
http.errback do
|
327
|
+
status 404
|
328
|
+
body '{"error":"could not retrieve a stash from the sensu api"}'
|
357
329
|
end
|
358
330
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
331
|
+
http.callback do
|
332
|
+
status http.response_header.status
|
333
|
+
body http.response
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
apost '/stash/*.json' do |path|
|
338
|
+
begin
|
339
|
+
request_options = {
|
340
|
+
:body => {'timestamp' => Time.now.to_i}.to_json,
|
341
|
+
:head => {
|
342
|
+
'content-type' => 'application/json'
|
366
343
|
}
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
344
|
+
}
|
345
|
+
http = EM::HttpRequest.new($api_server + '/stash/' + path).post request_options
|
346
|
+
rescue => e
|
347
|
+
$logger.warning(e)
|
348
|
+
status 404
|
349
|
+
body '{"error":"could not create a stash with the sensu api"}'
|
350
|
+
end
|
373
351
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
352
|
+
http.errback do
|
353
|
+
status 404
|
354
|
+
body '{"error":"could not create a stash with the sensu api"}'
|
355
|
+
end
|
378
356
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
body resp
|
383
|
-
end
|
357
|
+
http.callback do
|
358
|
+
status http.response_header.status
|
359
|
+
body http.response
|
384
360
|
end
|
361
|
+
end
|
385
362
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
http = EventMachine::HttpRequest.new("#{api_server}/stashes").post request_options
|
395
|
-
rescue => e
|
396
|
-
puts e
|
397
|
-
status 404
|
398
|
-
body '{\"error\":\"could not retrieve a list of stashes from the sensu api\"}'
|
399
|
-
end
|
363
|
+
adelete '/stash/*.json' do |path|
|
364
|
+
begin
|
365
|
+
http = EM::HttpRequest.new($api_server + '/stash/' + path).delete
|
366
|
+
rescue => e
|
367
|
+
$logger.warning(e)
|
368
|
+
status 404
|
369
|
+
body '{"error":"could not delete a stash with the sensu api"}'
|
370
|
+
end
|
400
371
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
372
|
+
http.errback do
|
373
|
+
status 404
|
374
|
+
body '{"error":"could not delete a stash with the sensu api"}'
|
375
|
+
end
|
405
376
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
status http.response_header.status
|
410
|
-
body resp
|
411
|
-
end
|
377
|
+
http.callback do
|
378
|
+
status http.response_header.status
|
379
|
+
body http.response
|
412
380
|
end
|
381
|
+
end
|
413
382
|
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
383
|
+
apost '/event/resolve.json' do
|
384
|
+
begin
|
385
|
+
request_options = {
|
386
|
+
:body => request.body.read,
|
387
|
+
:head => {
|
388
|
+
'content-type' => 'application/json'
|
389
|
+
}
|
390
|
+
}
|
391
|
+
http = EM::HttpRequest.new($api_server + '/event/resolve').post request_options
|
392
|
+
rescue => e
|
393
|
+
$logger.warning(e)
|
394
|
+
status 404
|
395
|
+
body '{"error":"could not resolve an event with the sensu api"}'
|
424
396
|
end
|
425
397
|
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
398
|
+
http.errback do
|
399
|
+
status 404
|
400
|
+
body '{"error":"could not resolve an event with the sensu api"}'
|
401
|
+
end
|
402
|
+
|
403
|
+
http.callback do
|
404
|
+
status http.response_header.status
|
405
|
+
body http.response
|
433
406
|
end
|
434
407
|
end
|
435
408
|
|
436
|
-
|
409
|
+
aget '/stashes.json' do
|
410
|
+
begin
|
411
|
+
http = EM::HttpRequest.new($api_server + '/stashes').get
|
412
|
+
rescue => e
|
413
|
+
$logger.warning(e)
|
414
|
+
status 404
|
415
|
+
body '{"error":"could not retrieve a list of stashes from the sensu api"}'
|
416
|
+
end
|
437
417
|
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
418
|
+
http.errback do
|
419
|
+
status 404
|
420
|
+
body '{"error":"could not retrieve a list of stashes from the sensu api"}'
|
421
|
+
end
|
422
|
+
|
423
|
+
http.callback do
|
424
|
+
status http.response_header.status
|
425
|
+
body http.response
|
426
|
+
end
|
443
427
|
end
|
444
|
-
|
445
|
-
|
428
|
+
|
429
|
+
apost '/stashes.json' do
|
430
|
+
begin
|
431
|
+
request_options = {
|
432
|
+
:body => request.body.read,
|
433
|
+
:head => {
|
434
|
+
'content-type' => 'application/json'
|
435
|
+
}
|
436
|
+
}
|
437
|
+
http = EM::HttpRequest.new($api_server + '/stashes').post request_options
|
438
|
+
rescue => e
|
439
|
+
$logger.warning(e)
|
440
|
+
status 404
|
441
|
+
body '{"error":"could not retrieve a list of stashes from the sensu api"}'
|
442
|
+
end
|
443
|
+
|
444
|
+
http.errback do
|
445
|
+
status 404
|
446
|
+
body '{"error":"could not retrieve a list of stashes from the sensu api"}'
|
447
|
+
end
|
448
|
+
|
449
|
+
http.callback do
|
450
|
+
status http.response_header.status
|
451
|
+
body http.response
|
452
|
+
end
|
446
453
|
end
|
447
454
|
|
455
|
+
def self.stop(signal)
|
456
|
+
$logger.warn('[stop] -- stopping sensu dashboard -- ' + signal)
|
457
|
+
EM::Timer.new(1) do
|
458
|
+
EM::stop_event_loop
|
459
|
+
end
|
460
|
+
end
|
448
461
|
end
|
462
|
+
|
463
|
+
options = Sensu::Config.read_arguments(ARGV)
|
464
|
+
Dashboard.run(options)
|
data/sensu-dashboard.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = %q{A web interface for sensu, a publish/subscribe server monitoring framework}
|
12
12
|
s.description = %q{Display current events and clients in sensu via a simple web interface. Please use the sensu-dashboard gem as this gem is for Sonian use only.}
|
13
13
|
|
14
|
-
s.add_dependency("sensu")
|
14
|
+
s.add_dependency("sensu", "~> 0.9.1")
|
15
15
|
s.add_dependency("em-http-request", "0.3.0")
|
16
16
|
s.add_dependency("em-websocket")
|
17
17
|
s.add_dependency("sass")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-dashboard-sonian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 6
|
10
|
+
version: 0.9.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Justin Kolberg
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-12-
|
19
|
+
date: 2011-12-28 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -25,12 +25,14 @@ dependencies:
|
|
25
25
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
26
|
none: false
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
30
|
+
hash: 57
|
31
31
|
segments:
|
32
32
|
- 0
|
33
|
-
|
33
|
+
- 9
|
34
|
+
- 1
|
35
|
+
version: 0.9.1
|
34
36
|
type: :runtime
|
35
37
|
version_requirements: *id001
|
36
38
|
- !ruby/object:Gem::Dependency
|