Ver Fonte

Daemon: Bugfix Sums/Avg Berechnung Drive/Mounts

Christian Kahlau há 3 anos atrás
pai
commit
a6f1b194d0
1 ficheiros alterados com 9 adições e 3 exclusões
  1. 9 3
      daemon/src/collector.class.ts

+ 9 - 3
daemon/src/collector.class.ts

@@ -184,13 +184,19 @@ export class Collector {
               res.ram.max = cur.ram.max;
 
               if (cur.hdd && Object.keys(cur.hdd).length) {
+                const hdd_sums = res.hdd ?? {};
                 res.hdd = Object.keys(cur.hdd).reduce((res_hdd, mount) => {
-                  if (!res_hdd[mount]) res_hdd[mount] = { sum: 0, peak: 0, max: 0 };
+                  Logger.debug('[DEBUG] Drive Data', cur.time, mount, JSON.stringify(cur.hdd[mount]));
+                  if (!res_hdd[mount]) {
+                    Logger.debug('[DEBUG] --- NEW SUMS', mount, ' ---');
+                    res_hdd[mount] = { sum: 0, peak: 0, max: 0 };
+                  }
                   res_hdd[mount].sum += cur.hdd[mount].used;
                   res_hdd[mount].peak = Math.max(res_hdd[mount].peak, cur.hdd[mount].used);
-                  res_hdd[mount].max += cur.hdd[mount].max;
+                  res_hdd[mount].max = cur.hdd[mount].max;
+                  Logger.debug('[DEBUG] Drive Sums', cur.time, mount, JSON.stringify(res_hdd[mount]));
                   return res_hdd;
-                }, {} as IntermediateDriveData);
+                }, hdd_sums);
               }
 
               return res;