added total workers amount to the table

This commit is contained in:
jvved 2025-01-31 17:47:26 -05:00
parent 3cd037c8b3
commit a1ab31acfe
3 changed files with 46 additions and 71 deletions

Binary file not shown.

View File

@ -1,16 +1,9 @@
class HelloWorld:
def __init__(self, num_iters):
self.num_iters = num_iters
self.counter = 0
class SampleClass:
class_attr = 100
def __init__(self, instance_attr):
self.instance_attr = instance_attr
def __iter__(self):
qreturn self
qreturn self
def __next__(self):
if self.counter < self.num_iters:
self.counter += 1
return "Hello World"
raise StopIteration
def method(self):
print(f"Class attribute: {self.class_attr}")
print(f"Instance attribute: {self.instance_attr}")

View File

@ -28,9 +28,6 @@ class RouterStats(pydantic.BaseModel):
subscriptions: list[RouterSubscription]
cheap: int = pydantic.Field(ge=0)
def run(stats_address):
if not all([stats_address.exists(), stats_address.is_socket()]):
raise Exception(f"unable to read stats from {(stats_address)}")
@ -77,50 +74,38 @@ if __name__ == "__main__":
stats = run(stats_address)
class AppStats(pydantic.BaseModel):
model_config = pydantic.ConfigDict(strict=True)
version: str
listen_queue: int
listen_queue_errors: int
signal_queue: int
load: int
pid: int
uid: int
gid: int
cwd: str
locks: list[dict[str, int]]
sockets: list[stats.SocketStats]
workers: list[stats.WorkerStats]
# class AppStats(pydantic.BaseModel):
# model_config = pydantic.ConfigDict(strict=True)
# version: str
# listen_queue: int
# listen_queue_errors: int
# signal_queue: int
# load: int
# pid: int
# uid: int
# gid: int
# cwd: str
# locks: list[dict[str, int]]
# sockets: list[stats.SocketStats]
# workers: list[stats.WorkerStats]
def read_stats(socket_address):
sockets = {
"9027_stats.sock": "{app1 - stats}"
}
if socket_address in sockets:
return sockets[socket_address]
else:
return "could not lookup socket"
if __name__ == "__main__":
counter = 0
nodes = ["127.0.0.1:9027", "127.0.0.1:9030"]
for node in nodes:
port = node.split(":")[-1]
socket_address = f"{port}_stats.sock"
stats = read_stats(socket_address)
print(stats)
node_stats = Path("9027_stats.sock")
print(node_stats)
stats_address2 = Path("run/9027_stats.sock")
stats2 = run(stats_address2)
stats2 = run(Path("run/app1_stats.sock"))
app_stats = AppStats(**stats2)
print(app_stats.workers)
worker_amount = app_stats.workers
print(len(app_stats.workers))
print(len(app_stats.workers)) #print amount workers
router_stats = RouterStats(**stats)
print(router_stats)
@ -133,10 +118,7 @@ class AppStats(pydantic.BaseModel):
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)}")
table.add_row(sub.key, f"{len(sub.nodes)}", f"{len(app_stats.workers)}")
console = Console()
console.print(table)