Finished subscription table
This commit is contained in:
parent
6cbfc82e94
commit
dd37364378
@ -99,45 +99,44 @@ def read_stats(stats_address):
|
|||||||
print(js)
|
print(js)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
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"]
|
stats_list = ["run/sub1-stats.sock", "run/sub2-stats.sock"]
|
||||||
for stats in stats_list:
|
|
||||||
stats_address = Path(stats_list)
|
|
||||||
stats = read_stats(stats_address)
|
|
||||||
print(stats)
|
|
||||||
router_stats = RouterStats(**stats)
|
|
||||||
all_app_stats = {}
|
|
||||||
total_workers = 0
|
|
||||||
|
|
||||||
for sub in router_stats.subscriptions:
|
|
||||||
print(sub)
|
|
||||||
for node in sub.nodes:
|
|
||||||
print(node.name)
|
|
||||||
port = node.name.split(":")[-1]
|
|
||||||
print(port)
|
|
||||||
stats_address2 = Path(f"run/{port}_stats.sock")
|
|
||||||
stats2 = read_stats(stats_address2)
|
|
||||||
app_stats = AppStats(**stats2)
|
|
||||||
print(f"App Stats for {port}:{app_stats}")
|
|
||||||
print(app_stats.workers)
|
|
||||||
print(len(app_stats.workers))
|
|
||||||
worker_amount = len(app_stats.workers)
|
|
||||||
total_workers = total_workers + worker_amount
|
|
||||||
print(total_workers)
|
|
||||||
|
|
||||||
|
|
||||||
print(router_stats)
|
|
||||||
#import ipdb;ipdb.set_trace()
|
|
||||||
for sub in router_stats.subscriptions:
|
|
||||||
print(f"{sub.key=}")
|
|
||||||
|
|
||||||
table = Table()
|
table = Table()
|
||||||
table.add_column("Virtual Hosts", justify="right", style="cyan", no_wrap=True)
|
table.add_column("Virtual Hosts", justify="right", style="cyan", no_wrap=True)
|
||||||
table.add_column("Nodes", style="magenta")
|
table.add_column("Nodes", style="magenta")
|
||||||
table.add_column("Total Workers", style="magenta")
|
table.add_column("Total Workers", style="magenta")
|
||||||
table.add_row(sub.key, f"{len(sub.nodes)}", f"{total_workers}")
|
|
||||||
|
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
|
||||||
|
|
||||||
|
for sub in router_stats.subscriptions:
|
||||||
|
print(sub)
|
||||||
|
for node in sub.nodes:
|
||||||
|
print(node.name)
|
||||||
|
port = node.name.split(":")[-1]
|
||||||
|
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)
|
||||||
|
print(len(app_stats.workers))
|
||||||
|
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}")
|
||||||
|
|
||||||
console = Console()
|
console = Console()
|
||||||
console.print(table)
|
console.print(table)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user