Added active links stat to rnstatus

master
Mark Qvist 2026-08-21 13:23:30 +02:00
parent 5f2f4438d0
commit 880db0a7b7
No known key found for this signature in database
3 changed files with 25 additions and 1 deletions

View File

@ -1287,6 +1287,7 @@ class Reticulum:
if path == "next_hop": self.rpc_return(conn, self.get_next_hop(call["destination_hash"]))
if path == "first_hop_timeout": self.rpc_return(conn, self.get_first_hop_timeout(call["destination_hash"]))
if path == "link_count": self.rpc_return(conn, self.get_link_count())
if path == "active_link_count": self.rpc_return(conn, self.get_active_link_count())
if path == "packet_rssi": self.rpc_return(conn, self.get_packet_rssi(call["packet_hash"]))
if path == "packet_snr": self.rpc_return(conn, self.get_packet_snr(call["packet_hash"]))
if path == "packet_q": self.rpc_return(conn, self.get_packet_q(call["packet_hash"]))
@ -1738,7 +1739,17 @@ class Reticulum:
return response
else:
return len(RNS.Transport.link_table)
return RNS.Transport.link_count()
def get_active_link_count(self):
if self.is_connected_to_shared_instance:
rpc_connection = self.get_rpc_client()
rpc_connection.send_bytes(mp.packb({"get": "active_link_count"}))
response = mp.unpackb(rpc_connection.recv_bytes())
return response
else:
return RNS.Transport.active_link_count()
def get_packet_rssi(self, packet_hash):
if self.is_connected_to_shared_instance:

View File

@ -3047,6 +3047,14 @@ class Transport:
if interface != None and interface.bitrate: return ((1/interface.bitrate)*8)*RNS.Reticulum.MTU
else: return 0
@staticmethod
def link_count():
return len(Transport.link_table)
@staticmethod
def active_link_count():
return sum(1 for e in (True for entry in Transport.link_table if entry[IDX_LT_VALIDATED]))
@staticmethod
def expire_path(destination_hash):
with Transport.path_table_lock:

View File

@ -173,6 +173,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
else: return
link_count = None
active_link_count = None
stats = None
details = False
@ -339,6 +340,8 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
if lstats:
try: link_count = reticulum.get_link_count()
except Exception as e: pass
try: active_link_count = reticulum.get_active_link_count()
except Exception as e: pass
try: stats = reticulum.get_interface_stats()
except Exception as e: pass
@ -677,6 +680,8 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
else:
lstr = f" {link_count} entr{ms} in link table"
if active_link_count: lstr = f"{lstr} ({active_link_count} active)"
if traffic_totals:
rxb_str = ""+RNS.prettysize(stats["rxb"])
txb_str = ""+RNS.prettysize(stats["txb"])