Splite cpu/memory info in OSUtils#isOverload (#12663)

This commit is contained in:
Wenjun Ruan 2022-11-02 21:15:03 +08:00 committed by GitHub
parent aeb861fa15
commit ff59acd02f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -477,10 +477,14 @@ public class OSUtils {
double loadAverage = loadAverage();
// system available physical memory
double availablePhysicalMemorySize = availablePhysicalMemorySize();
if (loadAverage > maxCpuLoadAvg || availablePhysicalMemorySize < reservedMemory) {
if (loadAverage > maxCpuLoadAvg) {
logger.warn("Current cpu load average {} is too high, max.cpuLoad.avg={}", loadAverage, maxCpuLoadAvg);
return true;
}
if (availablePhysicalMemorySize < reservedMemory) {
logger.warn(
"Current cpu load average {} is too high or available memory {}G is too low, under max.cpuLoad.avg={} and reserved.memory={}G",
loadAverage, availablePhysicalMemorySize, maxCpuLoadAvg, reservedMemory);
"Current available memory {}G is too low, reserved.memory={}G", maxCpuLoadAvg, reservedMemory);
return true;
}
return false;