MCPcopy Create free account
hub / github.com/cppla/ServerStatus / resourceMeter

Function resourceMeter

web/js/app.js:283–296  ·  view source on GitHub ↗
(label, value, pct, kind)

Source from the content-addressed store, hash-verified

281 </div>`;
282}
283function resourceMeter(label, value, pct, kind){
284 const safePct = clamp(num(pct), 0, 100);
285 const thresholds = {
286 cpu: { warn: 75, bad: 90 },
287 mem: { warn: 80, bad: 90 },
288 swap: { warn: 80, bad: 90 },
289 hdd: { warn: 85, bad: 90 }
290 }[kind] || { warn: 75, bad: 90 };
291 const level = safePct >= thresholds.bad ? 'bad' : (safePct >= thresholds.warn ? 'warn' : 'ok');
292 return `<div class="resource-meter" data-kind="${esc(kind)}" data-level="${level}" style="--p:${safePct.toFixed(1)}%">
293 <div class="resource-meter-head"><span>${esc(label)}</span><strong>${esc(value)}</strong></div>
294 <div class="resource-track"><i></i></div>
295 </div>`;
296}
297function detailResourceHTML(s, m){
298 const swapPct = s.swap_total ? num(s.swap_used) / num(s.swap_total) * 100 : 0;
299 return `

Callers 1

detailResourceHTMLFunction · 0.85

Calls 3

clampFunction · 0.85
numFunction · 0.85
escFunction · 0.85

Tested by

no test coverage detected