container metrics fix
This commit is contained in:
parent
93ba77b4e3
commit
8a8d28ad8f
2 changed files with 5 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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`));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue