Sfoglia il codice sorgente

container metrics fix

lllllllillllllillll 1 anno fa
parent
commit
8a8d28ad8f
2 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 2 2
      functions/system.js
  2. 3 1
      public/js/main.js

+ 2 - 2
functions/system.js

@@ -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);
         }

+ 3 - 1
public/js/main.js

@@ -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`));