-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrent_load.html
319 lines (278 loc) · 8.35 KB
/
current_load.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
<!DOCTYPE HTML>
<html>
<head>
<style>
html {
height: 100%;
}
body {
height: 100%;
overflow: hidden; /*makes the body non-scrollable (we will add scrolling to the sidebar and main content containers)*/
margin: 0px; /*removes default style*/
display: flex; /*enables flex content for its children*/
box-sizing: border-box;
}
.column {
height: 100%; /*allows both columns to span the full height of the browser window*/
display: flex;
flex-direction: column; /*places the left and right headers above the bottom content*/
overflow-x: auto;
}
#left {
flex-shrink: 1;
max-width: 600px;
min-width: 350px;
}
.top-left {
flex-shrink: 0;
}
.bottom {
flex-grow: 1; /*ensures that the container will take up the full height of the parent container*/
overflow-y: auto; /*adds scroll to this container*/
margin: 5px;
}
/* Content styling */
img {
max-width: 100%;
max-height: 100%;
border-radius: 3px;
margin-bottom: 5px;
position: center;
}
p {
font-family: sans-serif;
font-size: 15px;
}
#header-div {
font-family: sans-serif;
font-size: 30px;
margin: 10px;
}
#moreinfo, #timestamp {
font-family: sans-serif;
font-size: 15px;
margin-bottom: 10px;
}
/* Progress bars stylings */
.ui-progressbar {
position: relative;
border-radius: 3px;
border: 2px solid black;
}
#loadbar {
background: #777;
height: 50px;
margin-bottom: 10px;
}
#memorybar {
background: #777;
height: 22px;
margin-bottom: 5px;
}
#cpubar {
background: #777;
height: 22px;
margin-bottom: 5px;
}
.ui-progressbar .ui-progressbar-value {
height: 100%;
border-radius: 3px;
}
.load-label {
position: absolute;
text-align: center;
width: 100%;
font-family: sans-serif;
font-size: 45px;
color: white;
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
.memory-label, .cpu-label {
position: absolute;
text-align: center;
width: 100%;
font-family: sans-serif;
font-size: 18px;
color: white;
text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(function() {
var loadbar = $("#loadbar");
var progressLabel = $(".load-label");
// Load bar
loadbar.progressbar({
value: false,
change: function() {
var val = loadbar.progressbar("value");
progressLabel.text("Load: " + val + "%");
var col = "white"
if (val > 80) {
col = "#920000"
} else if (val > 60) {
col = "#924900"
} else if (val > 40) {
col = "#db9500"
} else if (val > 20) {
col = "#24ff24"
} else {
col = "#ffff6d"
}
$(this).find('.ui-widget-header').css({ 'background': col });
}
});
//memorybar
var memorybar = $("#memorybar");
var memoryLabel = $(".memory-label");
memorybar.progressbar({
value: false,
change: function() {
var val = memorybar.progressbar("value");
var col = "white"
if (val > 80) {
col = "#920000"
} else if (val > 60) {
col = "#924900"
} else if (val > 40) {
col = "#db9500"
} else if (val > 20) {
col = "#24ff24"
} else {
col = "#ffff6d"
}
$(this).find('.ui-widget-header').css({
'background': col
});
}
});
//cpubar
var cpubar = $("#cpubar");
var cpuLabel = $(".cpu-label");
cpubar.progressbar({
value: false,
change: function() {
var val = cpubar.progressbar("value");
var col = "white"
if (val > 80) {
col = "#920000"
} else if (val > 60) {
col = "#924900"
} else if (val > 40) {
col = "#db9500"
} else if (val > 20) {
col = "#24ff24"
} else {
col = "#ffff6d"
}
$(this).find('.ui-widget-header').css({
'background': col
});
}
});
// Make the request to get the JSON data
var getJSON = function(url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status === 200) {
callback(null, xhr.response);
} else {
callback(status, xhr.response);
}
};
xhr.send();
};
function timerfn() {
//TODO: put this url in a easy to change variable
getJSON('http://my.slurm-rest-api.url/nodes',
function(err, json_data) {
if (err !== null) {
console.log('Something went wrong! Tell a developer: ' + err);
} else {
var data = json_data.data;
var num_nodes = 0;
var cpu_used = 0;
var cpu_total = 0;
var mem_used = 0;
var mem_total = 0;
var node_per = 0;
_.each(data, function(node, key){
if(node['state'] != "DOWN*"){
num_nodes++;
cpu_used += node['alloc_cpus'];
cpu_total += node['cpus'];
mem_used += node['alloc_mem'];
mem_total += node['real_memory'];
var cpu_per = node['alloc_cpus'] / node['cpus']
var mem_per = node['alloc_mem'] / node['real_memory']
var this_per = 0;
if (cpu_per > mem_per) {
this_per = cpu_per;
} else {
this_per = mem_per;
}
node_per += this_per;
}
});
node_per = node_per / num_nodes * 100;
var mem_per = mem_used / mem_total * 100;
var cpu_per = cpu_used / cpu_total * 100;
var alltext = "" + num_nodes +", "+node_per+", "+cpu_used+", "+cpu_total+", "+mem_used+", "+mem_total+", ";
loadbar.progressbar("value", Math.round(node_per * 100) / 100 );
memorybar.progressbar("value", Math.round(mem_per * 100) / 100 );
memoryLabel.text("Memory: " + Math.round(mem_used/1000) + "GB / " + Math.round(mem_total/1000) + "GB Used");
cpubar.progressbar("value", Math.round(cpu_per * 100) / 100 );
cpuLabel.text("CPU: " + cpu_used + " / " + cpu_total + " Used");
var div_time = document.getElementById('timestamp');
var d = new Date();
div_time.innerHTML = "↻ Last Updated: " + d.toString();
}
});
}
window.onload = function() {
var div_time = document.getElementById('timestamp');
div_time.style.cursor = 'pointer';
div_time.onclick = function() {
timerfn();
}
timerfn();
setInterval(timerfn, 3 * 60 * 1000);
}
});
});
</script>
</head>
<body>
<div id="left" class="column">
<div class="top-left"><div id="header-div">Cluster Status</div></div>
<div class="bottom">
<div class="load_container">
<img src="image.jpg">
<div id="loadbar">
<div class="load-label"></div>
</div>
<div id="memorybar">
<div class="memory-label"></div>
</div>
<div id="cpubar">
<div class="cpu-label"></div>
</div>
<div id="moreinfo">
<a target="_blank" class="reference" href="node_status.html">Click Here For More Detailed Cluster Node Information</a>
<br>
<a target="_blank" class="reference" href="graphs.html">Click Here For Graphs on Load History</a>
</div>
<div id="timestamp">↻ Last Updated...</div>
<br/>
</div>
</div>
</div>
</body>
</html>