mirror of
https://github.com/FreifunkFranken/fff-monitoring.git
synced 2024-06-26 17:48:07 +02:00
config/routertools: Set minimum distance for data in router stats
This implement to different minimum distances in seconds for the router stats in general and the netif stats in particular. The values are chosen so that they are 30 secs. shorter than the desired timespans of 5 and 10 minutes, to allow for fluctuation in when data arrives. This fixes the data density increase caused by V2 Hoods with two gateways. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
parent
70f2f0a8a3
commit
2a515b94c7
|
@ -8,7 +8,9 @@ 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_mindiff_secs": 10, # Time difference (uptime) required for a new entry in router stats
|
||||
"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
|
||||
"event_num_entries": 30, # Number of events stored per router
|
||||
"global_stat_days": 365, # Global/hood stats are collected for X days
|
||||
"csv_dir": "/var/lib/ffmap/csv", # Directory where the .csv files for TileStache/mapnik are stored
|
||||
|
|
|
@ -474,6 +474,8 @@ def new_router_stats(mysql, router_id, uptime, router_update, netifdict):
|
|||
if (uptime + CONFIG["router_stat_mindiff_secs"]) < router_update["sys_uptime"]:
|
||||
time = mysql.utctimestamp()
|
||||
|
||||
stattime = mysql.findone("SELECT time FROM router_stats WHERE router = %s ORDER BY time DESC LIMIT 1",(router_id,),"time")
|
||||
if not stattime or (stattime + CONFIG["router_stat_mindiff_default"]) < time:
|
||||
mysql.execute("""
|
||||
INSERT INTO router_stats (time, router, sys_memfree, sys_membuff, sys_memcache, loadavg, sys_procrun, sys_proctot, clients)
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||
|
@ -488,6 +490,8 @@ def new_router_stats(mysql, router_id, uptime, router_update, netifdict):
|
|||
router_update["processes"]['total'],
|
||||
router_update["clients"],))
|
||||
|
||||
netiftime = mysql.findone("SELECT time FROM router_stats_netif WHERE router = %s ORDER BY time DESC LIMIT 1",(router_id,),"time")
|
||||
if not netiftime or (netiftime + CONFIG["router_stat_mindiff_netif"]) < time:
|
||||
ndata = []
|
||||
nkeys = []
|
||||
for netif in router_update["netifs"]:
|
||||
|
@ -520,6 +524,8 @@ def new_router_stats(mysql, router_id, uptime, router_update, netifdict):
|
|||
VALUES (%s, %s, %s, %s, %s)
|
||||
""",ndata)
|
||||
|
||||
# reuse timestamp from router_stats to avoid additional queries
|
||||
if not stattime or (stattime + CONFIG["router_stat_mindiff_default"]) < time:
|
||||
nbdata = []
|
||||
for neighbour in router_update["neighbours"]:
|
||||
with suppress(KeyError):
|
||||
|
@ -529,6 +535,8 @@ def new_router_stats(mysql, router_id, uptime, router_update, netifdict):
|
|||
VALUES (%s, %s, %s, %s)
|
||||
""",nbdata)
|
||||
|
||||
# reuse timestamp from router_stats to avoid additional queries
|
||||
if not stattime or (stattime + CONFIG["router_stat_mindiff_default"]) < time:
|
||||
gwdata = []
|
||||
for gw in router_update["gws"]:
|
||||
with suppress(KeyError):
|
||||
|
|
Loading…
Reference in New Issue
Block a user