Skip to content

Commit

Permalink
Use different intervals for ping and daemon_status in the collector t…
Browse files Browse the repository at this point in the history
…hread

So we can enforce a minimum interval between pings.
  • Loading branch information
cvaroqui committed Apr 12, 2018
1 parent 11183ff commit 6a7dfe0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/osvcd_collector.py
Expand Up @@ -12,7 +12,8 @@
from rcGlobalEnv import rcEnv

class Collector(shared.OsvcThread, Crypt):
interval = 300
update_interval = 300
ping_interval = 60

def run(self):
self.log = logging.getLogger(rcEnv.nodename+".osvcd.collector")
Expand Down Expand Up @@ -64,7 +65,7 @@ def do(self):
self.run_collector()
self.unqueue_xmlrpc()
with shared.COLLECTOR_TICKER:
shared.COLLECTOR_TICKER.wait(self.interval)
shared.COLLECTOR_TICKER.wait(self.update_interval)

def unqueue_xmlrpc(self):
while True:
Expand Down Expand Up @@ -168,7 +169,9 @@ def run_collector(self):
last_status, last_status_changed = self.get_last_status(data)
if last_status_changed != [] or self.last_comm is None:
self.send_daemon_status(data, last_status_changed)
elif self.last_comm <= datetime.datetime.utcnow() - datetime.timedelta(seconds=self.interval):
elif self.last_comm <= datetime.datetime.utcnow() - datetime.timedelta(seconds=self.ping_interval):
pass
elif self.last_comm <= datetime.datetime.utcnow() - datetime.timedelta(seconds=self.update_interval):
self.ping()
self.last_status = last_status

Expand Down

0 comments on commit 6a7dfe0

Please sign in to comment.