From 0ce3fa5c2fbcc4ef0f33e56125efc4e723dee5a3 Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Tue, 16 Jan 2018 00:16:27 +0100 Subject: [PATCH] routertools: Set rx/tx to zero if router gets offline This has to be done BEFORE the status is set, since otherwise the selector won't work anymore. Signed-off-by: Adrian Schmutzler --- ffmap/routertools.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ffmap/routertools.py b/ffmap/routertools.py index 5efa303..efac02a 100644 --- a/ffmap/routertools.py +++ b/ffmap/routertools.py @@ -330,6 +330,13 @@ def detect_offline_routers(mysql): VALUES (%s, %s, 'offline', '') """,rdata) + mysql.execute(""" + UPDATE router_netif AS n + INNER JOIN router AS r ON r.id = n.router + SET n.rx = 0, n.tx = 0 + WHERE r.last_contact < %s AND r.status <> 'offline' AND r.status <> 'orphaned' + """,(threshold,)) + # Online to Offline has to be updated after other queries! mysql.execute(""" UPDATE router SET status = 'offline', clients = 0