-
Notifications
You must be signed in to change notification settings - Fork 17
/
status.html
231 lines (191 loc) · 6.68 KB
/
status.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
<html>
<head>
<meta charset="UTF-8">
<title>Validators Status</title>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
</head>
<link rel="stylesheet" href="main.css">
<style>
.note {
margin-top: 100px;
color: #aaa;
}
#counts {
color: #444;
margin-bottom: 20px;
}
table {
color: #444;
font-size: 12px;
}
.grey {
/*color: #f38020;*/
color: #aaa;
font-weight: 900;
}
.green {
color: #46a46c;
font-weight: 900;
}
.orange {
color: #FF8C00;
font-weight: 900;
}
.red {
color: #CD4C47;
font-weight: 900;
}
.mono {
font-family: monospace;
font-size: 12px;
color: #0088cc;
}
th, td {
text-align: left;
padding-left: 20px;
padding-right: 20px;
padding-top: 20px;
padding-bottom: 20px;
border-bottom: 1px solid #eee;
}
th {
padding-bottom: 10px;
color: #444;
}
.td-right {
text-align: right;
}
</style>
<body>
<center>
<h1 style="margin-top: 50px; margin-bottom: 100px">Validators Status</h1>
<div id="counts">
</div>
<table id="validator-table">
</table>
<div class="note">Note: data on this page is self reported by validators. It can be forged and must not be
trusted.
</div>
<div style="text-align: center; margin-top: 100px">
<img src="logo.png" style="width: 32px; pointer-events: none">
</div>
</center>
<script>
function updateTable(data) {
console.log(data);
var table = document.getElementById('validator-table');
var tableInnerHTML = "";
function addTr(status, statusClass, addr, weight, efficiency, mr, wr, stake, lag, cpuLoad, tonRevision, mytonctrlRevision) {
tableInnerHTML += "<tr>";
tableInnerHTML += `<td class='${statusClass}'>${status}</td>`
tableInnerHTML += `<td class="mono">${addr}</td>`
tableInnerHTML += `<td class="td-right">${weight}</td>`
tableInnerHTML += `<td class="td-right">${efficiency}</td>`
tableInnerHTML += `<td class="td-right">${mr}</td>`
tableInnerHTML += `<td class="td-right">${wr}</td>`
tableInnerHTML += `<td class="td-right">${stake}</td>`
tableInnerHTML += `<td class="td-right">${lag}</td>`
tableInnerHTML += `<td class="td-right">${cpuLoad}</td>`
tableInnerHTML += `<td class="td-right">${tonRevision}</td>`
tableInnerHTML += `<td class="td-right">${mytonctrlRevision}</td>`
tableInnerHTML += "</tr>";
}
function formatRevision(rev) {
if (!rev) return '-';
return rev.substring(0, 6);
}
tableInnerHTML = `<tr>
<th>Status</th>
<th>Validator ADNL</th>
<th class="td-right">Weight, %</th>
<th class="td-right">Efficiency, %</th>
<th class="td-right">mr</th>
<th class="td-right">wr</th>
<th class="td-right">Stake</th>
<th class="td-right">Lag, sec</th>
<th class="td-right">CPU load</th>
<th class="td-right">TON rev.</th>
<th class="td-right">MyTonCtrl rev.</th>
</tr>`;
var statusToCount = {};
var statusToWeight = {};
let weight_sum = 0;
for (r of data.current) {
weight_sum += r.weight;
}
for (r of data.current) {
let status;
let statusClass;
let lag = '-';
let cpuLoad = '-';
if (r.stats) {
if (!r.stats.validatorStatus?.isWorking) {
status = 'Issues';
statusClass = 'red';
} else {
if (r.stats.validatorStatus?.lag < 45) {
status = 'Working';
statusClass = 'green';
} else {
status = 'Issues';
statusClass = 'red';
}
lag = r.stats.validatorStatus?.lag?.toFixed(3);
}
cpuLoad = r.stats.cpuLoad[0] + " / " + r.stats.cpuLoad[1] + " / " + r.stats.cpuLoad[2];
} else {
status = 'Not reported';
statusClass = 'grey';
}
const weightNum = (r.weight / weight_sum * 100);
const weight = weightNum.toFixed(3) + " %";
efficiency = r.efficiency + " %"
mr = 0;
wr = 0;
if(r.mr && r.wr) {
mr = r.mr.toFixed(2);
wr = r.wr.toFixed(2);
}
if (r.efficiency && r.efficiency < 30) {
status = 'Issues';
statusClass = 'red';
} else if (mr < 0.1 || wr < 0.1) {
statusClass = 'orange';
}
if (!statusToCount[status]) {
statusToCount[status] = 0;
}
statusToCount[status]++;
if (!statusToWeight[status]) {
statusToWeight[status] = 0;
}
statusToWeight[status] += weightNum;
addTr(status, statusClass, r.adnlAddr, weight, efficiency, mr, wr, r.stats?.stake || '-', lag, cpuLoad,
(r.stats?.engine || '-') + ' ' + formatRevision(r.stats?.gitHashes?.validator),
formatRevision(r.stats?.gitHashes?.mytonctrl));
}
table.innerHTML = tableInnerHTML;
var countsInnerHTML = '';
for (var status in statusToCount) {
countsInnerHTML += status + ': ' + statusToCount[status] + ' (' + statusToWeight[status].toFixed(3) + '%) , '
}
document.getElementById('counts').innerHTML = countsInnerHTML.substr(0, countsInnerHTML.length - 2);
};
function update() {
var oReq = new XMLHttpRequest();
oReq.addEventListener("load", data => {
console.log(data);
updateTable(JSON.parse(data.target.responseText));
});
oReq.open("GET", "https://toncenter.com/api/newton_test/status/network_health");
oReq.send();
}
update();
setInterval(30000, update);
</script>
</body>
</html>