adaptai / platform /dbops /tools /central_stack_health.py
ADAPT-Chase's picture
Add files using upload-large-folder tool
503b0e9 verified
#!/usr/bin/env python3
import os, socket, json
from datetime import datetime
try:
import yaml
except Exception:
yaml = None
CFG = os.environ.get("CENTRAL_STACK_CFG", "/data/adaptai/secrets/dataops/central_stack.yaml")
def tcp(host, port, timeout=2.0):
try:
with socket.create_connection((host, port), timeout=timeout):
return True, None
except Exception as e:
return False, str(e)
def load_cfg(path):
if yaml:
with open(path) as f:
return yaml.safe_load(f)
# minimal fallback for k:v
data = {}
with open(path) as f:
for ln in f:
ln = ln.strip()
if not ln or ln.startswith('#'): continue
if ':' in ln:
k,v = ln.split(':',1)
data[k.strip()] = v.strip()
return data
def main():
if not os.path.exists(CFG):
raise SystemExit(f"Config not found: {CFG}")
cfg = load_cfg(CFG)
checks = []
def add(name, host, ports):
for p in ports:
ok, err = tcp(host, p)
checks.append({"name": name, "host": host, "port": p, "ok": ok, "error": err})
# expected keys in cfg
if 'central_host' in cfg:
host = cfg['central_host']
else:
host = '172.17.0.3'
add('qdrant-http', cfg.get('qdrant_host', host), [cfg.get('qdrant_http', 17000)])
add('qdrant-grpc', cfg.get('qdrant_host', host), [cfg.get('qdrant_grpc', 17001)])
add('gremlin', cfg.get('gremlin_host', host), [cfg.get('gremlin_port', 17002)])
add('dragonfly', cfg.get('dragonfly_host', host), cfg.get('dragonfly_ports', [18000,18001,18002]))
add('redis-cluster', cfg.get('redis_host', host), cfg.get('redis_ports', [18010,18011,18012]))
add('etcd', cfg.get('etcd_host', host), [cfg.get('etcd_client', 2379)])
add('minio', cfg.get('minio_host', host), [cfg.get('minio_api', 9000), cfg.get('minio_console', 9001)])
add('pulsar', cfg.get('pulsar_host', host), [cfg.get('pulsar_bin', 6650), cfg.get('pulsar_http', 8080)])
add('postgres', cfg.get('postgres_host', host), [cfg.get('postgres_port', 5432)])
add('milvus', cfg.get('milvus_host', host), [cfg.get('milvus_grpc', 19530), cfg.get('milvus_http', 9091)])
add('opensearch', cfg.get('opensearch_host', host), [cfg.get('opensearch_http', 9200)])
add('meilisearch', cfg.get('meilisearch_host', host), [cfg.get('meilisearch_http', 7700)])
add('influxdb', cfg.get('influxdb_host', host), [cfg.get('influxdb_http', 8086)])
add('ipfs', cfg.get('ipfs_host', host), [cfg.get('ipfs_api', 5001), cfg.get('ipfs_gateway', 8080)])
out = {
"ts": datetime.utcnow().isoformat() + 'Z',
"host": host,
"results": checks,
}
print(json.dumps(out, indent=2))
if __name__ == '__main__':
main()