container metrics fix

This commit is contained in:
lllllllillllllillll 2023-12-04 01:37:06 -08:00 committed by GitHub
parent 93ba77b4e3
commit 8a8d28ad8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -168,19 +168,19 @@ module.exports.containerList = async function () {
module.exports.containerStats = async function () {
let container_stats = [];
const data = await docker.listContainers({ all: true });
for (const container of data) {
if ((container.Names[0].slice(1) != 'DweebUI') && (container.Names[0].slice(1) != 'DweebCache')) {
const stats = await dockerContainerStats(container.Id);
let container_stat = {
name: container.Names[0].slice(1),
cpu: Math.round(stats[0].cpuPercent),
ram: Math.round(stats[0].memPercent)
}
//push stats to an array
container_stats.push(container_stat);
}

View file

@ -158,10 +158,12 @@ socket.on('cards', (data) => {
});
socket.on('container_stats', (data) => {
socket.on('containerStats', (data) => {
let {name, cpu, ram} = data;
console.log(`drawing chart for ${name}`)
var cpu_array = JSON.parse(localStorage.getItem(`${name}_cpu`));
var ram_array = JSON.parse(localStorage.getItem(`${name}_ram`));