Added interface announce queue stats to rnstatus

This commit is contained in:
Mark Qvist 2022-04-18 16:41:38 +02:00
parent 222437d851
commit 282239fc57
2 changed files with 20 additions and 2 deletions

View File

@ -788,6 +788,12 @@ class Reticulum:
else: else:
ifstats["peers"] = None ifstats["peers"] = None
if hasattr(interface, "announce_queue"):
if interface.announce_queue != None:
ifstats["announce_queue"] = len(interface.announce_queue)
else:
ifstats["announce_queue"] = None
ifstats["name"] = str(interface) ifstats["name"] = str(interface)
ifstats["rxb"] = interface.rxb ifstats["rxb"] = interface.rxb
ifstats["txb"] = interface.txb ifstats["txb"] = interface.txb

View File

@ -48,8 +48,13 @@ def size_str(num, suffix='B'):
def program_setup(configdir, dispall=False, verbosity = 0): def program_setup(configdir, dispall=False, verbosity = 0):
reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity) reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity)
ifstats = reticulum.get_interface_stats() ifstats = None
try:
ifstats = reticulum.get_interface_stats()
except Exception as e:
pass
if ifstats != None: if ifstats != None:
for ifstat in ifstats: for ifstat in ifstats:
name = ifstat["name"] name = ifstat["name"]
@ -103,6 +108,13 @@ def program_setup(configdir, dispall=False, verbosity = 0):
if "i2p_b32" in ifstat and ifstat["i2p_b32"] != None: if "i2p_b32" in ifstat and ifstat["i2p_b32"] != None:
print(" I2P B32 : {ep}".format(ep=str(ifstat["i2p_b32"]))) print(" I2P B32 : {ep}".format(ep=str(ifstat["i2p_b32"])))
if "announce_queue" in ifstat and ifstat["announce_queue"] != None and ifstat["announce_queue"] > 0:
aqn = ifstat["announce_queue"]
if aqn == 1:
print(" Queued : {np} announce".format(np=aqn))
else:
print(" Queued : {np} announces".format(np=aqn))
print(" Traffic : {txb}\n {rxb}".format(rxb=size_str(ifstat["rxb"]), txb=size_str(ifstat["txb"]))) print(" Traffic : {txb}\n {rxb}".format(rxb=size_str(ifstat["rxb"]), txb=size_str(ifstat["txb"])))
print("") print("")