Added link table stats to rnstatus
This commit is contained in:
parent
b994db3745
commit
1f6560619e
|
@ -1100,6 +1100,9 @@ class Reticulum:
|
||||||
if path == "first_hop_timeout":
|
if path == "first_hop_timeout":
|
||||||
rpc_connection.send(self.get_first_hop_timeout(call["destination_hash"]))
|
rpc_connection.send(self.get_first_hop_timeout(call["destination_hash"]))
|
||||||
|
|
||||||
|
if path == "link_count":
|
||||||
|
rpc_connection.send(self.get_link_count())
|
||||||
|
|
||||||
if path == "packet_rssi":
|
if path == "packet_rssi":
|
||||||
rpc_connection.send(self.get_packet_rssi(call["packet_hash"]))
|
rpc_connection.send(self.get_packet_rssi(call["packet_hash"]))
|
||||||
|
|
||||||
|
@ -1348,6 +1351,16 @@ class Reticulum:
|
||||||
else:
|
else:
|
||||||
return RNS.Transport.next_hop(destination)
|
return RNS.Transport.next_hop(destination)
|
||||||
|
|
||||||
|
def get_link_count(self):
|
||||||
|
if self.is_connected_to_shared_instance:
|
||||||
|
rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||||
|
rpc_connection.send({"get": "link_count"})
|
||||||
|
response = rpc_connection.recv()
|
||||||
|
return response
|
||||||
|
|
||||||
|
else:
|
||||||
|
return len(RNS.Transport.link_table)
|
||||||
|
|
||||||
def get_packet_rssi(self, packet_hash):
|
def get_packet_rssi(self, packet_hash):
|
||||||
if self.is_connected_to_shared_instance:
|
if self.is_connected_to_shared_instance:
|
||||||
rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||||
|
@ -1376,7 +1389,6 @@ class Reticulum:
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_packet_q(self, packet_hash):
|
def get_packet_q(self, packet_hash):
|
||||||
if self.is_connected_to_shared_instance:
|
if self.is_connected_to_shared_instance:
|
||||||
rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||||
|
|
|
@ -46,9 +46,16 @@ def size_str(num, suffix='B'):
|
||||||
|
|
||||||
return "%.2f%s%s" % (num, last_unit, suffix)
|
return "%.2f%s%s" % (num, last_unit, suffix)
|
||||||
|
|
||||||
def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=False, astats=False, sorting=None, sort_reverse=False):
|
def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=False, astats=False, lstats=False, sorting=None, sort_reverse=False):
|
||||||
reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity)
|
reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity)
|
||||||
|
|
||||||
|
link_count = None
|
||||||
|
if lstats:
|
||||||
|
try:
|
||||||
|
link_count = reticulum.get_link_count()
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
stats = None
|
stats = None
|
||||||
try:
|
try:
|
||||||
stats = reticulum.get_interface_stats()
|
stats = reticulum.get_interface_stats()
|
||||||
|
@ -208,11 +215,22 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||||
|
|
||||||
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"])))
|
||||||
|
|
||||||
|
lstr = ""
|
||||||
|
if link_count != None and lstats:
|
||||||
|
ms = "y" if link_count == 1 else "ies"
|
||||||
|
if "transport_id" in stats and stats["transport_id"] != None:
|
||||||
|
lstr = f", {link_count} entr{ms} in link table"
|
||||||
|
else:
|
||||||
|
lstr = f" {link_count} entr{ms} in link table"
|
||||||
|
|
||||||
if "transport_id" in stats and stats["transport_id"] != None:
|
if "transport_id" in stats and stats["transport_id"] != None:
|
||||||
print("\n Transport Instance "+RNS.prettyhexrep(stats["transport_id"])+" running")
|
print("\n Transport Instance "+RNS.prettyhexrep(stats["transport_id"])+" running")
|
||||||
if "probe_responder" in stats and stats["probe_responder"] != None:
|
if "probe_responder" in stats and stats["probe_responder"] != None:
|
||||||
print(" Probe responder at "+RNS.prettyhexrep(stats["probe_responder"])+ " active")
|
print(" Probe responder at "+RNS.prettyhexrep(stats["probe_responder"])+ " active")
|
||||||
print(" Uptime is "+RNS.prettytime(stats["transport_uptime"]))
|
print(" Uptime is "+RNS.prettytime(stats["transport_uptime"])+lstr)
|
||||||
|
else:
|
||||||
|
if lstr != "":
|
||||||
|
print(f"\n{lstr}")
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
@ -241,6 +259,14 @@ def main():
|
||||||
default=False
|
default=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-l",
|
||||||
|
"--link-stats",
|
||||||
|
action="store_true",
|
||||||
|
help="show link stats",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-s",
|
"-s",
|
||||||
"--sort",
|
"--sort",
|
||||||
|
@ -284,6 +310,7 @@ def main():
|
||||||
name_filter=args.filter,
|
name_filter=args.filter,
|
||||||
json=args.json,
|
json=args.json,
|
||||||
astats=args.announce_stats,
|
astats=args.announce_stats,
|
||||||
|
lstats=args.link_stats,
|
||||||
sorting=args.sort,
|
sorting=args.sort,
|
||||||
sort_reverse=args.reverse,
|
sort_reverse=args.reverse,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue