mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-14 05:57:32 -07:00
Fix cpu/memory stats widget
This commit is contained in:
parent
cae79a3383
commit
5639ba6863
4 changed files with 7 additions and 6 deletions
|
@ -37,6 +37,7 @@ export default function () {
|
|||
mem: {
|
||||
used: round(memStats.used - memStats.buffers - memStats.cached),
|
||||
active: round(memStats.active),
|
||||
total: round(memStats.total),
|
||||
},
|
||||
net: {
|
||||
rx: round(Math.max(0, netStats.rx_sec)),
|
||||
|
|
|
@ -84,8 +84,8 @@ const diskAvailable = $computed(() => meta.fs.total - meta.fs.used);
|
|||
function onStats(stats) {
|
||||
cpuUsage = stats.cpu;
|
||||
|
||||
memUsage = stats.mem.active / meta.mem.total;
|
||||
memTotal = meta.mem.total;
|
||||
memUsage = stats.mem.active / stats.mem.total;
|
||||
memTotal = stats.mem.total;
|
||||
memUsed = stats.mem.active;
|
||||
memFree = memTotal - memUsed;
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ function onStats(connStats) {
|
|||
]);
|
||||
const memPolylinePointsStats = stats.map((s, i) => [
|
||||
viewBoxX - (stats.length - 1 - i),
|
||||
(1 - s.mem.active / props.meta.mem.total) * viewBoxY,
|
||||
(1 - s.mem.active / s.mem.total) * viewBoxY,
|
||||
]);
|
||||
cpuPolylinePoints = cpuPolylinePointsStats
|
||||
.map((xy) => `${xy[0]},${xy[1]}`)
|
||||
|
@ -153,7 +153,7 @@ function onStats(connStats) {
|
|||
memHeadY = memPolylinePointsStats[memPolylinePointsStats.length - 1][1];
|
||||
|
||||
cpuP = (connStats.cpu * 100).toFixed(0);
|
||||
memP = ((connStats.mem.active / props.meta.mem.total) * 100).toFixed(0);
|
||||
memP = ((connStats.mem.active / connStats.mem.total) * 100).toFixed(0);
|
||||
}
|
||||
|
||||
function onStatsLog(statsLog) {
|
||||
|
|
|
@ -26,8 +26,8 @@ let usage: number = $ref(0),
|
|||
free: number = $ref(0);
|
||||
|
||||
function onStats(stats) {
|
||||
usage = stats.mem.active / props.meta.mem.total;
|
||||
total = props.meta.mem.total;
|
||||
usage = stats.mem.active / stats.mem.total;
|
||||
total = stats.mem.total;
|
||||
used = stats.mem.active;
|
||||
free = total - used;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue