Files
kefu/im/.deploy/check_remote_health.py
2026-09-03 08:38:17 +08:00

21 lines
948 B
Python

import hashlib,json,os,subprocess,urllib.request
from pathlib import Path
binary=Path('/www/server/xingyu-im/bt/xingyu-api')
print('binary',hashlib.sha256(binary.read_bytes()).hexdigest())
for proc in Path('/proc').iterdir():
if not proc.name.isdigit(): continue
try:
exe=os.readlink(str(proc/'exe'))
if 'xingyu' in exe:
print('process',proc.name,exe,hashlib.sha256((proc/'exe').read_bytes()).hexdigest())
except Exception: pass
for url in ['http://127.0.0.1:18888/healthz','https://im.bchongw.com/healthz']:
try:
with urllib.request.urlopen(url,timeout=10) as response:
print('health',url,response.status,response.read(1000).decode('utf-8','replace'))
except Exception as e: print('health-error',url,type(e).__name__,str(e))
print('project-files')
for p in sorted(Path('/www/server/xingyu-im').glob('**/*log*'))[:30]: print(str(p))
print('listening')
print(subprocess.run(['ss','-ltnp'],stdout=subprocess.PIPE,text=True).stdout)