import subprocess,urllib.request,json
cmds=[['systemctl','list-units','--type=service','--all','--no-pager'],['ss','-ltnp'],['ps','-eo','pid,etime,args']]
for cmd in cmds:
o=subprocess.run(cmd,capture_output=True,text=True,timeout=30).stdout
print('CMD', ' '.join(cmd)); print('\n'.join(x for x in o.splitlines() if any(k in x.lower() for k in ['youtube','dashboard','uvicorn','python3','8000','5000','9119','9130','8642']) or cmd[0]=='ss'))
for port in [5000,8000,9119,9130,8642]:
for path in ['/','/health','/openapi.json','/v1/dashboard']:
try:
r=urllib.request.urlopen(f'http://127.0.0.1:{port}{path}',timeout=3); data=r.read(400).decode('utf-8','replace'); print('HTTP',port,path,r.status,r.headers.get('content-type'),data[:200])
except Exception as e: print('HTTP',port,path,type(e).__name__,str(e)[:120])