diff --git a/html/js/monitor.js b/html/js/monitor.js
index 7a4b221..7e43a83 100644
--- a/html/js/monitor.js
+++ b/html/js/monitor.js
@@ -3,19 +3,21 @@ const apis = [
"id":"Main",
"url":"https://api.nolancasey.click/server",
"online": true,
- "failedAttempts": 0
- },
- {
- "id":"Proxy",
- "url":"https://api.nolancasey.click/proxy",
- "online": true,
- "failedAttempts": 0
+ "failedAttempts": 0,
+ "cpu": null,
+ "threads": null,
+ "ram": null,
+ "swap": null
},
{
"id":"Lightweight",
"url":"https://api.nolancasey.click/lightweight",
"online": true,
- "failedAttempts": 0
+ "failedAttempts": 0,
+ "cpu": null,
+ "threads": null,
+ "ram": null,
+ "swap": null
}
];
const colors = ["red", "green", "blue", "chartreuse", "darkmagenta", "darkkhaki", "purple", "salmon", "yellow", "blueviolet", "chocolate", "crimson", "cyan", "darkslategrey", "khaki", "hotpink"];
@@ -96,7 +98,7 @@ window.addEventListener("load", async function () {
)
}
- cpu = new Chart(api.id + "_cpu",{
+ api["cpu"] = new Chart(api.id + "_cpu",{
type: "line",
data:{
labels: labels,
@@ -135,7 +137,7 @@ window.addEventListener("load", async function () {
);
}
- threads = new Chart(api.id + "_threads", {
+ api["threads"] = new Chart(api.id + "_threads", {
type: "line",
data:{
labels: labels,
@@ -158,7 +160,7 @@ window.addEventListener("load", async function () {
});
var x = ["Used", "Free"]
- ram = new Chart(api.id + "_ram",{
+ api["ram"] = new Chart(api.id + "_ram",{
type: "doughnut",
data:{
labels: x,
@@ -182,7 +184,7 @@ window.addEventListener("load", async function () {
}
});
- swap = new Chart(api.id + "_swap",{
+ api["swap"] = new Chart(api.id + "_swap",{
type: "doughnut",
labels: x,
data:{
@@ -235,24 +237,23 @@ async function increment() {
api.failedAttempts = 0;
for (var i = 1; i < resolution; i++){
- cpu.data.datasets[0].data[i - 1] = cpu.data.datasets[0].data[i];
+ api["cpu"].data.datasets[0].data[i - 1] = api["cpu"].data.datasets[0].data[i];
}
- cpu.data.datasets[0].data[resolution - 1] = json["cpu0"];
- cpu.update();
+ api["cpu"].data.datasets[0].data[resolution - 1] = json["cpu0"];
+ api["cpu"].update();
for (var i = 0; i < json["cpuCount"]; i++){
for (var j = 1; j < resolution; j++){
- threads.data.datasets[i].data[j - 1] = threads.data.datasets[i].data[j];
+ api["threads"].data.datasets[i].data[j - 1] = api["threads"].data.datasets[i].data[j];
}
- threads.data.datasets[i].data[resolution - 1] = json["cpu" + (i + 1)];
- threads.update();
+ api["threads"].data.datasets[i].data[resolution - 1] = json["cpu" + (i + 1)];
}
- threads.update();
- ram.data.datasets[0].data[0] = json["usedRam"];
- ram.data.datasets[0].data[1] = json["totalRam"] - json["usedRam"];
- swap.data.datasets[0].data[0] = json["usedSwap"];
- swap.data.datasets[0].data[1] = json["totalSwap"] - json["usedSwap"];
- ram.update();
- swap.update();
+ api["threads"].update();
+ api["ram"].data.datasets[0].data[0] = json["usedRam"];
+ api["ram"].data.datasets[0].data[1] = json["totalRam"] - json["usedRam"];
+ api["swap"].data.datasets[0].data[0] = json["usedSwap"];
+ api["swap"].data.datasets[0].data[1] = json["totalSwap"] - json["usedSwap"];
+ api["ram"].update();
+ api["swap"].update();
}catch (error){
if (api.failedAttempts > 5){
api.online = false;