#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Кто пишет rejected_signals и arena_l2_* — и почему замолчал. Только чтение.""" import os, re, subprocess def sh(c, t=90): try: r = subprocess.run(c, shell=True, capture_output=True, text=True, timeout=t) return (r.stdout or r.stderr or "").strip() except Exception as e: return f"<{type(e).__name__}>" ROOTS = "/opt/arena /opt/sovereign-v5" for table, label in (("rejected_signals", "ЖУРНАЛ ОТКАЗОВ"), ("arena_l2_", "СБОР СТАКАНА")): print("=" * 62) print(f"{label} ({table})") print("=" * 62) print("-- ПИШУТ (INSERT/COPY) --") w = sh(f"grep -rlE 'INSERT INTO {table}|COPY {table}|to_sql\\(.{table}' {ROOTS} " f"--include=*.py 2>/dev/null | head -8") print("\n".join(" " + x for x in w.splitlines()) or " не найдено") print("-- ЧИТАЮТ (SELECT) --") r = sh(f"grep -rlE 'FROM {table}|from {table}' {ROOTS} --include=*.py 2>/dev/null | head -8") rr = [x for x in r.splitlines() if x not in w.splitlines()] print("\n".join(" " + x for x in rr) or " не найдено") print("-- УПОМИНАНИЯ В ДАШБОРДАХ/КОНФИГАХ --") d = sh(f"grep -rl '{table}' {ROOTS} --include=*.json --include=*.sql " f"--include=*.service 2>/dev/null | head -5") print("\n".join(" " + x for x in d.splitlines()) or " не найдено") # живы ли процессы этих файлов print("-- ЗАПУЩЕНЫ ЛИ ЭТИ ФАЙЛЫ --") seen = set() for f in (w.splitlines() + rr)[:8]: b = os.path.basename(f) if b in seen: continue seen.add(b) n = sh(f"pgrep -fc '{b}'") unit = sh(f"systemctl list-units --all --no-legend --no-pager | grep -o '[a-z0-9-]*{b[:-3].replace('_','-')}[a-z0-9-]*\\.service' | head -1") print(f" {b:34} процессов: {n:>3} юнит: {unit or '—'}") print() print("=" * 62) print("ЧТО ВООБЩЕ ОСТАНОВИЛОСЬ ОКОЛО 20 ИЮЛЯ") print("=" * 62) print("-- сервисы, неактивные но включённые --") print(sh("systemctl list-unit-files --state=enabled --no-legend --no-pager | awk '{print $1}' | " "while read u; do s=$(systemctl is-active $u); " "[ \"$s\" != active ] && echo \" $u -> $s\"; done | head -20")) print("-- последняя запись в логах юнитов, что не активны --") print(sh("systemctl list-units --state=inactive,failed --no-legend --no-pager | " "grep -E 'arena|scanner|gate|filter' | awk '{print $1}' | head -8"))