diff --git a/monkey_island/cc/main.py b/monkey_island/cc/main.py index b22bb6212..2595396af 100644 --- a/monkey_island/cc/main.py +++ b/monkey_island/cc/main.py @@ -296,6 +296,11 @@ def output_json(obj, code, headers=None): def update_dead_monkeys(): + + # Update dead monkeys only if no living monkey transmitted keepalive in the last 10 minutes + if mongo.db.monkey.find_one({'dead': {'$ne': True}, 'keepalive': {'$gte': datetime.now() - timedelta(minutes=10)}}): + return + mongo.db.monkey.update( {'keepalive': {'$lte': datetime.now() - timedelta(minutes=10)}, 'dead': {'$ne': True}}, {'$set': {'dead': True, 'modifytime': datetime.now()}}, upsert=False, multi=True)