|
@@ -301,22 +301,21 @@ class AgentOperService:
|
|
|
traceback.print_exc()
|
|
|
|
|
|
def check_agent_live_daemon(_members):
|
|
|
- key = CENTER_AGENT_LIVE_CNT % SAAS_ID
|
|
|
- pre_val = self.redis_handler.redis.get(key)
|
|
|
- if not pre_val:
|
|
|
- if not _members or len(_members) == 0:
|
|
|
- value = datetime.now().timestamp()
|
|
|
- self.redis_handler.redis.set(key, value, ex=60*60, nx=True)
|
|
|
+ _key = CENTER_AGENT_LIVE_CNT % SAAS_ID
|
|
|
+ pre_time = self.redis_handler.redis.get(_key)
|
|
|
+ if not pre_time or not _members or len(_members) == 0:
|
|
|
+ value = datetime.now().timestamp()
|
|
|
+ self.redis_handler.redis.set(_key, value, ex=60*60, nx=True)
|
|
|
else:
|
|
|
- diff = datetime.now().timestamp() - float(pre_val)
|
|
|
- # self.logger.info('check_agent_live_daemon, members=%s, diff=%s, pre_val=%s', (len(_members) if _members else 0), diff, pre_val)
|
|
|
+ diff = datetime.now().timestamp() - float(pre_time)
|
|
|
if diff > self.agent_serial_live_expire:
|
|
|
+ self.logger.info('check_agent_live_daemon, members=%s, diff=%s, pre_val=%s', (len(_members) if _members else 0), diff, pre_time)
|
|
|
self.logger.warn('WARING::live agent count less than 1 serial ten minutes')
|
|
|
self.data_handle_server.create_warning_record(1, '10分钟空岗报警')
|
|
|
- self.redis_handler.redis.delete(key)
|
|
|
+ self.redis_handler.redis.delete(_key)
|
|
|
|
|
|
if _members and len(_members) > 0:
|
|
|
- self.redis_handler.redis.delete(key)
|
|
|
+ self.redis_handler.redis.delete(_key)
|
|
|
|
|
|
name = CENTER_AGENT_HEARTBEAT % SAAS_ID
|
|
|
members = self.redis_handler.redis.hgetall(name)
|