diff --git a/docs/agent-integration.md b/docs/agent-integration.md index 746bae2..4a85c2a 100644 --- a/docs/agent-integration.md +++ b/docs/agent-integration.md @@ -76,8 +76,8 @@ Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000 ### 2.3. Spool при ошибке 1. Записать JSON в `SAC_SPOOL_DIR/{event_id}.json`. -2. Периодически (каждая итерация цикла / отдельный timer) повторять POST. -3. После успеха — удалить файл. +2. **ssh-monitor:** каждую итерацию цикла вызывается `sac_flush_spool` (до 20 файлов). +3. После успеха (HTTP 202) — удалить файл. 4. Лимит размера spool (например 500 MB) — логировать WARN, не удалять без алерта. --- diff --git a/docs/operations-prod-status.md b/docs/operations-prod-status.md index ce2e2f6..8b5caee 100644 --- a/docs/operations-prod-status.md +++ b/docs/operations-prod-status.md @@ -40,7 +40,7 @@ sudo /opt/sac-deploy.sh |----------|----------| | Хост | `ubabuba` / `10.10.36.9` | | Репозиторий | `git.kalinamall.ru/PapaTramp/ssh-monitor` (`main`, есть `sac-client.sh`) | -| `UseSAC` | `exclusive` (без Telegram на тесте) | +| `UseSAC` | пилот **exclusive** — см. [pilot-2.1-exclusive.md](pilot-2.1-exclusive.md) | | Сервис | `ssh-monitor.service` — **active** | | `--check-sac` | OK (health + ingest `agent.test` 202) | diff --git a/docs/pilot-2.1-exclusive.md b/docs/pilot-2.1-exclusive.md new file mode 100644 index 0000000..c968162 --- /dev/null +++ b/docs/pilot-2.1-exclusive.md @@ -0,0 +1,92 @@ +# Пилот 2.1 — UseSAC=exclusive + +Цель: один Linux-хост и (позже) один Windows-хост шлют **только в SAC**, без дублирования в Telegram с агента. + +--- + +## Linux (ssh-monitor) — ubabuba / новые хосты + +### 1. Обновить агент + +```bash +sudo /opt/scripts/update_ssh_monitor.sh +# или первично: sudo ./first_deploy.sh +``` + +### 2. Конфиг `/etc/ssh-monitor.conf` + +```ini +UseSAC=exclusive +SAC_URL=https://sac.kalinamall.ru +SAC_API_KEY=sac_xxxxxxxx +SAC_TLS_SKIP_VERIFY=0 +SAC_SPOOL_DIR=/var/lib/ssh-monitor/sac-spool +SAC_TIMEOUT_SEC=12 +``` + +Telegram/email **можно оставить** в конфиге — в `exclusive` они **не вызываются** для событий (`notify_or_sac` → только SAC). + +### 3. Проверки на агенте + +```bash +sudo /usr/local/bin/ssh-monitor --check-sac +sudo bash /opt/scripts/update/ssh-monitor/scripts/pilot-verify-exclusive.sh +# или из клона: +sudo bash /opt/scripts/update/ssh-monitor/scripts/pilot-verify-exclusive.sh + +sudo systemctl restart ssh-monitor.service +sudo systemctl status ssh-monitor.service --no-pager +``` + +### 4. Проверки в SAC + +1. UI → **Хосты** — появился/обновился хост пилота. +2. Сгенерировать: успешный SSH, `sudo` (успешный), при необходимости неудачный SSH. +3. UI → **События** — типы `ssh.login.success`, `privilege.sudo.command`, … +4. **Telegram бота агента** — новых сообщений от этого хоста **нет** (только SAC, если включён Telegram **сервера SAC** — это отдельно). +5. При `high`/`critical` — **Проблемы** и опционально Telegram из `TELEGRAM_*` в `sac-api.env`. + +### 5. Spool (сбой SAC) + +При недоступности SAC события пишутся в `SAC_SPOOL_DIR`. После восстановления SAC цикл монитора вызывает `sac_flush_spool` (до 20 файлов за итерацию). + +```bash +ls -la /var/lib/ssh-monitor/sac-spool/ +``` + +### 6. Откат на dual + +```ini +UseSAC=dual +``` + +```bash +sudo systemctl restart ssh-monitor.service +``` + +--- + +## Windows (RDP-login-monitor) + +**Статус:** интеграция UseSAC в RDP-monitor **ещё не реализована** — пилот 2.1 сейчас только **Linux**. + +После появления `UseSAC` в RDP — повторить сценарий с `Test-SacConnection` и событиями `rdp.login.*`. + +--- + +## Критерии приёмки 2.1 (Linux) + +| # | Критерий | +|---|----------| +| 1 | `UseSAC=exclusive`, сервис `active` | +| 2 | `--check-sac` → ingest OK | +| 3 | События видны в SAC UI | +| 4 | Telegram **агента** молчит | +| 5 | Spool очищается после восстановления SAC | + +--- + +## См. также + +- [agent-integration.md](agent-integration.md) +- [operations-prod-status.md](operations-prod-status.md) diff --git a/docs/work-plan.md b/docs/work-plan.md index 722f8a6..e3eb6e2 100644 --- a/docs/work-plan.md +++ b/docs/work-plan.md @@ -63,7 +63,7 @@ | # | Задача | |---|--------| -| 2.1 | E2E: 1 Linux + 1 Windows, `UseSAC=exclusive` | +| 2.1 | E2E: 1 Linux + 1 Windows, `UseSAC=exclusive` | 🔄 Linux: [pilot-2.1-exclusive.md](pilot-2.1-exclusive.md); Windows ⏳ RDP | | 2.2 | Daily report / heartbeat через SAC | | 2.3 | fallback на агентах |