58 lines
2.5 KiB
Python
58 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
p = paramiko.SSHClient()
|
|
p.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
p.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False)
|
|
sftp = p.open_sftp()
|
|
with sftp.open("/tmp/cov.py", "w") as f:
|
|
f.write(
|
|
"""
|
|
import sqlite3
|
|
c=sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
|
|
cols=[r[1] for r in c.execute("pragma table_info(sessions)")]
|
|
print("cols",[x for x in cols if "cover" in x.lower()])
|
|
for col in [x for x in cols if "cover" in x.lower()]:
|
|
rows=c.execute(f"select id, substr({col},1,140) from sessions where {col}!='' order by rowid desc limit 5").fetchall()
|
|
print(col, rows)
|
|
c.close()
|
|
"""
|
|
)
|
|
sftp.close()
|
|
_i, o, e = p.exec_command("echo '4669805' | sudo -S -p '' python3 /tmp/cov.py", timeout=40)
|
|
print("PHYS", (o.read() + e.read()).decode("utf-8", "replace"))
|
|
p.close()
|
|
|
|
v = paramiko.SSHClient()
|
|
v.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
v.connect("107.173.30.245", 22, "root", "Xiao4669805", timeout=40, allow_agent=False, look_for_keys=False)
|
|
_i, o, e = v.exec_command(
|
|
r"""
|
|
python3 - <<"PY"
|
|
import sqlite3
|
|
c=sqlite3.connect("/opt/douyinWEB/backend/data/monitor.db")
|
|
rows=c.execute("select id, substr(cover_path,1,160) from sessions where cover_path!='' order by rowid desc limit 8").fetchall()
|
|
for r in rows:
|
|
print(r)
|
|
n=c.execute("select count(*) from sessions where cover_path like 'C:%'").fetchone()[0]
|
|
print("bad_windows_paths", n)
|
|
n2=c.execute("select count(*) from sessions where cover_path like 'http%'").fetchone()[0]
|
|
print("http_paths", n2)
|
|
c.close()
|
|
PY
|
|
SID=$(python3 -c "import sqlite3;c=sqlite3.connect('/opt/douyinWEB/backend/data/monitor.db');print(c.execute(\"select id from sessions where cover_path!='' order by rowid desc limit 1\").fetchone()[0])")
|
|
echo SID=$SID
|
|
curl -sS -m 10 -o /dev/null -w "api_cover=%{http_code} ctype=%{content_type}\n" "http://127.0.0.1:8014/api/sessions/$SID/cover"
|
|
curl -sS -m 10 -o /dev/null -w "phys_s3_obj=%{http_code}\n" "http://127.0.0.1:28333/douyin-covers/covers/${SID}.jpg"
|
|
curl -sS -m 10 -o /dev/null -w "public_dy_obj=%{http_code}\n" "https://dy.nomadro.com/douyin-covers/covers/${SID}.jpg"
|
|
curl -sS -m 10 -o /dev/null -w "opsneko=%{http_code}\n" "https://dy.nomadro.com/ops-neko/1/"
|
|
curl -sS -m 10 -o /dev/null -w "covers_root=%{http_code}\n" "https://dy.nomadro.com/douyin-covers/"
|
|
""",
|
|
timeout=60,
|
|
)
|
|
print("VPS", (o.read() + e.read()).decode("utf-8", "replace"))
|
|
v.close()
|