fix: status parsing from systemd list-units
This commit is contained in:
parent
1974fd0293
commit
c8fd8bc37e
1 changed files with 6 additions and 5 deletions
|
|
@ -218,18 +218,19 @@ def remove_node(name):
|
|||
# ─── Status ────────────────────────────────────────────────────────────
|
||||
|
||||
def show_status():
|
||||
# Check systemd for running instances if state is empty
|
||||
r = run("systemctl list-units 'wallarm-node@*' --no-legend 2>/dev/null")
|
||||
if not r.stdout.strip():
|
||||
print("No nodes running.")
|
||||
return
|
||||
print("\n─── Node Status ───")
|
||||
for line in r.stdout.strip().split("\n"):
|
||||
# Parse: "wallarm-node@srv1.service loaded active running ..."
|
||||
parts = line.split()
|
||||
if len(parts) >= 4:
|
||||
name = parts[0].replace("wallarm-node@", "").replace(".service", "")
|
||||
status = "●" if parts[3] == "running" else "○"
|
||||
print(f" {status} {name} — {parts[3]}")
|
||||
if len(parts) >= 4 and '@' in parts[0]:
|
||||
name = parts[0].split('@')[1].replace(".service", "")
|
||||
active = parts[3] if len(parts) > 3 else "unknown"
|
||||
status = "●" if active == "active" or active == "running" else "○"
|
||||
print(f" {status} {name} — {active}")
|
||||
|
||||
# ─── Tunnel ────────────────────────────────────────────────────────────
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue