threshold 0 can by used with cpu.

This commit is contained in:
wescoeur 2016-03-09 17:53:38 +01:00
parent aa117a0ee3
commit 96190c21d6

View File

@ -224,7 +224,15 @@ class Plan {
this._poolIds = poolIds this._poolIds = poolIds
this._thresholds = { this._thresholds = {
cpu: { cpu: {
critical: thresholds.cpu || DEFAULT_CRITICAL_THRESHOLD_CPU critical: (() => {
const { cpu } = thresholds
if (cpu >= 0) {
return cpu
}
return DEFAULT_CRITICAL_THRESHOLD_CPU
})()
}, },
memoryFree: { memoryFree: {
critical: (thresholds.memoryFree || DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE) * 1024 critical: (thresholds.memoryFree || DEFAULT_CRITICAL_THRESHOLD_MEMORY_FREE) * 1024
@ -261,11 +269,11 @@ class Plan {
// 1. Check if a ressource's utilization exceeds threshold. // 1. Check if a ressource's utilization exceeds threshold.
const avgNow = computeRessourcesAverage(hosts, hostsStats, EXECUTION_DELAY) const avgNow = computeRessourcesAverage(hosts, hostsStats, EXECUTION_DELAY)
const toOptimize = this._checkRessourcesThresholds(hosts, avgNow) let toOptimize = this._checkRessourcesThresholds(hosts, avgNow)
// No ressource's utilization problem. // No ressource's utilization problem.
if (toOptimize.length === 0) { if (toOptimize.length === 0) {
debug('No hosts to optimize.') debug('No hosts to opdeededtizzzzzzzzzmize.')
return return
} }
@ -273,8 +281,16 @@ class Plan {
const avgBefore = computeRessourcesAverage(hosts, hostsStats, MINUTES_OF_HISTORICAL_DATA) const avgBefore = computeRessourcesAverage(hosts, hostsStats, MINUTES_OF_HISTORICAL_DATA)
const avgWithRatio = computeRessourcesAverageWithWeight(avgNow, avgBefore, 0.75) const avgWithRatio = computeRessourcesAverageWithWeight(avgNow, avgBefore, 0.75)
toOptimize = this._checkRessourcesThresholds(toOptimize, avgWithRatio)
// No ressource's utilization problem.
if (toOptimize.length === 0) {
debug('No hosts to opddedzssssstizzzzzzzzzmize.')
return
}
return { return {
toOptimize: this._checkRessourcesThresholds(toOptimize, avgWithRatio), toOptimize,
averages: avgWithRatio, averages: avgWithRatio,
hosts hosts
} }
@ -381,7 +397,6 @@ class PerformancePlan extends Plan {
const data = await this._findHostsToOptimize() const data = await this._findHostsToOptimize()
if (!data) { if (!data) {
debug('No hosts to optimize.')
return return
} }