87 lines
3.0 KiB
Python
87 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(
|
|
"107.173.30.245",
|
|
4014,
|
|
"eric",
|
|
"4669805",
|
|
timeout=45,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=120,
|
|
)
|
|
cmd = (
|
|
"echo '4669805' | sudo -S -p '' bash -lc "
|
|
"'sleep 8; docker exec -i douyinweb-neko-8 python3 - <<\"PY\"\n"
|
|
"import os,json,urllib.request\n"
|
|
"mains=0;load=False;sw=-1\n"
|
|
"for pid in os.listdir(\"/proc\"):\n"
|
|
" if not pid.isdigit(): continue\n"
|
|
" try: raw=open(f\"/proc/{pid}/cmdline\",\"rb\").read()\n"
|
|
" except: continue\n"
|
|
" if not raw: continue\n"
|
|
" if b\"google-chrome\" in raw and b\"--type=\" not in raw and b\"crashpad\" not in raw and b\"browser-launch\" not in raw:\n"
|
|
" mains+=1\n"
|
|
" if b\"load-extension\" in raw and b\"dhdgff\" in raw: load=True\n"
|
|
"try:\n"
|
|
" tabs=json.loads(urllib.request.urlopen(\"http://127.0.0.1:9222/json/list\",timeout=3).read())\n"
|
|
" sw=sum(1 for t in tabs if t.get(\"type\")==\"service_worker\" and \"dhdgff\" in (t.get(\"url\") or \"\"))\n"
|
|
"except Exception as e:\n"
|
|
" sw=str(e)\n"
|
|
"print(\"neko-8\", \"mains\",mains,\"load\",load,\"tm_sw\",sw)\n"
|
|
"PY\n"
|
|
"curl -sS -m 5 -o /dev/null -w \"cn_neko3=%{http_code} cn_neko8=%{http_code}\\n\" "
|
|
"https://dy.nomadro.cn/neko/3/ https://dy.nomadro.cn/neko/8/'"
|
|
)
|
|
# simpler via sftp script
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_recheck_n8.sh", "w") as f:
|
|
f.write(
|
|
"""#!/bin/bash
|
|
sleep 5
|
|
docker exec -i douyinweb-neko-8 python3 - <<'PY'
|
|
import os, json, urllib.request
|
|
mains=0; load=False; sw=-1
|
|
for pid in os.listdir("/proc"):
|
|
if not pid.isdigit(): continue
|
|
try: raw=open(f"/proc/{pid}/cmdline","rb").read()
|
|
except: continue
|
|
if not raw: continue
|
|
if b"google-chrome" in raw and b"--type=" not in raw and b"crashpad" not in raw and b"browser-launch" not in raw:
|
|
mains += 1
|
|
if b"load-extension" in raw and b"dhdgff" in raw: load=True
|
|
try:
|
|
tabs=json.loads(urllib.request.urlopen("http://127.0.0.1:9222/json/list",timeout=3).read())
|
|
sw=sum(1 for t in tabs if t.get("type")=="service_worker" and "dhdgff" in (t.get("url") or ""))
|
|
except Exception as e:
|
|
sw=repr(e)
|
|
print("neko-8", "mains", mains, "load", load, "tm_sw", sw)
|
|
PY
|
|
curl -sS -m 8 -o /dev/null -w 'cn_neko3=%{http_code}\\n' https://dy.nomadro.cn/neko/3/
|
|
curl -sS -m 8 -o /dev/null -w 'cn_neko8=%{http_code}\\n' https://dy.nomadro.cn/neko/8/
|
|
"""
|
|
)
|
|
sftp.close()
|
|
_i, o, e = c.exec_command(
|
|
"echo '4669805' | sudo -S -p '' bash /tmp/_recheck_n8.sh",
|
|
timeout=60,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|