improved CpuLoad trigger logic
This commit is contained in:
@@ -19,7 +19,7 @@ class TriggerTuple(NamedTuple):
|
|||||||
custom_config: OrderedDict[str, Any]
|
custom_config: OrderedDict[str, Any]
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"{self.name}, interval: {self.interval_in_seconds}, governor: {self.governor}, custom_config: {self.custom_config}"
|
return f"{self.name}, loglevel: {self.loglevel}, interval: {self.interval_in_seconds}, governor: {self.governor}, custom_config: {self.custom_config}"
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ class CpuLoadTrigger(Trigger):
|
|||||||
self.current_load, self.threshold, self.governor.name
|
self.current_load, self.threshold, self.governor.name
|
||||||
)
|
)
|
||||||
self.timestamp_last_governor_change = current_time
|
self.timestamp_last_governor_change = current_time
|
||||||
|
|
||||||
|
elif current_active and new_active:
|
||||||
|
self.log.debug("trigger is already active, load: %s, threshold: %s", self.current_load, self.threshold)
|
||||||
|
self.timestamp_last_governor_change = current_time
|
||||||
|
|
||||||
elif current_active and not new_active:
|
elif current_active and not new_active:
|
||||||
if (current_time - timedelta(minutes=self.cooldown_period_in_minutes)) < self.timestamp_last_governor_change:
|
if (current_time - timedelta(minutes=self.cooldown_period_in_minutes)) < self.timestamp_last_governor_change:
|
||||||
@@ -60,5 +64,7 @@ class CpuLoadTrigger(Trigger):
|
|||||||
"deactivating trigger, load: %s, threshold: %s, governor: %s",
|
"deactivating trigger, load: %s, threshold: %s, governor: %s",
|
||||||
self.current_load, self.threshold, self.governor.name
|
self.current_load, self.threshold, self.governor.name
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
self.log.debug("trigger is already inactive, load: %s, threshold: %s", self.current_load, self.threshold)
|
||||||
|
|
||||||
self.active = new_active
|
self.active = new_active
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "cpu_governor_auto_adjust"
|
name = "cpu_governor_auto_adjust"
|
||||||
version = "0.1.43"
|
version = "0.1.44"
|
||||||
description = "This application has been developed to automatically change cpu governor based on certain triggers."
|
description = "This application has been developed to automatically change cpu governor based on certain triggers."
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Martin Reurekas", email = "martin@semrks.nl" }
|
{ name = "Martin Reurekas", email = "martin@semrks.nl" }
|
||||||
|
|||||||
Reference in New Issue
Block a user