sensu-dashboard 0.8.1 → 0.9.0
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/sensu-dashboard/app.rb
CHANGED
@@ -104,44 +104,45 @@ EventMachine.run do
|
|
104
104
|
autocomplete = []
|
105
105
|
statuses = {:warning => [], :critical => [], :unknown => []}
|
106
106
|
subscriptions = {}
|
107
|
-
checks =
|
107
|
+
checks = []
|
108
108
|
|
109
|
+
# searching by client
|
109
110
|
clients.each do |client|
|
110
111
|
client_name = client['name']
|
111
112
|
if events.include?(client_name)
|
112
|
-
autocomplete.push({:value => client_name, :name => client_name})
|
113
|
+
autocomplete.push({:value => [client_name], :type => 'client', :name => client_name})
|
113
114
|
client['subscriptions'].each do |subscription|
|
114
115
|
subscriptions[subscription] ||= []
|
115
116
|
subscriptions[subscription].push(client_name)
|
116
117
|
end
|
117
118
|
events[client_name].each do |check, event|
|
118
|
-
|
119
|
+
|
120
|
+
case event['status']
|
119
121
|
when 1
|
120
|
-
statuses[:warning].push(
|
122
|
+
statuses[:warning].push(event['status'])
|
121
123
|
when 2
|
122
|
-
statuses[:critical].push(
|
124
|
+
statuses[:critical].push(event['status'])
|
123
125
|
else
|
124
|
-
statuses[:unknown].push(
|
126
|
+
statuses[:unknown].push(event['status'])
|
125
127
|
end
|
126
|
-
checks
|
127
|
-
checks[check].push(client_name)
|
128
|
+
checks.push(check)
|
128
129
|
end
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
132
133
|
# searching by subscription
|
133
134
|
subscriptions.each do |k, v|
|
134
|
-
autocomplete.push({:value => v.
|
135
|
+
autocomplete.push({:value => v.uniq, :type => 'subscription', :name => k})
|
135
136
|
end
|
136
137
|
|
137
138
|
# searching by status
|
138
139
|
statuses.each do |k, v|
|
139
|
-
autocomplete.push({:value => v.
|
140
|
+
autocomplete.push({:value => v.uniq, :type => 'status', :name => k})
|
140
141
|
end
|
141
142
|
|
142
143
|
# searching by check
|
143
|
-
checks.each do |
|
144
|
-
autocomplete.push({:value => v
|
144
|
+
checks.uniq.each do |v|
|
145
|
+
autocomplete.push({:value => [v], :type => 'check', :name => v})
|
145
146
|
end
|
146
147
|
|
147
148
|
body autocomplete.to_json
|
@@ -1,8 +1,17 @@
|
|
1
1
|
// remap jQuery to $
|
2
2
|
(function($){})(window.jQuery);
|
3
3
|
|
4
|
-
|
5
|
-
var
|
4
|
+
Object.size = function(obj) {
|
5
|
+
var size = 0, key;
|
6
|
+
for (key in obj) {
|
7
|
+
if (obj.hasOwnProperty(key)) size++;
|
8
|
+
}
|
9
|
+
return size;
|
10
|
+
};
|
11
|
+
|
12
|
+
var selected_filters = {};
|
13
|
+
var grouped_filters = {};
|
14
|
+
|
6
15
|
var filter_unknown_checks = true;
|
7
16
|
|
8
17
|
function capitaliseFirstLetter(string) {
|
@@ -22,46 +31,107 @@ function fetchEvents() {
|
|
22
31
|
var event_count = 0;
|
23
32
|
|
24
33
|
$.getJSON('/events.json', function(data) {
|
25
|
-
m_events = new Array();
|
34
|
+
var m_events = new Array();
|
26
35
|
|
27
36
|
$('table#events > tbody').empty();
|
28
37
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
38
|
+
// iterate through the filters
|
39
|
+
grouped_filters = {};
|
40
|
+
for (var i in selected_filters) {
|
41
|
+
var current_filter = selected_filters[i];
|
42
|
+
|
43
|
+
// store client filters in the grouped filters array
|
44
|
+
if (current_filter['type'] == 'client') {
|
45
|
+
grouped_filters['client'] || (grouped_filters['client'] = []);
|
46
|
+
for (var j in current_filter['value']) {
|
47
|
+
grouped_filters['client'].push(current_filter['value'][j]);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
// store subscription filters in the grouped filters array
|
52
|
+
if (current_filter['type'] == 'subscription') {
|
53
|
+
grouped_filters['subscription'] || (grouped_filters['subscription'] = []);
|
54
|
+
for (var j in current_filter['value']) {
|
55
|
+
grouped_filters['subscription'].push(current_filter['value'][j]);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
// store check filters in the grouped filters array
|
60
|
+
if (current_filter['type'] == 'check') {
|
61
|
+
grouped_filters['check'] || (grouped_filters['check'] = []);
|
62
|
+
for (var j in current_filter['value']) {
|
63
|
+
grouped_filters['check'].push(current_filter['value'][j]);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
// store status filters in the grouped filters array
|
68
|
+
if (current_filter['type'] == 'status') {
|
69
|
+
grouped_filters['status'] || (grouped_filters['status'] = []);
|
70
|
+
for (var j in current_filter['value']) {
|
71
|
+
grouped_filters['status'].push(current_filter['value'][j]);
|
59
72
|
}
|
60
73
|
}
|
61
74
|
}
|
62
75
|
|
63
|
-
|
64
|
-
|
76
|
+
// iterate through each node
|
77
|
+
for (var nodekey in data) {
|
78
|
+
// skip node if client filters exist and the client is not in the filter
|
79
|
+
if ((Object.size(grouped_filters['client']) > 0) && ($.inArray(nodekey, grouped_filters['client']) == -1)) {
|
80
|
+
continue;
|
81
|
+
}
|
82
|
+
|
83
|
+
// skip node if subscription filters exist and the subscription is not in the filter
|
84
|
+
if ((Object.size(grouped_filters['subscription']) > 0) && ($.inArray(nodekey, grouped_filters['subscription']) == -1)) {
|
85
|
+
continue;
|
86
|
+
}
|
87
|
+
|
88
|
+
var node = data[nodekey];
|
89
|
+
|
90
|
+
// iterate through each event for the current node
|
91
|
+
for (var a in node) {
|
92
|
+
// skip unknown checks if the checkbox is enabled
|
93
|
+
if (filter_unknown_checks && (node[a]['output'] == 'Unknown check')) {
|
94
|
+
continue;
|
95
|
+
}
|
96
|
+
|
97
|
+
// skip event if check filters exist and the check is not in the filter
|
98
|
+
if ((Object.size(grouped_filters['check']) > 0) && ($.inArray(a, grouped_filters['check']) == -1)) {
|
99
|
+
continue;
|
100
|
+
}
|
101
|
+
|
102
|
+
// skip event if status filters exist and the status is not in the filter
|
103
|
+
if ((Object.size(grouped_filters['status']) > 0) && ($.inArray(node[a]['status'], grouped_filters['status']) == -1)) {
|
104
|
+
continue;
|
105
|
+
}
|
106
|
+
|
107
|
+
// if a status code does not exist, set it to unknown
|
108
|
+
node[a]['status'] || (node[a]['status'] = 3);
|
109
|
+
|
110
|
+
// if an output does not exist, set it to "nil"
|
111
|
+
node[a]['output'] || (node[a]['output'] = "nil output");
|
112
|
+
|
113
|
+
var is_unknown = node[a]['status'] >= 3 || node[a]['status'] < 0;
|
114
|
+
|
115
|
+
event_count++;
|
116
|
+
var dataObject = {
|
117
|
+
identifier: SHA1(nodekey+a),
|
118
|
+
client: nodekey,
|
119
|
+
check: a,
|
120
|
+
status: node[a]['status'],
|
121
|
+
output: node[a]['output'],
|
122
|
+
occurrences: node[a]['occurrences'],
|
123
|
+
is_unknown: is_unknown
|
124
|
+
};
|
125
|
+
|
126
|
+
if (!m_events[node[a]['status']]) {
|
127
|
+
m_events[node[a]['status']] = [];
|
128
|
+
}
|
129
|
+
|
130
|
+
m_events[node[a]['status']][nodekey+a] = dataObject;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
for (var status in m_events) {
|
134
|
+
for (var a in m_events[status]) {
|
65
135
|
var m_event = m_events[status][a];
|
66
136
|
var ccheck = m_event['client'] + m_event['check'];
|
67
137
|
|
@@ -163,10 +233,10 @@ function fetchStashes() {
|
|
163
233
|
data: JSON.stringify(data),
|
164
234
|
success: function(stash_data, textStatus, xhr) {
|
165
235
|
stashes = new Array();
|
166
|
-
for (stash in stash_data) {
|
236
|
+
for (var stash in stash_data) {
|
167
237
|
stash_keys = new Array();
|
168
238
|
stash_values = new Array();
|
169
|
-
for (stash_value in stash_data[stash]) {
|
239
|
+
for (var stash_value in stash_data[stash]) {
|
170
240
|
stash_keys.push(stash_value);
|
171
241
|
stash_values.push({
|
172
242
|
name: stash_value,
|
@@ -225,21 +295,6 @@ function fetchStashes() {
|
|
225
295
|
});
|
226
296
|
}
|
227
297
|
|
228
|
-
function filterEvents() {
|
229
|
-
var values = $("input[type=hidden]").val().split(",");
|
230
|
-
filtered_events = [];
|
231
|
-
filtered_events_count = 0;
|
232
|
-
|
233
|
-
for(value in values) {
|
234
|
-
if(values[value] != "") {
|
235
|
-
filtered_events_count++;
|
236
|
-
filtered_events.push(values[value]);
|
237
|
-
}
|
238
|
-
}
|
239
|
-
|
240
|
-
fetchEvents();
|
241
|
-
}
|
242
|
-
|
243
298
|
/* trigger when page is ready */
|
244
299
|
$(document).ready(function() {
|
245
300
|
|
@@ -248,11 +303,11 @@ $(document).ready(function() {
|
|
248
303
|
selectedItemProp: "name",
|
249
304
|
searchObjProps: "name",
|
250
305
|
selectionAdded: function(elem) {
|
251
|
-
|
306
|
+
fetchEvents();
|
252
307
|
},
|
253
308
|
selectionRemoved: function(elem) {
|
254
309
|
elem.fadeTo("fast", 0, function() { elem.remove(); });
|
255
|
-
|
310
|
+
fetchEvents();
|
256
311
|
}
|
257
312
|
});
|
258
313
|
|
@@ -170,7 +170,7 @@
|
|
170
170
|
var clientname = org_li.prev().text();
|
171
171
|
clientname = clientname.substring(1, clientname.length);
|
172
172
|
var clients = items[clientname];
|
173
|
-
|
173
|
+
delete selected_filters[clients];
|
174
174
|
opts.selectionRemoved.call(this, org_li.prev());
|
175
175
|
} else {
|
176
176
|
opts.selectionClick.call(this, org_li.prev());
|
@@ -329,16 +329,16 @@
|
|
329
329
|
}
|
330
330
|
|
331
331
|
function add_selected_item(data, num){
|
332
|
-
|
333
|
-
|
334
|
-
|
332
|
+
var item_id = SHA1(data['name'] + data['type']);
|
333
|
+
selected_filters[item_id] = data;
|
334
|
+
items[data[opts.selectedItemProp]] = item_id;
|
335
335
|
var item = $('<li class="as-selection-item" id="as-selection-'+num+'"></li>').click(function(){
|
336
336
|
opts.selectionClick.call(this, $(this));
|
337
337
|
selections_holder.children().removeClass("selected");
|
338
338
|
$(this).addClass("selected");
|
339
339
|
}).mousedown(function(){ input_focus = false; });
|
340
340
|
var close = $('<a class="as-close">×</a>').click(function(){
|
341
|
-
|
341
|
+
delete selected_filters[item_id];
|
342
342
|
opts.selectionRemoved.call(this, item);
|
343
343
|
input_focus = true;
|
344
344
|
input.focus();
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-dashboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 9
|
9
|
+
- 0
|
10
|
+
version: 0.9.0
|
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-15 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|