Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RunOnFluxBot committed Oct 10, 2024
1 parent 499b60c commit fbf35c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -9665,6 +9665,7 @@ async function checkApplicationsCpuUSage() {
// cpu was high on 80% of the checks
cpuThrottling = true;
}
appsMonitored[app.name].lastHourstatsStore = [];
log.info(`checkApplicationsCpuUSage ${app.name} cpu high load: ${cpuThrottling}`);
log.info(`checkApplicationsCpuUSage ${cpuPercentage}`);
if (cpuThrottling && app.cpu > 1) {
Expand All @@ -9677,28 +9678,23 @@ async function checkApplicationsCpuUSage() {
await dockerService.appDockerUpdateCpu(app.name, Math.round(app.cpu * 1e9 * 0.9));
}
log.info(`checkApplicationsCpuUSage ${app.name} lowering cpu.`);
appsMonitored[app.name].lastHourstatsStore = [];
}
} else if (cpuPercentage <= 0.8) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(app.name, Math.round(app.cpu * 1e9 * 0.85));
log.info(`checkApplicationsCpuUSage ${app.name} increasing cpu 85.`);
appsMonitored[app.name].lastHourstatsStore = [];
} else if (cpuPercentage <= 0.85) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(app.name, Math.round(app.cpu * 1e9 * 0.9));
log.info(`checkApplicationsCpuUSage ${app.name} increasing cpu 90.`);
appsMonitored[app.name].lastHourstatsStore = [];
} else if (cpuPercentage <= 0.9) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(app.name, Math.round(app.cpu * 1e9 * 0.95));
log.info(`checkApplicationsCpuUSage ${app.name} increasing cpu 95.`);
appsMonitored[app.name].lastHourstatsStore = [];
} else if (cpuPercentage < 1) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(app.name, Math.round(app.cpu * 1e9));
log.info(`checkApplicationsCpuUSage ${app.name} increasing cpu 100.`);
appsMonitored[app.name].lastHourstatsStore = [];
}
}
} else {
Expand Down Expand Up @@ -9726,6 +9722,7 @@ async function checkApplicationsCpuUSage() {
// cpu was high on 80% of the checks
cpuThrottling = true;
}
appsMonitored[`${appComponent.name}_${app.name}`].lastHourstatsStore = [];
log.info(`checkApplicationsCpuUSage ${appComponent.name}_${app.name} cpu high load: ${cpuThrottling}`);
log.info(`checkApplicationsCpuUSage ${cpuPercentage}`);
if (cpuThrottling && appComponent.cpu > 1) {
Expand All @@ -9738,28 +9735,23 @@ async function checkApplicationsCpuUSage() {
await dockerService.appDockerUpdateCpu(`${appComponent.name}_${app.name}`, Math.round(appComponent.cpu * 1e9 * 0.9));
}
log.info(`checkApplicationsCpuUSage ${appComponent.name}_${app.name} lowering cpu.`);
appsMonitored[app.name].lastHourstatsStore = [];
}
} else if (cpuPercentage <= 0.8) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(`${appComponent.name}_${app.name}`, Math.round(appComponent.cpu * 1e9 * 0.85));
log.info(`checkApplicationsCpuUSage ${appComponent.name}_${app.name} increasing cpu 85.`);
appsMonitored[`${appComponent.name}_${app.name}`].lastHourstatsStore = [];
} else if (cpuPercentage <= 0.85) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(`${appComponent.name}_${app.name}`, Math.round(appComponent.cpu * 1e9 * 0.9));
log.info(`checkApplicationsCpuUSage ${appComponent.name}_${app.name} increasing cpu 90.`);
appsMonitored[`${appComponent.name}_${app.name}`].lastHourstatsStore = [];
} else if (cpuPercentage <= 0.9) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(`${appComponent.name}_${app.name}`, Math.round(appComponent.cpu * 1e9 * 0.95));
log.info(`checkApplicationsCpuUSage ${appComponent.name}_${app.name} increasing cpu 95.`);
appsMonitored[`${appComponent.name}_${app.name}`].lastHourstatsStore = [];
} else if (cpuPercentage < 1) {
// eslint-disable-next-line no-await-in-loop
await dockerService.appDockerUpdateCpu(`${appComponent.name}_${app.name}`, Math.round(appComponent.cpu * 1e9));
log.info(`checkApplicationsCpuUSage ${appComponent.name}_${app.name} increasing cpu 100.`);
appsMonitored[`${appComponent.name}_${app.name}`].lastHourstatsStore = [];
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/serviceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ async function startFluxFunctions() {
setInterval(() => {
appsService.checkApplicationsCpuUSage();
}, 15 * 60 * 1000);
}, 20 * 60 * 1000);
}, 15 * 60 * 1000);
setTimeout(() => {
// appsService.checkForNonAllowedAppsOnLocalNetwork();
appsService.checkMyAppsAvailability(); // periodically checks
Expand Down

0 comments on commit fbf35c4

Please sign in to comment.