Finished subscription table

This commit is contained in:
jvved 2025-02-05 13:15:48 -05:00
parent 6cbfc82e94
commit dd37364378

View File

@ -99,15 +99,20 @@ def read_stats(stats_address):
print(js)
if __name__ == "__main__":
# ini_directory = Path("/home/jvved/dev/testpks/")
# ini_file = ini_directory.glob("sub*.ini")
# print(ini_file)
stats_list = ["run/sub1-stats.sock", "run/sub2-stats.sock"]
for stats in stats_list:
stats_address = Path(stats_list)
table = Table()
table.add_column("Virtual Hosts", justify="right", style="cyan", no_wrap=True)
table.add_column("Nodes", style="magenta")
table.add_column("Total Workers", style="magenta")
for sock in stats_list:
stats_address = Path(sock)
stats = read_stats(stats_address)
print(stats)
router_stats = RouterStats(**stats)
all_app_stats = {}
total_workers = 0
@ -119,6 +124,7 @@ if __name__ == "__main__":
print(port)
stats_address2 = Path(f"run/{port}_stats.sock")
stats2 = read_stats(stats_address2)
print(stats2)
app_stats = AppStats(**stats2)
print(f"App Stats for {port}:{app_stats}")
print(app_stats.workers)
@ -126,18 +132,11 @@ if __name__ == "__main__":
worker_amount = len(app_stats.workers)
total_workers = total_workers + worker_amount
print(total_workers)
for a in router_stats.subscriptions:
print(a.key)
table.add_row(a.key, f"{len(sub.nodes)}", f"{total_workers}")
print(router_stats)
#import ipdb;ipdb.set_trace()
for sub in router_stats.subscriptions:
print(f"{sub.key=}")
table = Table()
table.add_column("Virtual Hosts", justify="right", style="cyan", no_wrap=True)
table.add_column("Nodes", style="magenta")
table.add_column("Total Workers", style="magenta")
table.add_row(sub.key, f"{len(sub.nodes)}", f"{total_workers}")
console = Console()
console.print(table)