diff --git a/ffmap/config.py b/ffmap/config.py index e2606b2..643bf0a 100644 --- a/ffmap/config.py +++ b/ffmap/config.py @@ -8,6 +8,7 @@ CONFIG = { "orphan_threshold_days": 7, # Router switches to orphaned state after X days "delete_threshold_days": 180, # Router is deleted after X days "router_stat_days": 30, # Router stats are collected for X days (if online) + "router_stat_netif": 21, # Router stats for netifs are collected for X days (if online) "router_stat_mindiff_secs": 10, # Time difference (uptime) in seconds required for a new entry in router stats "router_stat_mindiff_default": 270, # Time difference (router stats tables) in seconds required for a new entry in router stats "router_stat_mindiff_netif": 570, # Time difference (router netif stats) in seconds required for a new entry in router stats diff --git a/ffmap/routertools.py b/ffmap/routertools.py index 5bae737..ae03011 100644 --- a/ffmap/routertools.py +++ b/ffmap/routertools.py @@ -387,6 +387,7 @@ def delete_unlinked_routers(mysql): def delete_old_stats(mysql): threshold=(utcnow() - datetime.timedelta(days=CONFIG["router_stat_days"])).timestamp() + threshold_netif=(utcnow() - datetime.timedelta(days=CONFIG["router_stat_netif"])).timestamp() start_time = time.time() mysql.execute(""" @@ -427,7 +428,7 @@ def delete_old_stats(mysql): LEFT JOIN router AS r ON s.router = r.id SET s.deletebit = 1 WHERE s.time < %s AND (r.status = 'online' OR r.status IS NULL) - """,(threshold,)) + """,(threshold_netif,)) mysql.commit() writelog(CONFIG["debug_dir"] + "/deletetime.txt", "Update netif stats: %.3f seconds" % (time.time() - start_time)) print("--- Update netif stats: %.3f seconds ---" % (time.time() - start_time))