-
Notifications
You must be signed in to change notification settings - Fork 4
/
ganglia.html
335 lines (291 loc) · 9.22 KB
/
ganglia.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body onload="init()">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/moment.js"></script>
<title> Ganglia Graph Extractor </title>
<script type="text/javascript">
var imageSize = 'xlarge';
var xhr = new XMLHttpRequest();
var apps;
<!-- var metrics = {"cpu_report":"", "input_disk_report":"2500000000", "temp_disk_report":"2500000000", "output_disk_report":"2500000000", "network_report":"2500000000"}; -->
var metrics = {
// "mem_report":"",
"cpu_report":"",
// "network_report":"",
"network_stack_report":"2500000000",
// "load_all_report":"",
"disk_throu_report":"4000000000",
};
function err(){
document.getElementById('placeholder').innerHTML =
'<p> Please type start/finish times in %m/%d/%Y %H:%M</p>';
}
function getQuickTimeButtonString(min, text) {
return '<button type="button" ' +
'class="btn btn-default btn-primary" ' +
'onclick="setTimeFrom('+min+')">'+text+'</button>';
}
function setQuickTimeButtons() {
var str = '';
var times1 = {10:'10m', 20:'20m', 30:'30m', 40:'40m', 50:'50m', 60:'60m'};
var times2 = {120:'2h', 240:'4h', 360:'6h', 720:'12h', 1080:'18h', 1440:'24h'};
var times3 = {2880:'2d', 4320:'3d', 5760:'4d', 7200:'5d', 8640:'6d', 10080:'7d'};
str = '<div class="btn-group" role="group">'
for (var min in times1) {
var text = times1[min];
str += getQuickTimeButtonString(min, text);
}
str += '</div> '
document.getElementById("min-buttons").innerHTML += str;
str = '<div class="btn-group" role="group">'
for (var min in times2) {
var text = times2[min];
str += getQuickTimeButtonString(min, text);
}
str += '</div> '
document.getElementById("hr-buttons").innerHTML += str;
str = '<div class="btn-group" role="group">'
for (var min in times3) {
var text = times3[min];
str+= getQuickTimeButtonString(min, text);
}
str += '</div>'
document.getElementById("day-buttons").innerHTML += str;
}
function onApplicationLoaded(i) {
if (apps) {
var app = apps[i];
setTimeFromMillis(app.startedTime, app.finishedTime);
console.log(app);
}
}
function setRecentApplications() {
//http://sobd-master:8188/ws/v1/applicationhistory/apps/
var appsLimit = document.getElementById("yarn-apps-limit").value;
var ats = document.getElementById("yarn-ats").value;
var appTable = document.getElementById("yarn-apps-table");
apps = undefined;
xhr.open('GET', ats+"/ws/v1/applicationhistory/apps?limit="+appsLimit);
xhr.responseType = 'json';
xhr.onload = function() {
if (xhr.status === 200) {
var str = '';
var appObjList = xhr.response.app;
for (var i in appObjList) {
var app = appObjList[i];
var from = moment(app.startedTime);
var until = moment(app.finishedTime);
str += '<tr>';
str += '<td>' + app.appId.replace("application_", "") + '</td>';
str += '<td>' + app.name + '</td>';
str += '<td>' + app.appState + '</td>';
str += '<td>' + from.format('MM/DD HH:mm') + '</td>';
str += '<td>' + until.format('MM/DD HH:mm') + '</td>';
str += '<td>' + app.elapsedTime/1000 + '</td>';
var t1 = from.format("MM/DD/YYYY HH:mm");
var t2 = until.format("MM/DD/YYYY HH:mm");
str += '<td><button type="button" ' +
'class="btn btn-primary btn-sm" ' +
'onclick=onApplicationLoaded('+i+')>Click</button></td>';
str += '</tr>';
}
appTable.innerHTML = str;
apps = appObjList;
} else {
console.log("Cannot connect to Hadoop Application Timeline Server (ATS)");
}
};
xhr.send();
}
function init() {
var now = new Date();
var t = moment(now).format('MM/DD/YYYY HH:mm');
document.getElementById("time-until").value = t;
setQuickTimeButtons();
setRecentApplications();
extract();
}
function trans(str_time){
// %m/%d/%Y %H:%M
var time_format = /\d\d\/\d\d\/\d\d\d\d \d\d:\d\d/g;
var trimmed = str_time.trim();
if (trimmed.length != 16 || trimmed.match(time_format) == null){
return null;
}
return trimmed.replace(/\//g, "%2F").replace(" ", "+").replace(/:/g, "%3A");
}
function setTimeFromMillis(from, until) {
document.getElementById("time-from").value = moment(from).format('MM/DD/YYYY HH:mm');
document.getElementById("time-until").value = moment(until).format('MM/DD/YYYY HH:mm');
extract();
}
function setTimeFromDate(from, until) {
document.getElementById("time-from").value = moment(from).format('MM/DD/YYYY HH:mm');
document.getElementById("time-until").value = moment(until).format('MM/DD/YYYY HH:mm');
extract();
}
function setTimeFrom(minutesToSubtract) {
var now = new Date();
var from = new Date();
from.setMinutes(now.getMinutes() - minutesToSubtract);
setTimeFromDate(from, now);
}
function setImageSize(strSize) {
imageSize = strSize;
extract();
}
function extract(){
document.getElementById('placeholder').innerHTML = '';
var start = trans(document.getElementById("time-from").value);
var finish = trans(document.getElementById("time-until").value);
var ganglia_url = document.getElementById("ganglia-url").value;
var cluster_name = document.getElementById("cluster-name").value;
var str_html = "<p>";
for (metric in metrics) {
var url = ganglia_url+"/graph.php?r=custom"+
"&c="+cluster_name+
"&m="+metric+
"&x="+metrics[metric]+
"&z="+imageSize+
"&cs="+start;
if (finish != null) {
url += "&ce="+finish;
}
str_html += "<div class=\"col-xs-12 col-sm-12 col-md-12 co-lg-6\"><img src="+url+"></div>"
}
str_html += "</p>";
document.getElementById('placeholder').innerHTML = str_html;
}
</script>
<div style="height:100vh; overflow: auto;" class="col-lg-6 col-md-6 col-sm-12" align="center">
<div>
<table class="table table-striped table-bordered">
<th><h3>Ganglia</h3></th>
<tr>
<td>
<label>Ganglia address</label>
<input type="text"
class="form-control"
id="ganglia-url"
value="http://50.1.101.152/ganglia"/>
</td>
</tr>
<tr>
<td>
<label>Cluster name</label>
<input type="text"
class="form-control"
id="cluster-name"
value="unspecified">
</td>
</tr>
<tr>
<td>
<label>Image </label>
<div class="btn-group" role="group">
<button type="button" class="btn btn-default btn-warning" onclick="setImageSize('small')">small</button>
<button type="button" class="btn btn-default btn-warning" onclick="setImageSize('medium')">medium</button>
<button type="button" class="btn btn-default btn-warning" onclick="setImageSize('large')">large</button>
<button type="button" class="btn btn-default btn-warning" onclick="setImageSize('xlarge')">xlarge</button>
<button type="button" class="btn btn-default btn-warning" onclick="setImageSize('xxlarge')">xxlarge</button>
</div>
</td>
</tr>
<tr>
<td id="min-buttons">
<label>Minutes </label>
</td>
</tr>
<tr>
<td id="hr-buttons">
<label>hours </label>
</td>
</tr>
<tr>
<td id="day-buttons">
<label>Days </label>
</td>
</tr>
<tr>
<td>
<label>From</label>
<input type="text"
class="form-control"
id="time-from"
placeholder="MM/DD/YYYY HH:mm"/>
</td>
</tr>
<tr>
<td>
<label>Until</label>
<input type="text"
class="form-control"
id="time-until"
placeholder="MM/DD/YYYY HH:mm">
</td>
</tr>
<tr>
<td>
<button class="btn btn-default btn-danger btn-block"
onclick="extract()">Submit</button>
</td>
</tr>
</table>
</div>
<div>
<table class="table table-striped table-bordered">
<th><h3>Application Timeline Service (ATS)</h3></th>
<tr>
<td>
<label>Application List Limit</label>
<input type="text"
class="form-control"
id="yarn-apps-limit"
value="10"/>
</td>
</tr>
<tr>
<td>
<label>ATS Server</label>
<input type="text"
class="form-control"
id="yarn-ats"
value="http://50.1.101.152:8188"/>
</td>
</tr>
<tr>
<td>
<button class="btn btn-default btn-danger btn-block"
onclick="setRecentApplications()">Load recent YARN applications</button>
</td>
</tr>
</table>
</div>
<div style="height:300px; overflow: auto;">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Applications</th>
<th>Name</th>
<th>Status</th>
<th>From</th>
<th>Until</th>
<th>Seconds</th>
<th>Load</th>
</tr>
</thead>
<tbody id="yarn-apps-table"></tbody>
</table>
</div>
</div>
<div style="height:100vh; overflow: auto;" id="placeholder" class="col-lg-6 col-md-6 col-sm-12" align="center"> </div>
</body>
</html>