cpu load trigger: made cooldown period configuraable
This commit is contained in:
@@ -8,7 +8,7 @@ from datetime import datetime, timedelta
|
||||
class CpuLoadTrigger(Trigger):
|
||||
def __init__(self, _config: Config) -> None:
|
||||
super().__init__(_config)
|
||||
self.timestamp_last_governor_change = datetime.now() - timedelta(minutes=10)
|
||||
self.timestamp_last_governor_change = datetime.now() - timedelta(minutes=self.cooldown_period_in_minutes + 1)
|
||||
|
||||
@cached_property
|
||||
def one_minute_load_threshold(self) -> float:
|
||||
@@ -25,6 +25,10 @@ class CpuLoadTrigger(Trigger):
|
||||
@cached_property
|
||||
def threshold(self) -> tuple[float, float, float]:
|
||||
return self.one_minute_load_threshold, self.five_minute_load_threshold, self.ten_minute_load_threshold
|
||||
|
||||
@cached_property
|
||||
def cooldown_period_in_minutes(self) -> float:
|
||||
return float(self.config.custom_config['cooldownPeriodInMinutes'])
|
||||
|
||||
@property
|
||||
def current_load(self) -> tuple[float, float, float]:
|
||||
@@ -48,8 +52,8 @@ class CpuLoadTrigger(Trigger):
|
||||
self.timestamp_last_governor_change = current_time
|
||||
|
||||
elif current_active and not new_active:
|
||||
if (current_time - timedelta(minutes=5)) < self.timestamp_last_governor_change:
|
||||
self.log.info("cooldown period, staying on governor: %s", self.governor.name)
|
||||
if (current_time - timedelta(minutes=self.cooldown_period_in_minutes)) < self.timestamp_last_governor_change:
|
||||
self.log.info("cooldown period, staying on governor: %s, current load: %s", self.governor.name, self.current_load)
|
||||
return
|
||||
|
||||
self.log.info(
|
||||
|
||||
Reference in New Issue
Block a user