diff options
author | nicolargo <nicolashennion@gmail.com> | 2015-11-28 15:52:42 +0100 |
---|---|---|
committer | nicolargo <nicolashennion@gmail.com> | 2015-11-28 15:52:42 +0100 |
commit | 71a18e67a707e4d2f35b1b74321f47c0dde517ba (patch) | |
tree | c8918fd0eb0d745e8b72f1d3659419f5528f54a5 /glances/actions.py | |
parent | b4d1ee475318260f795438baeb5df7e749b2f317 (diff) |
When Glances is starting the notifications should be delayed #732
Diffstat (limited to 'glances/actions.py')
-rw-r--r-- | glances/actions.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/glances/actions.py b/glances/actions.py index a7fdca3a..4fea8d61 100644 --- a/glances/actions.py +++ b/glances/actions.py @@ -22,6 +22,7 @@ from subprocess import Popen from glances.logger import logger +from glances.timer import Timer try: import pystache @@ -36,7 +37,7 @@ class GlancesActions(object): """This class manage action if an alert is reached.""" - def __init__(self): + def __init__(self, args=None): """Init GlancesActions class.""" # Dict with the criticity status # - key: stat_name @@ -44,6 +45,13 @@ class GlancesActions(object): # Goal: avoid to execute the same command twice self.status = {} + # Add a timer to avoid any trigger when Glances is started (issue#732) + # Action can be triggered after refresh * 2 seconds + if hasattr(args, 'time'): + self.start_timer = Timer(args.time * 2) + else: + self.start_timer = Timer(3) + def get(self, stat_name): """Get the stat_name criticity.""" try: @@ -65,7 +73,7 @@ class GlancesActions(object): Return True if the commands have been ran. """ - if self.get(stat_name) == criticity: + if self.get(stat_name) == criticity or not self.start_timer.finished(): # Action already executed => Exit return False |