From 1829662562408e424f9ec4b6e005239162703e1f Mon Sep 17 00:00:00 2001 From: XK4MiLX <62837435+XK4MiLX@users.noreply.github.com> Date: Sat, 5 Oct 2024 20:27:51 +0200 Subject: [PATCH] add logs, monitoring interval 3min --- ZelBack/src/services/appsService.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ZelBack/src/services/appsService.js b/ZelBack/src/services/appsService.js index f3580ba32..001f81fa1 100644 --- a/ZelBack/src/services/appsService.js +++ b/ZelBack/src/services/appsService.js @@ -1255,14 +1255,14 @@ function startAppMonitoring(appName) { appsMonitored[appName].statsStore.push({ timestamp: now, data: statsNow }); const statsStoreSizeInBytes = new TextEncoder().encode(JSON.stringify(appsMonitored[appName].statsStore)).length; const estimatedSizeInMB = statsStoreSizeInBytes / (1024 * 1024); - log.info(`Estimated size of statsStore over 7 days: ${estimatedSizeInMB.toFixed(2)} MB`); + log.info(`Size of stats for ${appName}: ${estimatedSizeInMB.toFixed(2)} MB`); appsMonitored[appName].statsStore = appsMonitored[appName].statsStore.filter( (stat) => now - stat.timestamp <= 7 * 24 * 60 * 60 * 1000, ); } catch (error) { log.error(error); } - }, 1 * 60 * 1000); + }, 3 * 60 * 1000); } } @@ -9682,7 +9682,7 @@ async function checkApplicationsCpuUSage() { stats = appsMonitored[app.name].statsStore; // eslint-disable-next-line no-await-in-loop const inspect = await dockerService.dockerContainerInspect(app.name); - if (inspect && stats.length > 55) { + if (inspect && stats.length > 19) { const nanoCpus = inspect.HostConfig.NanoCpus; let cpuThrottling = true; const cpuUsage = averageStats.avgCpuUsageDiff; @@ -9692,7 +9692,7 @@ async function checkApplicationsCpuUSage() { if (realCpu < 92) { cpuThrottling = false; } - log.info(`CPU usage: ${realCpu}%`); + log.info(`CPU usage: ${realCpu.toFixed(2)}%`); log.info(`checkApplicationsCpuUSage ${app.name} cpu high load: : ${cpuThrottling}`); if (cpuThrottling && app.cpu > 1) { if (nanoCpus / app.cpu / 1e9 === 1) { @@ -9718,7 +9718,7 @@ async function checkApplicationsCpuUSage() { const averageStats = getAverageCpuUsage(`${appComponent.name}_${app.name}`); // eslint-disable-next-line no-await-in-loop const inspect = await dockerService.dockerContainerInspect(`${appComponent.name}_${app.name}`); - if (inspect && stats.length > 55) { + if (inspect && stats.length > 19) { const nanoCpus = inspect.HostConfig.NanoCpus; let cpuThrottling = true; const cpuUsage = averageStats.avgCpuUsageDiff; @@ -9728,7 +9728,7 @@ async function checkApplicationsCpuUSage() { if (realCpu < 92) { cpuThrottling = false; } - log.info(`CPU usage: ${realCpu}%`); + log.info(`CPU usage: ${realCpu.toFixed(2)}%`); log.info(`checkApplicationsCpuUSage ${appComponent.name}_${app.name} cpu high load: : ${cpuThrottling}`); if (cpuThrottling && appComponent.cpu > 1) { if (nanoCpus / appComponent.cpu / 1e9 === 1) {