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
|
<!doctype html><html><head><title>Netdata Agent Console</title><script>let pathsRegex = /\/(spaces|nodes|overview|alerts|dashboards|anomalies|events|cloud|v2)\/?.*/
let getBasename = function() {
return window.location.origin + window.location.pathname.replace(pathsRegex, "")
}
let goToOld = function(path) {
let goToUrl = getBasename() + path;
if (path === "/v2") {
let pathsRegex = /(\/(spaces|nodes|overview|alerts|dashboards|anomalies|events|cloud)\/?.*)/
if (pathsRegex.test(window.location.origin + window.location.pathname)) {
goToUrl = (window.location.origin + window.location.pathname).replace(pathsRegex, "/v2$1")
}
}
window.location.replace(ensureOneSlash(goToUrl + window.location.search))
}
let getAssetFile = function(path) {
window.location.replace(__webpack_public_path__ + path)
}
let ensureOneSlash = function(urlStr) {
return urlStr.replace(/([^:]\/)\/+/g, "$1")
}
let searchParams = new URLSearchParams(location.search)
window.envSettings = {
isAgent: true,
apiUrl: "https://app.netdata.cloud",
cloudUrl: "https://app.netdata.cloud",
demoSlug: "netdata-demo",
demoFavourites: {"postgresql":["postgres"],"redis":["redis"],"dns-query":["dns_query"],"http-endpoints":["httpcheck"],"nginx":["web_log","nginx"],"apache":["apache"],"host-reachability":["ping"],"cassandra":["cassandra"],"coredns":["coredns"],"logind":["logind"],"iis":["iis"],"active-directory":["ad"],"windows":["windows","ad","iis","mssql","exchange","netframework"],"docker":["cgroup","docker"],"ups":["upsd"]},
webpackPublicPath: "",
agentApiUrl: searchParams.get("agent") || getBasename(),
posthogToken: "phc_hnhlqe6D2Q4IcQNrFItaqdXJAxQ8RcHkPAFAp74pubv",
version: "6.138.3",
tracking: false,
cookieDomain: ".netdata.cloud",
onprem: false,
nodeEnv: "production"
}
window.visitedNodes = []
function loadStyle(url, { media, insertAfter: aref, insertBefore: bref, rel, type } = {}) {
rel = rel || 'stylesheet'
type = type || 'text/css'
return new Promise(function(resolve, reject) {
let link = document.createElement('link');
link.type = type;
link.rel = rel;
link.href = url;
link.media = media || 'all';
link.onerror = function(err) {
reject(new URIError(`loadStyle: the stylesheet ${err.target.src} is not accessible.`));
};
link.onload = function() {
resolve();
};
if (aref) {
aref.parentNode.insertBefore(link, aref.nextSibling);
return;
}
if (bref) {
bref.parentNode.insertBefore(link, bref);
return;
}
document.head.appendChild(link);
});
}
loadStyle(window.envSettings.agentApiUrl + "/v2/static/splash.css")
loadStyle(window.envSettings.agentApiUrl + "/v2/favicon.ico", {rel: "icon", type: "image/x-icon"})</script><meta name="application-name" content="netdata"/><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta charset="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/></head><body><noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N6CBMJD" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript><div id="app"><div id="agent-splash-screen" class="loading"><div class="hero"><div class="logo-container"><svg width="133" height="105" viewBox="0 0 133 105" fill="none" xmlns="http://www.w3.org/2000/svg" class="logo-blur"><path fill-rule="evenodd" clip-rule="evenodd" d="M81.697 105H55.0693L0.5 0.5H77.9598C108.079 0.554913 132.484 24.7711 132.5 54.6451C132.452 82.485 109.73 105 81.697 105Z" fill="rgba(0,171,68,0.1)"/></svg> <svg width="133" height="105" viewBox="0 0 133 105" fill="none" xmlns="http://www.w3.org/2000/svg" class="logo"><path fill-rule="evenodd" clip-rule="evenodd" d="M81.697 105H55.0693L0.5 0.5H77.9598C108.079 0.554913 132.484 24.7711 132.5 54.6451C132.452 82.485 109.73 105 81.697 105Z" fill="#DDFFEB"/></svg></div><div class="headings"><h1 class="title">Welcome to Netdata</h1><div class="loading-message"><p class="subtitle">Loading latest Netdata UI...</p><div class="flex-center">We couldn't load the latest Netdata UI. <a class="button ghost" href="javascript:location.reload();">You can try again <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18.364 8.05001L17.657 7.34301C16.318 6.00369 14.5472 5.18285 12.6598 5.02654C10.7724 4.87022 8.89077 5.38856 7.34966 6.48934C5.80855 7.59011 4.70794 9.20193 4.24365 11.038C3.77936 12.8741 3.98151 14.8153 4.81412 16.5164C5.64674 18.2174 7.05583 19.5678 8.79067 20.3275C10.5255 21.0871 12.4736 21.2067 14.2883 20.6648C16.103 20.123 17.6666 18.955 18.701 17.3685C19.7353 15.782 20.1733 13.8801 19.937 12.001M18.364 8.05001L14.121 8.05101M18.364 8.05001V3.80701" stroke="#00ab44" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg></a></div></div></div></div><div class="flex-center">Or you can load the <a class="button ghost" href="javascript:goToOld('/v1');">old single node dashboard</a> or a <a class="button ghost" href="javascript:goToOld('/v2');">local copy</a> of Netdata UI</div><div class="flex-center terms"><a href="javascript:getAssetFile('/LICENSE.md');">Netdata UI license</a></div></div></div><script>let status = {
TIMEOUT: 'timeout',
SUCCESS: 'success',
SKIPPED: 'skipped'
};
function loadScript(
url,
{ async = true, defer = false, insertAfter: aref, insertBefore: bref, timeout = 5000, attrs, skipIf } = {}
) {
return new Promise(function(resolve, reject) {
if (typeof skipIf === 'function' && skipIf()) {
resolve(status.SKIPPED);
return;
}
let rejectWithTimeout = setTimeout(function() { reject(status.TIMEOUT) }, timeout);
let script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
script.async = async;
script.defer = defer;
if (attrs) {
for (let attr in attrs) {
script.setAttribute(attr, attrs[attr]);
}
}
script.onerror = function(err) {
reject(new URIError(`loadScript: the script ${err.target.src} is not accessible.`));
};
script.onload = function() {
clearTimeout(rejectWithTimeout);
resolve(status.SUCCESS);
};
if (aref) {
aref.parentNode.insertBefore(script, aref.nextSibling);
return;
}
if (bref) {
bref.parentNode.insertBefore(script, bref);
return;
}
document.body.appendChild(script);
});
}
fetch(window.envSettings.agentApiUrl + "/api/v1/registry?action=hello", { cache: "no-cache", credentials: "include" })
.then(function(response) { return response.json() })
.then(function(data) {
let to = data.cloud_base_url.lastIndexOf('/');
to = (to == -1 || to < data.cloud_base_url.length -2) ? data.cloud_base_url.length : to;
let cloudUrl = data.cloud_base_url.substring(0, to);
window.envSettings.apiUrl = cloudUrl
cloudUrl = /api\.netdata\.cloud/.test(cloudUrl) ? "https://app.netdata.cloud" : cloudUrl
window.envSettings.cloudUrl = cloudUrl
window.envSettings.webpackPublicPath = window.envSettings.webpackPublicPath ? cloudUrl : window.envSettings.webpackPublicPath
__webpack_public_path__ = ensureOneSlash(window.envSettings.webpackPublicPath ? (window.envSettings.webpackPublicPath + "/") : (window.envSettings.agentApiUrl + "/v2/"))
window.localNetdataRegistry = {
anonymousStatistics: data.anonymous_statistics,
registry: data.registry,
isNetdataRegistry: data.registry === "https://registry.my-netdata.io",
hostname: data.hostname,
mg: data.agent.machine_guid,
nd: data.agent.node_id,
claimId: data.agent.claim_id,
cloudStatus: data.cloud_status,
xNetdataAuthHeader: data["X-Netdata-Auth"] || false
}
if ((window.localNetdataRegistry.cloudStatus === "disabled" || window.localNetdataRegistry.cloudStatus === "unavailable") && !/\/v2/.test(location.pathname)) {
goToOld("/v2")
return
}
fetch(__webpack_public_path__ + "bundlesManifest."+ window.envSettings.version.toString().replace(/(\d+)\..+/, "$1") +".json")
.then(function(response) { return response.json() })
.then(function(data) {
Object.keys(data).forEach(function(k) {
if (/\.(map|ico|html)$/.test(data[k])) return
if (/static\//.test(data[k])) return
if (/\.css.*$/.test(data[k])) {
loadStyle(ensureOneSlash(__webpack_public_path__ + data[k]))
return
}
if (/\.js.*$/.test(data[k])) {
loadScript(ensureOneSlash(__webpack_public_path__ + data[k]), {
async: false,
});
}
let el = document.getElementById('agent-splash-screen');
el.classList.remove("loading");
})
}).catch(function() {
let el = document.getElementById('agent-splash-screen');
el.classList.remove("loading");
el.classList.add("error");
});
envSettings.tracking = window.localNetdataRegistry.anonymousStatistics !== false
let withoutNodes = btoa(JSON.stringify({
registry: data.registry,
machine_guid: data.machine_guid,
hostname: data.hostname,
agent: data.agent,
nodes: []
}))
let iframe = document.createElement('iframe');
iframe.src = data.registry + "/registry-access.html?x=" + withoutNodes + "&originUrl=" + window.envSettings.agentApiUrl;
iframe.style = { position: "absolute", left: "-99999999px" };
iframe.width = 0 ;
iframe.height = 0;
iframe.tabindex = -1;
iframe.title = "empty";
iframe.classList.add("hidden");
document.body.appendChild(iframe);
setTimeout(function () {
document.title = data.hostname + ': Netdata Agent Console';
iframe.contentWindow.postMessage(["netdata-registry", window.envSettings.agentApiUrl, data], "*")
}, 300);
window.addEventListener('message', function(event) {
if (event.source !== iframe.contentWindow) return;
if (event.data.status === "disabled") console.error("Your netdata registry is disabled! Check your configuration.")
if (event.data) {
if (!window.localNetdataRegistry) {
window.localNetdataRegistry = {}
}
window.localNetdataRegistry.pg = event.data.person_guid
if (!window.envSettings) {
window.envSettings = {}
}
window.envSettings.visitor = event.data.person_guid
try {
var visitedNodesByName = event.data.urls.reduce(function (vn, visitedUrl) {
vn[visitedUrl[4]] = vn[visitedUrl[4]] || {}
vn[visitedUrl[4]].id = visitedUrl[0]
vn[visitedUrl[4]].name = visitedUrl[4]
vn[visitedUrl[4]].lastAccessTime = visitedUrl[2]
vn[visitedUrl[4]].urls = vn[visitedUrl[4]].urls || []
vn[visitedUrl[4]].urls.push(visitedUrl[1])
return vn
}, {})
window.visitedNodes = Object.keys(visitedNodesByName).map(function(vn) {
return visitedNodesByName[vn]
})
} catch(e) {
// do nothing
}
}
});
}).catch(() => {})</script></body></html>
|