summaryrefslogtreecommitdiff
path: root/clusterman
diff options
context:
space:
mode:
authorLoic Guegan <loic.guegan@mailbox.org>2023-10-27 11:39:22 +0200
committerLoic Guegan <loic.guegan@mailbox.org>2023-10-27 11:39:22 +0200
commit7e267d1bcc8aaa04b12f8522f4fb9d4e9e19f180 (patch)
treeeab2ba8826df88f5a2e66713d918e0b39aae1b80 /clusterman
parentade516e6f80f5648594889acc9f32afb80b5f704 (diff)
Minor changes
Diffstat (limited to 'clusterman')
-rw-r--r--clusterman/commands/node.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py
index 24759f0..f57f743 100644
--- a/clusterman/commands/node.py
+++ b/clusterman/commands/node.py
@@ -1,4 +1,4 @@
-import os, json, time, re, sys
+import os, json, time, re, sys, subprocess
from clusterman.config import CONF
@@ -52,13 +52,13 @@ def scan(timeout):
if ip in ignore_list:
print("Skipping {}".format(ip))
continue
- response = os.system("ping -c 1 -W " + str(timeout)+ " " + ip + " &>/dev/null")
print("Contacting {}...".format(ip),end='')
- if response==0:
+ try:
+ subprocess.run(["ping", "-c", "1", "-W", str(timeout), ip],capture_output=True,check=True)
nodes.append(ip)
print("=> Found!!")
- else:
- print("")
+ except:
+ print()
with open(CONF.NODE_FILE, "w") as f:
f.write(json.dumps(nodes,indent=4))
CONF["cache"]["last_scan"]=int(time.time())