forked from hardcpp/P2PoolExtendedFrontEnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminers.html
502 lines (443 loc) · 24.3 KB
/
miners.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>P2Pool - Active Miners</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<script type="text/javascript" src="d3.v2.min.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/jquery.jqplot.min.css" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script language="javascript" type="text/javascript" src="js/jquery.jqplot.min.js"></script>
<script class="include" language="javascript" type="text/javascript" src="js/jqplot.pieRenderer.min.js"></script>
<style>
body {
padding-top: 60px;
}
line {
stroke: black;
stroke-width: 1;
shape-rendering: crispEdges;
}
.plotline {
stroke-width: 1.4;
fill: none;
}
text {
font-family: Sans-serif;
font-size: 12px;
}
</style>
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<script>
function ChangeCurrentPeriod(p_Period, p_Sender)
{
period=p_Period;
$('#scale_menu li').removeClass('active');
$('#' + p_Sender).addClass('active');
document.location.href = "?" + period;
}
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="/">P2Pool (<span class="symbol upper"></span>)</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="index.html">Stats</a></li>
<li class="active"><a href="miners.html">Miner Graphs</a></li>
<li><a href="graphs.html">Graph</a></li>
<li><a id="mailto" href="">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<center>
<div class="navbar" style="width: 460px;">
<div class="navbar-inner">
<a class="brand" href="javascript:void(0)">Scale</a>
<ul class="nav" id="scale_menu">
<li id="scaleHour"class="active"><a href="javascript:ChangeCurrentPeriod('Hour', 'scaleHour');">Hour</a></li>
<li id="scaleDay"><a href="javascript:ChangeCurrentPeriod('Day', 'scaleDay');">Day</a></li>
<li id="scaleWeek"><a href="javascript:ChangeCurrentPeriod('Week', 'scaleWeek');">Week</a></li>
<li id="scaleMonth"><a href="javascript:ChangeCurrentPeriod('Month', 'scaleMonth');">Month</a></li>
<li id="scaleYear"><a href="javascript:ChangeCurrentPeriod('Year', 'scaleYear');">Year</a></li>
</ul>
</div>
</div>
</center>
<script>
period = window.location.search.substr(1);
$('#scale_menu li').removeClass('active');
$('#scale' + period).addClass('active');
d3.json('/web/currency_info', function(currency_info) {
d3.selectAll('.symbol').text(currency_info.symbol);
});
</script>
<p style="display: none">Periods: <span id="period_chooser"></span> Current: <span id="period_current"></span></p>
<div id="warnings"></div>
<center>
<br/>
<div class="well" style="width:1000px">
<h2>Miners</h2>
<div id="miners"></div>
</div>
<br/>
</div>
</center>
<script type="text/javascript">
function compose() {
var funcs = arguments;
return function(x) {
for(var i = funcs.length-1; i >= 0; i--) {
x = funcs[i](x);
}
return x;
}
}
function itemgetter(i) { return function(x) { return x[i]; } }
function as_date(x) { return new Date(1000*x); }
function not_null(x) { return x != null; }
function get_area_mean(data) {
var top = 0;
var bottom = 0;
for(var i = 0; i < data.length; i++) {
if(data[i][1] == null) continue; // no data for bin
top += data[i][1] * data[i][2];
bottom += data[i][2];
}
return {"area": top, "mean": bottom==0?null:top/bottom};
}
function plot(g, unit, total_unit, lines, stack) {
// lines is a list of objects which have attributes data, color, and label
var table_div = document.createElement("div");
g.node().parentNode.insertBefore(table_div, g.node().nextSibling);
table_div.style.display = "none";
var showhide = document.createElement("p");
g.node().parentNode.insertBefore(showhide, g.node().nextSibling);
d3.select(showhide).append("a")
.text('Show/hide table')
.on('click', function() { table_div.style.display = table_div.style.display == "block" ? "none" : "block" })
.attr("style", "color:blue;text-decoration:underline;cursor:pointer");
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var table_sel = d3.select(table_div).append('table').attr('border', 1).attr('style', 'float:left');
var first_tr = table_sel.insert('tr');
first_tr.append('th').text('Date');
first_tr.append('th').text(line.label + '/(' + unit + ')');
var new_data = []
for(var j = 0; j < line.data.length; ++j)
if(j % 7 == 3)
new_data.push(line.data[j]);
var tr = table_sel.selectAll().data(new_data).enter().append('tr');
tr.append('td').text(function(datum){return new Date(1000*datum[0]).toString()});
tr.append('td').text(function(datum){return d3.format(".3s")(datum[1])});
}
d3.select(table_div).append('div').attr('style', 'clear:both');
d3.select(table_div).append('p').append("a")
.text('Show/hide table')
.on('click', function() { table_div.style.display = table_div.style.display == "block" ? "none" : "block" })
.attr("style", "color:blue;text-decoration:underline;cursor:pointer");
var w = 1000;
var h = 300;
var margin_v = 40;
var margin_h = 140;
var x = d3.time.scale().domain([
as_date(d3.min(lines, function(line) { return d3.min(line.data, itemgetter(0)); })),
as_date(d3.max(lines, function(line) { return d3.max(line.data, itemgetter(0)); }))
]).range([0 + margin_h, w - margin_h]);
g.attr("width", w).attr("height", h);
g.selectAll("*").remove();
if(stack) {
var data = d3.layout.stack()
.x(itemgetter(0))
.y(itemgetter(1))
.values(function(line){ return line.data })
(lines);
var y = d3.scale.linear().domain([
0,
d3.max(data, function(d) { return d3.max(d.data, function(d) { return d.y0 + d.y; }) })
]).range([h - margin_v, margin_v]);
var y_abs = d3.scale.linear().domain([0, 1]).range([h - margin_v, margin_v]);
g.selectAll().data(lines).enter().append("svg:path")
.attr("d", function(line){
return d3.svg.area()
.x(function(d) { return x(as_date(d[0])) })
.y0(function(d) { return y(d.y0) })
.y1(function(d) { return y(d.y0 + d.y) })
.defined(compose(not_null, itemgetter(1)))
(line.data)
})
.style("fill", function(line){return line.color})
.attr("stroke", function(line){return line.color})
.attr("class", "plotline");
var total = 0;
var total_area = 0;
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var stats = get_area_mean(line.data);
if(stats.mean != null) {
total += stats.mean;
total_area += stats.area;
}
}
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var stats = get_area_mean(line.data);
if(stats.mean != null) {
var num = 0;
var denom = 0;
for(var j = 0; j < line.data.length; j++)
if(line.data[j] != null) {
var d = line.data[j];
num += (d.y+1)*((d.y0 + d.y) + (d.y0))/2;
denom += (d.y+1);
}
g.append("svg:line")
.style("stroke", line.color)
.attr("x1", w - margin_h + 3)
.attr("y1", y(num/denom))
.attr("x2", w - margin_h + 10)
.attr("y2", y_abs(i/lines.length));
g.append("svg:text")
.text(line.label + " (mean: " + d3.format(".3s")(stats.mean) + unit + ")")
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y_abs(i/lines.length));
if(total_unit != null)
g.append("svg:text")
.text("Area: " + d3.format(".3s")(stats.area) + total_unit + " (" + d3.format(".2p")(stats.area/total_area) + " total)")
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y_abs(i/lines.length) + 12);
}
}
g.append("svg:line")
.style("stroke", "black")
.attr("x1", w - margin_h + 3)
.attr("y1", y(total))
.attr("x2", w - margin_h + 10)
.attr("y2", y_abs(1));
g.append("svg:text")
.text("Total (mean: " + d3.format(".3s")(total) + unit + ")")
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", "black")
.attr("x", w - margin_h + 10)
.attr("y", y_abs(1));
if(total_unit != null)
g.append("svg:text")
.text("Area: " + d3.format(".3s")(total_area) + total_unit)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", "black")
.attr("x", w - margin_h + 10)
.attr("y", y_abs(1) + 12);
} else {
var y = d3.scale.linear().domain([
0,
d3.max(lines, function(line) { return d3.max(line.data, itemgetter(1)); } )
]).range([h - margin_v, margin_v]);
g.selectAll().data(lines).enter().append("svg:path")
.attr("d", function(line) {
return d3.svg.line()
.x(compose(x, as_date, itemgetter(0)))
.y(compose(y, itemgetter(1)))
.defined(compose(not_null, itemgetter(1)))
(line.data)
})
.style("stroke", function(line) { return line.color })
.attr("class", "plotline");
for(var i = 0; i < lines.length; ++i) {
var line = lines[i];
var stats = get_area_mean(line.data);
if(stats.mean != null) {
g.append("svg:text")
.text(line.label)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y(stats.mean) - 12);
g.append("svg:text")
.text("-Mean: " + d3.format(".3s")(stats.mean) + unit)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h)
.attr("y", y(stats.mean));
if(total_unit != null)
g.append("svg:text")
.text("Area: " + d3.format(".3s")(stats.area) + total_unit)
.attr("text-anchor", "start")
.attr("dominant-baseline", "central")
.attr("fill", line.color)
.attr("x", w - margin_h + 10)
.attr("y", y(stats.mean) + 12);
}
}
}
// x axis
g.append("svg:line")
.attr("x1", margin_h)
.attr("y1", h - margin_v)
.attr("x2", w - margin_h)
.attr("y2", h - margin_v);
g.selectAll()
.data(x.ticks(13))
.enter().append("svg:g")
.attr("transform", function(d) { return "translate(" + x(d) + "," + (h-margin_v/2) + ")"; })
.append("svg:text")
.attr("transform", "rotate(45)")
.attr("text-anchor", "middle")
.attr("dominant-baseline", "central")
.text(x.tickFormat(13));
g.selectAll()
.data(x.ticks(13))
.enter().append("svg:line")
.attr("x1", x)
.attr("y1", h - margin_v)
.attr("x2", x)
.attr("y2", h - margin_v + 5);
// y axis
g.append("svg:line")
.attr("x1", margin_h)
.attr("y1", h - margin_v)
.attr("x2", margin_h)
.attr("y2", margin_v);
g.selectAll()
.data(y.ticks(6))
.enter().append("svg:line")
.attr("x1", margin_h - 5)
.attr("y1", y)
.attr("x2", margin_h)
.attr("y2", y);
g.selectAll()
.data(y.ticks(6))
.enter().append("svg:text")
.text(compose(function(x) { return x + unit; }, d3.format(".2s")))
.attr("x", margin_h/2)
.attr("y", y)
.attr("dominant-baseline", "central")
.attr("text-anchor", "middle");
}
function plot_later(g, unit, total_unit, lines, stack) { // takes lines with url attribute instead of data attribute
var callbacks_left = lines.length;
lines.map(function(line) {
d3.json(line.url, function(line_data) {
line.data = line_data;
callbacks_left--;
if(callbacks_left == 0)
plot(g, unit, total_unit, lines, stack);
});
});
}
function data_to_lines(data, sort_key) {
var vers = {}; for(var i = 0; i < data.length; ++i) if(data[i][1] != null) for(var v in data[i][1]) if(data[i][1][v] != data[i][3]) vers[v] = null;
var verlist = []; for(var v in vers) verlist.push(v);
verlist.sort();
lines = [];
for(var i = 0; i < verlist.length; i++) {
lines.push({
data: data.map(function(d){ return [d[0], d[1] == null ? null : (verlist[i] in d[1] ? d[1][verlist[i]] : d[3]), d[2]] }),
color: d3.hsl(i/verlist.length*360, 0.5, 0.5),
label: verlist[i]
});
}
if(sort_key == undefined)
var sort_key = function(x) { return d3.max(x.data, function(d){ return d[1] }) }
lines.sort(function(a, b){ return sort_key(a) - sort_key(b) });
return lines;
}
function change_period(period, currency_info) {
d3.select("#period_current").text(period);
var lowerperiod = period.toLowerCase();
plot_later(d3.select("#local"), "H/s", "H", [
{"url": "/web/graph_data/local_hash_rate/last_" + lowerperiod, "color": "#0000FF", "label": "Total"},
{"url": "/web/graph_data/local_dead_hash_rate/last_" + lowerperiod, "color": "#FF0000", "label": "Dead"}
]);
plot_later(d3.select("#local_shares"), "H/s", "H", [
{"url": "/web/graph_data/local_share_hash_rate/last_" + lowerperiod, "color": "#0000FF", "label": "Total"},
//{"url": getData("/web/graph_data/local_dead_share_hash_rate/last_" + lowerperiod, "color": "#FF0000", "label": "Dead"}
]);
plot_later(d3.select("#payout"), currency_info.symbol, null, [
{"url": "/web/graph_data/current_payout/last_" + lowerperiod, "color": "#0000FF"}
]);
d3.json("/web/graph_data/pool_rates/last_" + lowerperiod, function(data) {
plot(d3.select('#pool'), 'H/s', 'H', data_to_lines(data), true);
});
plot_later(d3.select("#peers"), "", null, [
{"url": "/web/graph_data/outgoing_peers/last_" + lowerperiod, "color": "#FF0000", "label": "Outgoing"},
{"url": "/web/graph_data/incoming_peers/last_" + lowerperiod, "color": "#0000FF", "label": "Incoming"}
], true);
d3.json("/web/graph_data/miner_hash_rates/last_" + lowerperiod, function(data) {
d3.json("/web/graph_data/miner_dead_hash_rates/last_" + lowerperiod, function(dead_data) {
d3.json("/web/graph_data/current_payouts/last_" + lowerperiod, function(current_payouts) {
var users = {}; for(var i = 0; i < data.length; ++i) for(var u in data[i][1]) users[u] = null; for(var i = 0; i < dead_data.length; ++i) for(var u in dead_data[i][1]) users[u] = null;
var userlist = []; for(var u in users) userlist.push(u);
userlist.sort();
d3.select("#miners").selectAll("*").remove();
var div = d3.select("#miners").selectAll().data(userlist).enter().append("div");
div.append("h3").text(function(u) { return u });
div.append("svg:svg").each(function(u) {
plot(d3.select(this), "H/s", "H", [
{"data": data.map(function(d){ return [d[0], u in d[1] ? d[1][u] : d[3], d[2]] }), "color": "#0000FF", "label": "Total"},
{"data": dead_data.map(function(d){ return [d[0], u in d[1] ? d[1][u] : d[3], d[2]] }), "color": "#FF0000", "label": "Dead"}
]);
});
div.append("svg:svg").each(function(u) {
plot(d3.select(this), currency_info.symbol, null, [
{"data": current_payouts.map(function(d){ return [d[0], u in d[1] ? d[1][u] : d[3], d[2]] }), "color": "#0000FF"}
]);
});
});
});
});
d3.json("/web/graph_data/desired_version_rates/last_" + lowerperiod, function(data) {
plot(d3.select('#desired_version_rates'), 'H/s', 'H', data_to_lines(data, function(line){ return parseInt(line.label) }), true);
});
d3.json("/web/graph_data/traffic_rate/last_" + lowerperiod, function(data) {
plot(d3.select('#traffic_rate'), 'B/s', 'B', data_to_lines(data, function(line){ return parseInt(line.label) }), true);
});
plot_later(d3.select("#getwork_latency"), "s", null, [
{"url": "/web/graph_data/getwork_latency/last_" + lowerperiod, "color": "#FF0000", "label": "Getwork Latency"}
], false);
plot_later(d3.select("#memory_usage"), "B", null, [
{"url": "/web/graph_data/memory_usage/last_" + lowerperiod, "color": "#FF0000", "label": "Memory Usage"}
], false);
}
d3.json('/local_stats', function(local_stats) {
d3.select('#warnings').selectAll().data(local_stats.warnings).enter().append('p')
.text(function(w){ return 'Warning: ' + w })
.attr('style', 'color:red;border:1px solid red;padding:5px');
})
periods = ["Hour", "Day", "Week", "Month", "Year"];
d3.select("#period_chooser").selectAll().data(periods).enter().append("a")
.text(function(period) { return period })
.attr('href', function(period){ return "?" + period })
.attr("style", function(d, i) { return (i == 0 ? "" : "margin-left:.4em;") + "color:blue;text-decoration:underline;cursor:pointer" });
period = window.location.search.substr(1);
if(period.length < 3) {
window.location.search = "Day";
} else {
d3.json('/web/currency_info', function(currency_info) {
change_period(period, currency_info);
});
}
</script>
</body>
</html>