mirror of
https://github.com/markqvist/Reticulum.git
synced 2025-08-13 16:55:52 -04:00
Basic interface rate estimation
This commit is contained in:
parent
7923322d92
commit
2f71296816
5 changed files with 49 additions and 5 deletions
|
@ -87,17 +87,23 @@ def program_setup(configdir, dispall=False, verbosity = 0):
|
|||
|
||||
print(" {n}".format(n=ifstat["name"]))
|
||||
print(" Status : {ss}".format(ss=ss))
|
||||
|
||||
|
||||
if clients != None:
|
||||
print(" "+clients_string)
|
||||
|
||||
if not (name.startswith("Shared Instance[") or name.startswith("TCPInterface[Client") or name.startswith("LocalInterface[")):
|
||||
print(" Mode : {mode}".format(mode=modestr))
|
||||
|
||||
if "bitrate" in ifstat and ifstat["bitrate"] != None:
|
||||
print(" Rate : {ss}".format(ss=speed_str(ifstat["bitrate"])))
|
||||
|
||||
if "peers" in ifstat and ifstat["peers"] != None:
|
||||
print(" Peers : {np} reachable".format(np=ifstat["peers"]))
|
||||
|
||||
if "i2p_b32" in ifstat:
|
||||
print(" I2P B32 : {ep}".format(ep=str(ifstat["i2p_b32"])))
|
||||
|
||||
print(" RX : {rxb}\n TX : {txb}".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("")
|
||||
|
||||
|
@ -133,5 +139,21 @@ def main():
|
|||
print("")
|
||||
exit()
|
||||
|
||||
def speed_str(num, suffix='bps'):
|
||||
units = ['','k','M','G','T','P','E','Z']
|
||||
last_unit = 'Y'
|
||||
|
||||
if suffix == 'Bps':
|
||||
num /= 8
|
||||
units = ['','K','M','G','T','P','E','Z']
|
||||
last_unit = 'Y'
|
||||
|
||||
for unit in units:
|
||||
if abs(num) < 1000.0:
|
||||
return "%3.2f %s%s" % (num, unit, suffix)
|
||||
num /= 1000.0
|
||||
|
||||
return "%.2f %s%s" % (num, last_unit, suffix)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue