diff --git a/routermon/routermon.py b/routermon/routermon.py index d98a331..e821b8f 100644 --- a/routermon/routermon.py +++ b/routermon/routermon.py @@ -49,15 +49,13 @@ def main() -> int: hw_stats: dict[str,str] = convertInt(api.get_resource('/system/resource').call('print', {'proplist':'uptime,cpu-load,total-memory,free-memory'})[0]) hw_stats['temperature'] = convertInt(api.get_resource('/system/health').call('print')[1])['value'] # Calcolo della velocita' interfaccia a ogni ciclo - for n, d in enumerate(if_stats): + for n, _ in enumerate(if_stats): + if_name = if_stats[n].pop('name') if_stats[n]['rx-rate'] = int((if_stats[n]['rx-bytes']-if_stats_old[n]['rx-bytes'])/(now-last)) if_stats[n]['tx-rate'] = int((if_stats[n]['tx-bytes']-if_stats_old[n]['tx-bytes'])/(now-last)) if_points.append( - Point('interfaces') - .tag('interface', d['name']) - .field('rx-rate', if_stats[n]['rx-rate']) - .field('tx-rate', if_stats[n]['tx-rate']) - ) + dict2Point('interfaces', if_stats[n], {'interface': if_name}) + ) write_client.write(record=if_points) # Risorse del router