10
0

Better port stats handling

This commit is contained in:
Lauri Võsandi 2021-07-05 20:22:48 +03:00
parent 192f427b35
commit 0a42485318

View File

@ -48,8 +48,6 @@ async def scrape_mikrotik(target):
) )
ports = ",".join([str(j) for j in range(0, 24)])
mk.talk_sentence(["/interface/print"]) mk.talk_sentence(["/interface/print"])
res = await mk.read_full_answer() res = await mk.read_full_answer()
for resp, _, obj in res: for resp, _, obj in res:
@ -74,6 +72,15 @@ async def scrape_mikrotik(target):
yield "interface_running", "gauge", int(obj["tx-byte"]), labels yield "interface_running", "gauge", int(obj["tx-byte"]), labels
yield "interface_actual_mtu", "gauge", obj["actual-mtu"], labels yield "interface_actual_mtu", "gauge", obj["actual-mtu"], labels
mk.talk_sentence(["/interface/ethernet/print"])
port_count = 0
res = await mk.read_full_answer()
for resp, _, obj in res:
if resp in ("!trap", "!done"):
break
port_count += 1
ports = ",".join([str(j) for j in range(0, port_count)])
mk.talk_sentence(["/interface/ethernet/monitor", "=once=", "=numbers=%s" % ports]) mk.talk_sentence(["/interface/ethernet/monitor", "=once=", "=numbers=%s" % ports])
res = await mk.read_full_answer() res = await mk.read_full_answer()
for resp, _, obj in res: for resp, _, obj in res: