-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot_health.html
340 lines (253 loc) · 11 KB
/
bot_health.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
---
title: Home Page
---
<head>
{% include common.html %}
<style>
.y.axis line, .y.axis path {
fill: none;
stroke: #000;
}
/* tell the SVG path to be a thin blue line without any area fill */
path {
stroke-width: 1;
fill: none;
}
</style>
</head>
{% for post in site.posts %}
{% if post.pull_request_issue_id == "" and post.repository %}
{% capture base_repository %}{{ post.repository }}{% endcapture %}
{% capture results_repository %}{{ post.results_repository }}{% endcapture %}
{% break %}
{% endif %}
{% endfor %}
{% include common_variables.html %}
<body>
<script>
document.writeln("<ol class='breadcrumb'><li><a href='full_dashboard.html'>Full Dashboard</a></li><li><a href='index.html'>Active Dashboard</a></li><li><a href='performance.html'>Performance</a></li><li>Bot Health</li></ol>");
</script>
<script>
function build_bot_data(data) {
var objects = new Object();
objects.seen_dates = [];
objects.ids = [];
for (var i = 0; i < data.length; ++i){
var key = data[i].machine_name + data[i].machine_ip;
if (!objects.hasOwnProperty(key)) {
objects.ids.push(key);
var bot = new Object();
bot.machine_name = data[i].machine_name;
bot.machine_ip = data[i].machine_ip;
bot.os = data[i].os;
bot.os_release = data[i].os_release;
bot.seen_dates = [];
bot.device_ids = [];
bot.unhandled_failure_dates = [];
objects[key] = bot;
}
objects.seen_dates.push(parseDate(data[i].date));
objects[key].seen_dates.push(parseDate(data[i].date));
if (!objects[key].hasOwnProperty(data[i].device_id)) {
objects[key].device_ids.push(data[i].device_id);
var device_id_obj = Object();
device_id_obj.build_times = [];
device_id_obj.test_times = [];
device_id_obj.package_times = [];
device_id_obj.install_times = [];
device_id_obj.seen_dates = [];
device_id_obj.unhandled_failures = 0;
device_id_obj.unhandled_failures_dates = [];
device_id_obj.num_builds = 0;
objects[key][data[i].device_id] = device_id_obj;
}
objects[key][data[i].device_id].seen_dates.push(parseDate(data[i].date));
objects[key][data[i].device_id].num_builds++;
if (data[i].build_time != null) {
objects[key][data[i].device_id].build_times.push(data[i].build_time);
}
if (data[i].test_time != null) {
objects[key][data[i].device_id].test_times.push(data[i].test_time);
}
if (data[i].package_time != null) {
objects[key][data[i].device_id].package_times.push(data[i].package_time);
}
if (data[i].install_time != null) {
objects[key][data[i].device_id].install_times.push(data[i].install_time);
}
if (data[i].unhandled_failure) {
objects[key][data[i].device_id].unhandled_failures++;
objects[key][data[i].device_id].unhandled_failures_dates.push(parseDate(data[i].date));
}
}
var max_seen_stamp = Math.max.apply(null, objects.seen_dates);
var day_1 = 60 * 60 * 24 * 1000;
var days_3 = day_1 * 3;
var days_7 = day_1 * 7;
var days_14 = day_1 * 14;
var warn_stamp = max_seen_stamp - days_3;
var error_stamp = max_seen_stamp - days_7;
var inactive = max_seen_stamp - days_14;
for (var bot_index = 0; bot_index < objects.ids.length; ++bot_index) {
var obj = objects[objects.ids[bot_index]];
obj.min_date_stamp = Math.min.apply(null, obj.seen_dates);
obj.max_date_stamp = Math.max.apply(null, obj.seen_dates);
if (obj.max_date_stamp < inactive) {
obj.inactive = true;
} else {
obj.inactive = false;
}
if (obj.max_date_stamp < error_stamp) {
obj.error_last_seen = true;
} else {
obj.error_last_seen = false;
}
if (obj.max_date_stamp < warn_stamp) {
obj.warning_last_seen = true;
} else {
obj.warning_last_seen = false;
}
obj.warning_unhandled_failures = false;
obj.error_unhandled_failures = false;
for (var device_index = 0; device_index < obj.device_ids.length; ++device_index) {
var build_device = obj[obj.device_ids[device_index]];
build_device.min_date_stamp = Math.min.apply(null, build_device.seen_dates);
build_device.max_date_stamp = Math.max.apply(null, build_device.seen_dates);
build_device.max_unhandled_failures_date_stamp = Math.max.apply(null, build_device.unhandled_failures_dates);
if (build_device.max_date_stamp < error_stamp) {
build_device.error_last_seen = true;
} else {
build_device.error_last_seen = false;
}
if (build_device.max_date_stamp < warn_stamp) {
build_device.warning_last_seen = true;
} else {
build_device.warning_last_seen = false;
}
// unhandled failures timing is the inverse of build device last seen failures
if (build_device.max_unhandled_failures_date_stamp > error_stamp) {
build_device.warning_unhandled_failures = true;
} else {
build_device.warning_unhandled_failures = false;
}
if (build_device.max_unhandled_failures_date_stamp > warn_stamp) {
build_device.error_unhandled_failures = true;
} else {
build_device.error_unhandled_failures = false;
}
obj.warning_unhandled_failures = obj.warning_unhandled_failures || build_device.warning_unhandled_failures;
obj.error_unhandled_failures = obj.error_unhandled_failures || build_device.error_unhandled_failures;
}
}
return objects;
}
function print_bot_data(t_data, t_inactive)
{
var keys = t_data.ids;
keys.sort(
function(a, b) {
if (a.toLowerCase() < b.toLowerCase()) return -1;
if (a.toLowerCase() > b.toLowerCase()) return 1;
return 0;
}
);
for (var i = 0; i < keys.length; ++i) {
var obj = t_data[keys[i]];
if (obj.inactive != t_inactive) { continue; }
var panel_context = function(obj){
if (obj.error_last_seen || obj.error_unhandled_failures) {
return "danger";
}
if (obj.warning_last_seen || obj.warning_unhandled_failures) {
return "warning";
}
return "success";
};
var last_seen_context = function(obj){
if (obj.error_last_seen) {
return "danger";
}
if (obj.warning_last_seen) {
return "warning";
}
return "success";
};
var unhandled_failures_context = function(obj){
if (obj.error_unhandled_failures) {
return "danger";
}
if (obj.warning_unhandled_failures) {
return "warning";
}
return "success";
};
var key = keys[i].replace(/\./g, "_").replace(/ /g, "_").replace(/-/g, "_");
var min_date = new Date(obj.min_date_stamp);
var max_date = new Date(obj.max_date_stamp);
document.writeln(
"<div class='panel panel-default'>"
+ "<div class='panel-heading'><span class='pull-right label label-" + unhandled_failures_context(obj) + "'>unhandled failures</span> <span class='pull-right label label-" + last_seen_context(obj) + "'>last seen</span> <span class='pull-right badge'>" + obj.machine_ip + "</span><h2 class='panel-title'><a data-toggle='collapse' data-parent='#accordian-" + key + "' href='#collapse-" + key + "'>" + osIcon(obj.device_ids[0]) + " " + obj.machine_name + " </a></h2></div>"
+ "<div id='collapse-" + key + "' class='panel-collapse collapse'><div class='panel-body'>"
+ "<p>");
document.writeln(
"<ul class='list-group'>"
+ "<li class='list-group-item'><strong>Machine name</strong> " + obj.machine_name + "</li>"
+ "<li class='list-group-item'><strong>Machine IP</strong> " + obj.machine_ip+ "</li>"
+ "<li class='list-group-item'><strong>OS</strong> " + obj.os + "</li>"
+ "<li class='list-group-item'><strong>OS release</strong> " + obj.os_release + "</li>"
+ "<li class='list-group-item'><strong>Number of builds</strong> " + obj.seen_dates.length + "</li>"
+ "<li class='list-group-item'><strong>First seen</strong> " + min_date.toString() + "</li>"
+ "<li class='list-group-item list-group-item-" + last_seen_context(obj) + "'><strong>Last seen</strong> " + max_date.toString() + "</li>"
+ "</ul>"
);
var device_ids = obj.device_ids.sort();
for (var device_index = 0; device_index < device_ids.length; ++device_index) {
var build_device = obj[device_ids[device_index]];
if (build_device == null) { continue; }
document.writeln(
"<div class='panel panel-" + panel_context(build_device) + "'>"
+ "<div class='panel-heading'><h3 class='panel-title'>" + device_ids[device_index] + "</h3></div>"
+ "<div class='panel-body'>"
+ "<p>");
var device_min_date = new Date(build_device.min_date_stamp);
var device_max_date = new Date(build_device.max_date_stamp);
var average = function(a) {
if (a.length == 0) { return null; }
var sum = function(a, b){
return a + b;
};
return a.reduce(sum) / a.length;
};
var avg_build_time = average(build_device.build_times);
var avg_test_time = average(build_device.test_times);
var avg_package_time = average(build_device.package_times);
var last_unhandled_failure_stamp = Math.max.apply(null, build_device.unhandled_failures_dates);
var last_unhandled_failure = new Date(last_unhandled_failure_stamp);
document.writeln(
"<ul class='list-group'>"
+ "<li class='list-group-item'><strong>First seen</strong> " + device_min_date.toString() + "</li>"
+ "<li class='list-group-item list-group-item-" + last_seen_context(build_device) + "'><strong>Last seen</strong> " + device_max_date.toString() + "</li>"
+ "<li class='list-group-item'><strong>Number of builds</strong> " + build_device.num_builds + "</li>"
+ "<li class='list-group-item'><strong>Average build time</strong> " + avg_build_time + "</li>"
+ "<li class='list-group-item'><strong>Average test time</strong> " + avg_test_time + "</li>"
+ "<li class='list-group-item'><strong>Average package time</strong> " + avg_package_time + "</li>"
+ "<li class='list-group-item'><strong>Unhandled failures</strong> " + build_device.unhandled_failures + "</li>"
+ "<li class='list-group-item list-group-item-" + unhandled_failures_context(build_device) + "'><strong>Last unhandled failure</strong> " + last_unhandled_failure.toString() + "</li>"
+ "</ul>"
);
document.writeln("</p></div></div>");
}
document.writeln("</p></div></div></div>\n\n<br/><br/>");
}
}
var bot_data = build_bot_data(data);
document.writeln("<div class='page-header'> <h1>Active Bot health dashboard for {{ dashboard_title }}</h1> </div>");
document.writeln("<div class='container'>");
print_bot_data(bot_data, false);
document.writeln("</div>");
document.writeln("<div class='page-header'> <h1>Inactive Bot health dashboard for {{ dashboard_title }}</h1> </div>");
document.writeln("<div class='container'>");
print_bot_data(bot_data, true);
document.writeln("</div>");
</script>
</body>