-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclusters.html
More file actions
192 lines (164 loc) · 6.93 KB
/
clusters.html
File metadata and controls
192 lines (164 loc) · 6.93 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Jarvis Bot - Cluster Status</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(135deg,#1a1a2e 0%,#16213e 50%,#0f3460 100%);
color: #fff;
margin: 0; padding: 40px 20px;
display: flex; flex-direction: column; align-items: center; min-height: 100vh;
}
h1 { font-size: 3rem; margin-bottom: 10px; text-align: center; text-transform: uppercase; letter-spacing: 2px; }
h2 { font-size: 1.2rem; color: #a3b3ff; margin-bottom: 30px; }
.system-stats-container {
display: flex; flex-wrap: wrap; justify-content: center; gap: 20px;
width: 100%; max-width: 1200px; margin-bottom: 40px;
}
.stat-box {
background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 15px 25px;
border: 1px solid rgba(114, 137, 218, 0.3); min-width: 200px; text-align: center;
}
.stat-label { color: #8892b0; font-size: 0.8rem; text-transform: uppercase; margin-bottom: 5px; }
.stat-value { font-size: 1.4rem; font-weight: bold; color: #7289da; }
/* Gauge Section */
.gauge-section {
display: flex; justify-content: center; gap: 30px; flex-wrap: wrap;
width: 100%; max-width: 1200px; margin-bottom: 40px;
}
.gauge-box {
background: rgba(26,26,46,0.95); border-radius: 12px; padding: 20px;
border: 1px solid rgba(114, 137, 218, 0.2); width: 260px; text-align: center;
position: relative; box-shadow: 0 8px 20px rgba(0,0,0,0.4);
}
.gauge-value-display {
position: absolute; bottom: 25px; left: 50%; transform: translateX(-50%);
font-size: 1.5rem; font-weight: bold;
}
.cluster-container {
display: grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr));
gap: 20px; width: 100%; max-width: 1200px;
}
.cluster-card {
background: rgba(26,26,46,0.95); border-radius: 12px; padding: 20px;
box-shadow: 0 8px 20px rgba(0,0,0,0.4); border-left: 5px solid #7289da;
}
/* Progress Bar Styling */
.progress-wrapper { width: 100%; background: #23272a; border-radius: 5px; margin-top: 10px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: #7289da; width: 0%; transition: width 0.5s ease; }
footer { margin-top: 60px; font-size: 0.9rem; color: #8892b0; }
</style>
</head>
<body>
<h1>Jarvis Discord Bot</h1>
<h2 id="sync-status">Core Interface Status: Nominal</h2>
<div class="system-stats-container">
<div class="stat-box">
<div class="stat-label">Bot RAM Usage</div>
<div class="stat-value" id="bot-ram-val">0.00 / 10 GB</div>
</div>
<div class="stat-box">
<div class="stat-label">Total System CPU</div>
<div class="stat-value" id="cpu-load-val">--%</div>
<div class="progress-wrapper"><div id="cpu-bar" class="progress-fill"></div></div>
</div>
<div class="stat-box">
<div class="stat-label">Total Servers</div>
<div class="stat-value" id="total-servers">--</div>
</div>
<div class="stat-box">
<div class="stat-label">Last Data Sync</div>
<div class="stat-value" id="sync-time" style="color: #fff; font-size: 1rem;">--:--:--</div>
</div>
</div>
<div class="gauge-section" id="gauge-area"></div>
<div class="cluster-container" id="clusters"></div>
<footer>
© 2026 Jarvis Discord Bot | System Status Nominal
</footer>
<script>
let gauges = {};
const gaugeNeedle = {
id: 'gaugeNeedle',
afterDatasetsDraw(chart) {
const { ctx, data, chartArea: { width, height } } = chart;
ctx.save();
const angle = Math.PI + (Math.PI * (data.datasets[0].data[0] / 300));
ctx.translate(width / 2, chart._metasets[0].data[0].y);
ctx.rotate(angle);
ctx.beginPath();
ctx.moveTo(0, -2); ctx.lineTo(height / 1.5, 0); ctx.lineTo(0, 2);
ctx.fillStyle = '#fff'; ctx.fill();
ctx.restore();
}
};
function createGauge(id, name, color) {
const container = document.getElementById('gauge-area');
const box = document.createElement('div');
box.className = 'gauge-box';
box.innerHTML = `<div class="stat-label">${name} Latency</div><canvas id="gauge-${id}"></canvas>
<div class="gauge-value-display" id="val-${id}" style="color:${color}">0ms</div>`;
container.appendChild(box);
const ctx = document.getElementById(`gauge-${id}`).getContext('2d');
gauges[id] = new Chart(ctx, {
type: 'doughnut',
data: {
datasets: [{
data: [0, 300], backgroundColor: [color, 'rgba(255,255,255,0.05)'],
borderWidth: 0, circumference: 180, rotation: 270,
}]
},
options: { cutout: '80%', plugins: { legend: { display: false } } },
plugins: [gaugeNeedle]
});
}
async function loadClusters() {
try {
const res = await fetch('/clusters');
const data = await res.json();
const sys = data.system_stats;
// Update Top Stats
document.getElementById('bot-ram-val').innerText = `${sys.bot_ram_gb.toFixed(2)} / 10 GB`;
document.getElementById('cpu-load-val').innerText = `${sys.cpu_total_percent}%`;
document.getElementById('cpu-bar').style.width = `${sys.cpu_total_percent}%`;
document.getElementById('sync-time').innerText = new Date().toLocaleTimeString();
let globalServers = 0;
const container = document.getElementById('clusters');
container.innerHTML = '';
data.clusters.forEach(cluster => {
globalServers += cluster.servers;
if (!gauges[cluster.shard_id]) {
const color = cluster.shard_id === 0 ? '#7289da' : '#faa61a';
createGauge(cluster.shard_id, cluster.name, color);
}
const gauge = gauges[cluster.shard_id];
gauge.data.datasets[0].data = [Math.min(cluster.latency_ms, 300), Math.max(0, 300 - cluster.latency_ms)];
gauge.update();
document.getElementById(`val-${cluster.shard_id}`).innerText = `${cluster.latency_ms}ms`;
// Density calculation: Users per Server
const density = (cluster.users / cluster.servers).toFixed(0);
const card = document.createElement('div');
card.className = `cluster-card`;
card.style.borderLeftColor = cluster.shard_id === 0 ? '#7289da' : '#faa61a';
card.innerHTML = `
<h3 style="margin:0;">${cluster.name}</h3>
<p style="font-size:0.8rem; color:#8892b0; margin: 5px 0;">Shard ${cluster.shard_id}</p>
<p><strong>Servers:</strong> ${cluster.servers.toLocaleString()}</p>
<p><strong>Users:</strong> ${cluster.users.toLocaleString()}</p>
<p><strong>Density:</strong> ${density} Users/Server (average)</p>
`;
container.appendChild(card);
});
document.getElementById('total-servers').innerText = globalServers.toLocaleString();
} catch (err) { console.error("Sync Offline"); }
}
loadClusters();
setInterval(loadClusters, 10000);
</script>
</body>
</html>