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 ────────────────────────────────────────────────────────────
|
# ─── Status ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
def show_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")
|
r = run("systemctl list-units 'wallarm-node@*' --no-legend 2>/dev/null")
|
||||||
if not r.stdout.strip():
|
if not r.stdout.strip():
|
||||||
print("No nodes running.")
|
print("No nodes running.")
|
||||||
return
|
return
|
||||||
print("\n─── Node Status ───")
|
print("\n─── Node Status ───")
|
||||||
for line in r.stdout.strip().split("\n"):
|
for line in r.stdout.strip().split("\n"):
|
||||||
|
# Parse: "wallarm-node@srv1.service loaded active running ..."
|
||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts) >= 4:
|
if len(parts) >= 4 and '@' in parts[0]:
|
||||||
name = parts[0].replace("wallarm-node@", "").replace(".service", "")
|
name = parts[0].split('@')[1].replace(".service", "")
|
||||||
status = "●" if parts[3] == "running" else "○"
|
active = parts[3] if len(parts) > 3 else "unknown"
|
||||||
print(f" {status} {name} — {parts[3]}")
|
status = "●" if active == "active" or active == "running" else "○"
|
||||||
|
print(f" {status} {name} — {active}")
|
||||||
|
|
||||||
# ─── Tunnel ────────────────────────────────────────────────────────────
|
# ─── Tunnel ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue