diff --git a/.gitea/workflows/lint.yml b/.gitea/workflows/lint.yml index 109754b..4550a7a 100644 --- a/.gitea/workflows/lint.yml +++ b/.gitea/workflows/lint.yml @@ -24,16 +24,28 @@ jobs: run: | python3 - <<'PY' import re, subprocess, sys - files = subprocess.run(["git","ls-files"],capture_output=True,text=True).stdout.split() - pat = re.compile(r"(?i)(password|passwd|api[_-]?key|secret|token)\s*[:=]\s*['\"]?[A-Za-z0-9_\-]{16,}") - hits=[] + rules = { + "name": re.compile(r"(?i)\b(pass|passwd|password|pwd|pw|secret|token|api[_-]?key|apikey)[a-z0-9_]{0,16}[\"']?\s*[:=]\s*[\"']?([A-Za-z0-9_\-]{16,})"), + "dsn": re.compile(r"://[^:/\s@]{1,32}:([^@\s'\"%]{12,})@"), + } + def placeholder(v): + v = v.strip().strip("'\"") + if not v: return True + if v.upper().startswith(("REMOVED", "EXAMPLE", "PLACEHOLDER", "CHANGEME", "XXX")): return True + if v.startswith(("{{", "${", "<")): return True + if re.fullmatch(r"[a-z][a-z0-9]*(_[a-z0-9]+)+", v): return True + return re.fullmatch(r"[A-Z0-9_]{6,}", v) is not None + files = subprocess.run(["git", "ls-files"], capture_output=True, text=True).stdout.split() + hits = [] for f in files: - if f.endswith(('.md','.yml','.yaml','.py','.sh','.json','.ini','.conf','.env')): - try: t=open(f,encoding='utf-8',errors='ignore').read() - except Exception: continue - for m in pat.finditer(t): - if 'example' in m.group(0).lower() or 'placeholder' in m.group(0).lower(): continue - hits.append(f"{f}: подозрение на секрет") + if not f.endswith((".md", ".yml", ".yaml", ".py", ".sh", ".json", ".ini", ".conf", ".env")): continue + try: t = open(f, encoding="utf-8", errors="ignore").read() + except Exception: continue + for i, line in enumerate(t.splitlines(), 1): + for rule, rx in rules.items(): + m = rx.search(line) + if m and not placeholder(m.group(m.lastindex)): + hits.append("%s:%d (%s)" % (f, i, rule)) print("файлов проверено:", len(files)) if hits: print("\n".join(hits[:10])); sys.exit(1) diff --git a/infra/n8n/workflows/workflow-current.json b/infra/n8n/workflows/workflow-current.json index 15ec028..846d6d9 100644 --- a/infra/n8n/workflows/workflow-current.json +++ b/infra/n8n/workflows/workflow-current.json @@ -76,7 +76,7 @@ "parameters": [ { "name": "Authorization", - "value": "token 416f50c1a559be2def78bd6e3616a97906b0623d" + "value": "token {{GITEA_TOKEN}}" }, { "name": "Content-Type", diff --git a/ops/backups/n8n_workflows_2026-10-08_21-03.json b/ops/backups/n8n_workflows_2026-10-08_21-03.json index 47290df..dd6082e 100644 --- a/ops/backups/n8n_workflows_2026-10-08_21-03.json +++ b/ops/backups/n8n_workflows_2026-10-08_21-03.json @@ -1,3 +1,3 @@ Acquiring database migration lock... Deprecation warning: The storage directory "/home/node/.n8n/binaryData" will be renamed to "/home/node/.n8n/storage" in n8n v3. To migrate now, set N8N_MIGRATE_FS_STORAGE_PATH=true. If you have a volume mounted at the old path, update your mount configuration after migration. -[{"updatedAt":"2026-10-08T16:48:29.376Z","createdAt":"2026-09-11T12:37:51.879Z","id":"TSqu00NJx2JOrtoN","name":"Uptime Kuma → Gitea Self-Healing","description":null,"active":false,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"uptime-kuma","responseMode":"responseNode","options":{}},"name":"Uptime Kuma Webhook","webhookId":"95de5809-c2a6-4ba1-a472-89debbc46fbb","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[144,256],"id":"a4c37fdc-fe82-4d53-8cd9-0d6af7afc90f"},{"parameters":{"jsCode":"const webhookData = $input.first().json;\nconst body = webhookData.body || webhookData;\n\n// УМНАЯ ПРОВЕРКА: если monitor_name пуст или 'Unknown', берем домен из URL\nlet monitorName = body.monitor_name || 'Unknown';\nif (monitorName === 'Unknown' || !monitorName) {\n const url = body.monitor_url || '';\n monitorName = url ? url.replace(/https?:\\/\\//, '').split('/')[0] : 'Unknown Service';\n}\n\nconst monitorUrl = body.monitor_url || 'N/A';\nconst status = parseInt(body.heartbeat_status) || 0;\nconst message = body.heartbeat_message || 'Service is down';\n\nconst ctMatch = monitorName.match(/\\((\\d+)\\)/);\nconst ctId = ctMatch ? ctMatch[1] : null;\n\n// Создаем четкий заголовок для Gitea\nconst giteaTitle = `AUTO-FIX: ${monitorName} DOWN`;\n\nreturn [{\n json: {\n monitorName,\n monitorUrl,\n status,\n message,\n ctId,\n giteaTitle,\n timestamp: new Date().toISOString(),\n shouldAlert: status === 0 && ctId !== null\n }\n}];"},"name":"Extract Info","type":"n8n-nodes-base.code","typeVersion":2,"position":[368,256],"id":"23e46b7d-28db-4d26-b90b-f86f49d216bc"},{"parameters":{"conditions":{"boolean":[{"value1":"={{ $json.shouldAlert }}","value2":true}],"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":1},"combinator":"and"},"options":{}},"name":"Should Create Issue?","type":"n8n-nodes-base.if","typeVersion":2,"position":[608,256],"id":"2b7f557f-8d80-4266-8f67-6b1dc3c38f25"},{"parameters":{"method":"POST","url":"http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token 416f50c1a559be2def78bd6e3616a97906b0623d"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ JSON.stringify({ title: $json.giteaTitle, body: \"CT_DOWN: \" + $json.ctId + \"\\n\\nАвтоматическое восстановление: \" + $json.monitorName + \".\\n\\nURL: \" + $json.monitorUrl + \"\\nMessage: \" + $json.message + \"\\nTime: \" + $json.timestamp, labels: [2] }) }}","options":{}},"name":"Create Gitea Issue","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[832,160],"id":"40bcfe34-b905-4ab2-ac2d-5de5ad5e9d5b"},{"parameters":{"method":"POST","url":"https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/sendMessage","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"bodyParameters":{"parameters":[{"name":"chat_id","value":"=273442500"},{"name":"text","value":"=🚨 {{ $json.monitorName }} DOWN\n\nURL: {{ $json.monitorUrl }}\nВремя: {{ new Date().toLocaleString(\"ru-RU\") }}\n\n✅ Issue создан в Gitea: {{ $json.giteaTitle }}"},{"name":"parse_mode","value":"HTML"}]},"options":{"allowUnauthorizedCerts":true}},"name":"Notify Telegram","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1088,256],"id":"9cbd83b9-944f-4d3f-9803-62ccf51cd458"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ ok: true, issue_created: $json.html_url || null }) }}","options":{}},"name":"Respond","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1312,256],"id":"6eac3128-5c63-4315-89af-4fb0be610522"}],"connections":{"Uptime Kuma Webhook":{"main":[[{"node":"Extract Info","type":"main","index":0}]]},"Extract Info":{"main":[[{"node":"Should Create Issue?","type":"main","index":0}]]},"Should Create Issue?":{"main":[[{"node":"Create Gitea Issue","type":"main","index":0}]]},"Create Gitea Issue":{"main":[[{"node":"Notify Telegram","type":"main","index":0}]]},"Notify Telegram":{"main":[[{"node":"Respond","type":"main","index":0}]]}},"settings":{"binaryMode":"separate","executionOrder":"v1"},"staticData":null,"meta":null,"nodeGroups":[],"pinData":{},"versionId":"804c1a12-b975-4e70-853e-5294085461b9","activeVersionId":null,"versionCounter":7,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T17:32:23.758Z","createdAt":"2026-10-06T17:32:23.758Z","role":"workflow:owner","workflowId":"TSqu00NJx2JOrtoN","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":"V2","description":""}},{"updatedAt":"2026-10-08T16:33:21.076Z","createdAt":"2026-08-03T21:21:20.902Z","id":"afdmDW35vpDd6oNs","name":"Buryan Health Monitor","description":null,"active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"buryan-health","options":{}},"type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"id":"4970a1ff-d80f-4b39-a443-07bd2954186b","name":"Webhook","webhookId":"9c0ce777-9b87-44f1-b800-38f5c8fba650"},{"parameters":{"operation":"executeQuery","query":"SELECT CASE WHEN h.host IS NULL THEN 0 ELSE 1 END AS has_prev, COALESCE(h.failed,0) AS failed, COALESCE(h.mem,0) AS mem, COALESCE(h.disk,0) AS disk FROM (VALUES (1)) v LEFT JOIN host_states h ON h.host = '{{ $json.body.host }}'","options":{}},"id":"getprevstate","name":"Get Prev State","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[272,304],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"jsCode":"const body = $('Webhook').first().json.body || {};\nconst prevRows = $('Get Prev State').all();\nconst prev = (prevRows.length && prevRows[0].json.has_prev) ? prevRows[0].json : null;\nconst failed = body.failed || 0, mem = body.mem || 0, disk = body.disk || 0;\nconst alerts = [];\n\nif (!prev) {\n if (failed > 0) alerts.push('❌ Упало контейнеров: ' + failed);\n if (mem >= 90) alerts.push('❌ Память критична: ' + mem + '%');\n if (disk >= 90) alerts.push('❌ Диск критичен: ' + disk + '%');\n} else {\n const pf = prev.failed || 0, pm = prev.mem || 0, pd = prev.disk || 0;\n \n // failed изменения\n if (pf === 0 && failed > 0) alerts.push('❌ Упало контейнеров: ' + failed);\n if (pf > 0 && failed === 0) alerts.push('✅ Контейнеры восстановлены');\n \n // mem изменения (переход через 90)\n if (pm < 90 && mem >= 90) alerts.push('❌ Память критична: ' + mem + '%');\n if (pm >= 90 && mem < 90) alerts.push('✅ Память в норме: ' + mem + '%');\n \n // disk изменения (переход через 90)\n if (pd < 90 && disk >= 90) alerts.push('❌ Диск критичен: ' + disk + '%');\n if (pd >= 90 && disk < 90) alerts.push('✅ Диск в норме: ' + disk + '%');\n}\n\nreturn [{ json: {\n send_alert: alerts.length > 0,\n alert_text: alerts.join('\\n'),\n host: body.host || 'unknown',\n ip: body.ip || '',\n failed: failed,\n restarted: body.restarted || 0,\n mem: mem,\n disk: disk,\n containers: JSON.stringify(body.containers || []).replace(/'/g, \"''\")\n}}];\n"},"name":"Compare States","type":"n8n-nodes-base.code","typeVersion":2,"position":[464,304],"id":"comparestates"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":1},"conditions":[{"leftValue":"={{ $json.send_alert }}","rightValue":true,"operator":{"type":"boolean","operation":"equals","singleValue":true}}],"combinator":"and"},"options":{}},"name":"State Changed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[672,304],"id":"statechanged"},{"parameters":{"operation":"executeQuery","query":"INSERT INTO host_states (host, ip, failed, restarted, mem, disk, containers, last_report_at, last_alert_sent) VALUES ('{{ $('Compare States').first().json.host }}', '{{ $('Compare States').first().json.ip }}', {{ $('Compare States').first().json.failed }}, {{ $('Compare States').first().json.restarted }}, {{ $('Compare States').first().json.mem }}, {{ $('Compare States').first().json.disk }}, '{{ $('Compare States').first().json.containers }}'::jsonb, NOW(), NOW()) ON CONFLICT (host) DO UPDATE SET ip=EXCLUDED.ip, failed=EXCLUDED.failed, restarted=EXCLUDED.restarted, mem=EXCLUDED.mem, disk=EXCLUDED.disk, containers=EXCLUDED.containers, last_report_at=NOW(), last_alert_sent=NOW()","options":{}},"id":"upsertwithalert","name":"Upsert With Alert","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[1072,112],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"operation":"executeQuery","query":"INSERT INTO host_states (host, ip, failed, restarted, mem, disk, containers, last_report_at)\nVALUES ('{{ $json.host }}', '{{ $json.ip }}', {{ $json.failed }}, {{ $json.restarted }}, {{ $json.mem }}, {{ $json.disk }}, '{{ $json.containers }}'::jsonb, NOW())\nON CONFLICT (host) DO UPDATE SET ip=EXCLUDED.ip, failed=EXCLUDED.failed, restarted=EXCLUDED.restarted, mem=EXCLUDED.mem, disk=EXCLUDED.disk, containers=EXCLUDED.containers, last_report_at=NOW()","options":{}},"id":"upsertnoalert","name":"Upsert No Alert","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[864,464],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"operation":"executeQuery","query":"INSERT INTO alert_queue (host, ip, alert_type, alert_text, mem, disk)\nVALUES (\n '{{ $('Compare States').first().json.host }}',\n '{{ $('Compare States').first().json.ip }}',\n CASE\n WHEN {{ $('Compare States').first().json.failed }} > 0 THEN 'failed_up'\n WHEN {{ $('Compare States').first().json.failed }} = 0 THEN 'failed_down'\n WHEN {{ $('Compare States').first().json.mem }} >= 90 THEN 'mem_up'\n WHEN {{ $('Compare States').first().json.mem }} < 90 THEN 'mem_down'\n WHEN {{ $('Compare States').first().json.disk }} >= 90 THEN 'disk_up'\n WHEN {{ $('Compare States').first().json.disk }} < 90 THEN 'disk_down'\n END,\n '{{ $('Compare States').first().json.alert_text }}',\n {{ $('Compare States').first().json.mem }},\n {{ $('Compare States').first().json.disk }}\n)","options":{}},"id":"insertqueue","name":"Insert Alert Queue","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[864,208],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}}],"connections":{"Webhook":{"main":[[{"node":"Get Prev State","type":"main","index":0}]]},"Get Prev State":{"main":[[{"node":"Compare States","type":"main","index":0}]]},"Compare States":{"main":[[{"node":"State Changed?","type":"main","index":0}]]},"State Changed?":{"main":[[{"node":"Insert Alert Queue","type":"main","index":0}],[{"node":"Upsert No Alert","type":"main","index":0}]]},"Insert Alert Queue":{"main":[[{"node":"Upsert With Alert","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","binaryMode":"separate","availableInMCP":false},"staticData":null,"meta":{"templateCredsSetupCompleted":true},"nodeGroups":[],"pinData":{},"versionId":"09e76e04-d673-46c8-a667-83f204b41ebd","activeVersionId":"48842de3-9f90-406a-a370-97d95d3cac1e","versionCounter":89,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T14:23:30.310Z","createdAt":"2026-10-06T14:23:30.310Z","role":"workflow:owner","workflowId":"afdmDW35vpDd6oNs","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":null,"description":null}},{"updatedAt":"2026-10-08T17:44:54.325Z","createdAt":"2026-08-05T20:15:42.923Z","id":"alertQueueProc01","name":"Alert Queue Processor","description":null,"active":true,"isArchived":false,"nodes":[{"parameters":{"rule":{"interval":[{"field":"minutes","minutesInterval":15}]}},"name":"Every 15 Minutes","type":"n8n-nodes-base.scheduleTrigger","typeVersion":1.2,"position":[-3248,176],"id":"88fea6e5-007b-4b94-86bf-d8df2816a5cb"},{"parameters":{"operation":"executeQuery","query":"SELECT * FROM alert_queue ORDER BY created_at","options":{}},"name":"Get Queue","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-3024,176],"id":"632431bf-21f0-47ac-b5e3-e8735c2544f4","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"jsCode":"const items = $('Get Queue').all();\nif (items.length === 0) return [];\nconst alerts = items.map(i => i.json);\nconst grouped = {};\nfor (const a of alerts) {\n const key = `${a.host}_${a.ip}`;\n if (!grouped[key]) {\n grouped[key] = { symptom_key: key, host: a.host, ip: a.ip, alert_texts: new Set(), count: 0 };\n }\n grouped[key].alert_texts.add(a.alert_text);\n grouped[key].count++;\n}\nreturn Object.values(grouped).map(g => ({ json: { symptom_key: g.symptom_key, host: g.host, ip: g.ip, alert_text: Array.from(g.alert_texts).join('\\n'), alert_count: g.count } }));"},"name":"Group Alerts by Host","type":"n8n-nodes-base.code","typeVersion":2,"position":[-2800,176],"id":"4f318f7c-da0e-41b9-b033-cc2c4fb1e418"},{"parameters":{"operation":"executeQuery","query":"INSERT INTO alert_history (host, ip, alert_text) VALUES ('{{ $json.host }}', '{{ $json.ip }}', '{{ $json.alert_text }}');","options":{}},"name":"Log to History","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-2576,-32],"id":"b63c72a2-4c18-478a-ad31-02931ab10095","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"operation":"executeQuery","query":"SELECT COUNT(*) as failure_count FROM alert_history WHERE host = '{{ $json.host }}' AND created_at >= NOW() - INTERVAL '1 hour';","options":{}},"name":"Check Failure Count","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-2352,176],"id":"be7b88e4-8951-42de-985f-8e0c92badf85","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"url":"http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues?state=open&q={{ $json.symptom_key }}","sendQuery":true,"queryParameters":{"parameters":[{"name":"state","value":"open"},{"name":"q","value":"={{ $json.symptom_key }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token 416f50c1a559be2def78bd6e3616a97906b0623d"},{"name":"Content-Type","value":"application/json"}]},"options":{}},"name":"Check Gitea Issues","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-2128,64],"id":"c69d7159-79df-4a49-8bd4-f70c5c8bc63e"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":1},"conditions":[{"id":"1","leftValue":"={{ $input.all().length }}","rightValue":0,"operator":{"type":"number","operation":"gt"}}],"combinator":"and"},"options":{}},"name":"IF: Issue Exists?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[-1904,64],"id":"6c70677e-b95f-499b-b7ef-9a0540d86dfa"},{"parameters":{"method":"POST","url":"=http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues/{{ $json[0].number }}/comments","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token 416f50c1a559be2def78bd6e3616a97906b0623d"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={\"body\": \"🔄 **Повторный алерт зафиксирован**\\n⏰ Время: {{ $now.format('HH:mm:ss') }}\\n Сбоев за час: {{ $json.failure_count }}\\n\\n📝 Детали:\\n{{ $('Group Alerts by Host').first().json.alert_text }}\"}","options":{}},"name":"Add Comment to Gitea","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-1680,-48],"id":"87b7dcfc-1fbd-4485-b1f2-3d7a706ab260"},{"parameters":{"method":"POST","url":"http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token 416f50c1a559be2def78bd6e3616a97906b0623d"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={\n \"title\": \"🚨 Алерт: {{ $json.host }} ({{ $json.ip }})\",\n \"body\": \"## Автоматически зафиксирован сбой\\n\\n**Хост:** {{ $json.host }}\\n**IP:** {{ $json.ip }}\\n**Сбоев за час:** {{ $json.failure_count }}\\n\\n### Детали алертов:\\n{{ $json.alert_text }}\",\n \"labels\": {{ $json.failure_count >= 3 ? '[\"alert\", \"sev:1\", \"critical\"]' : '[\"alert\", \"monitoring\"]' }}\n}","options":{}},"name":"Create Gitea Issue","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-1680,176],"id":"b7a93d40-63ad-4551-a4fa-c6026d26f253"},{"parameters":{"jsCode":"// Получаем данные из Group Alerts by Host\nconst groupedAlerts = $('Group Alerts by Host').all();\nconst alerts = groupedAlerts.map(i => i.json);\n\n// Получаем счетчики сбоев из Check Failure Count\nconst failureCounts = $('Check Failure Count').all();\nconst counts = failureCounts.map(i => i.json);\n\n// Объединяем данные\nconst merged = alerts.map((alert, index) => {\n const count = counts[index] || { failure_count: 0 };\n return {\n ...alert,\n failure_count: count.failure_count || 0\n };\n});\n\n// Проверяем, есть ли SEV:1 (3+ сбоя за час)\nconst hasSev1 = merged.some(h => h.failure_count >= 3);\n\nreturn [{\n json: {\n total_hosts: merged.length,\n hosts: merged,\n is_sev1: hasSev1,\n telegram_text: hasSev1\n ? `🚨 SEV:1 КРИТИЧЕСКИЙ ИНЦИДЕНТ\\n\\nВнимание! Один из сервисов превышает лимит сбоев (3+ раза в час).\\n\\n${merged.map(h => `• ${h.host} (${h.ip}): ${h.alert_count} событий\\n⚠️ Сбоев за час: ${h.failure_count}\\n${h.alert_text}`).join('\\n\\n')}\\n\\n Тикеты в Gitea`\n : ` Сводка алертов\\nВсего хостов с проблемами: ${merged.length}\\n\\n${merged.map(h => `• ${h.host} (${h.ip}): ${h.alert_count} событий\\n${h.alert_text}`).join('\\n\\n')}\\n\\n🔗 Тикеты в Gitea`\n }\n}];"},"name":"Aggregate for Telegram","type":"n8n-nodes-base.code","typeVersion":2,"position":[-2320,416],"id":"18613373-8814-47f4-a34e-8fdd1c3778a8"},{"parameters":{"method":"POST","url":"https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/sendMessage","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"bodyParameters":{"parameters":[{"name":"chat_id","value":"=273442500"},{"name":"text","value":"={{ $json.telegram_text }}"},{"name":"parse_mode","value":"HTML"}]},"options":{"allowUnauthorizedCerts":true}},"name":"Notify Telegram (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-2096,416],"id":"6474e66a-b860-491e-974f-baa08129f6d1"},{"parameters":{"operation":"executeQuery","query":"DELETE FROM alert_queue","options":{}},"name":"Clear Queue","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-1712,416],"id":"39e6b139-126d-4f23-8a87-c162fa09a77e","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}}],"connections":{"Every 15 Minutes":{"main":[[{"node":"Get Queue","type":"main","index":0}]]},"Get Queue":{"main":[[{"node":"Group Alerts by Host","type":"main","index":0}]]},"Group Alerts by Host":{"main":[[{"node":"Log to History","type":"main","index":0},{"node":"Check Failure Count","type":"main","index":0}]]},"Log to History":{"main":[[]]},"Check Failure Count":{"main":[[{"node":"Check Gitea Issues","type":"main","index":0},{"node":"Aggregate for Telegram","type":"main","index":0}]]},"Check Gitea Issues":{"main":[[{"node":"IF: Issue Exists?","type":"main","index":0}]]},"IF: Issue Exists?":{"main":[[{"node":"Add Comment to Gitea","type":"main","index":0}],[{"node":"Create Gitea Issue","type":"main","index":0}]]},"Add Comment to Gitea":{"main":[[{"node":"Clear Queue","type":"main","index":0}]]},"Create Gitea Issue":{"main":[[{"node":"Clear Queue","type":"main","index":0}]]},"Aggregate for Telegram":{"main":[[{"node":"Notify Telegram (HTTP)","type":"main","index":0}]]},"Notify Telegram (HTTP)":{"main":[[{"node":"Clear Queue","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","binaryMode":"separate"},"staticData":{"node:Every 15 Minutes":{"recurrenceRules":[null],"recurrenceRuleSignatures":[null]}},"meta":{"templateCredsSetupCompleted":true},"nodeGroups":[],"pinData":{},"versionId":"ce6b893a-58a9-439a-a94c-d4f2f979204d","activeVersionId":"ce6b893a-58a9-439a-a94c-d4f2f979204d","versionCounter":55,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T17:28:32.499Z","createdAt":"2026-10-06T17:28:32.499Z","role":"workflow:owner","workflowId":"alertQueueProc01","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":"v3.1","description":""}},{"updatedAt":"2026-10-06T15:43:20.990Z","createdAt":"2026-10-06T14:23:27.246Z","id":"eqYDYibHxBt8NPq4","name":"Gitea Task Dispatcher","description":null,"active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"gitea-task","options":{}},"name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"webhookId":"fe5c7ad8-99fa-45f5-8e75-a365d7f08ae22","id":"f97c8348-ad40-470f-b891-67d468383566"},{"parameters":{"jsCode":"const w = $input.first().json;\nconst d = w.body || {};\nconst action = d.action || '';\nif (action !== 'opened' && action !== 'closed') return [];\nconst i = d.issue || {};\nconst r = d.repository || {};\nconst prefix = action === 'closed' ? 'CLOSED' : 'NEW';\nconst text = prefix + ' ' + (i.title || '?') + ' #' + (i.number || '?') + ' in ' + (r.full_name || '?') + '\\n' + (i.html_url || '');\nreturn [{ json: { text: text, critical: action === 'closed', repo: r.full_name || '?', alert_type: 'gitea_issue_' + action, alert_text: text } }];"},"name":"Parse","type":"n8n-nodes-base.code","typeVersion":2,"position":[240,0],"id":"d751f61e-ee10-4203-8f53-21ac59196b90"},{"parameters":{"jsCode":"return $input.all().filter(it => it.json.critical);"},"name":"OnlyCritical","type":"n8n-nodes-base.code","typeVersion":2,"position":[480,-120],"id":"2effd388-fee0-47b6-a223-63831696e8e8"},{"parameters":{"chatId":"273442500","text":"={{ $json.text }}"},"name":"Telegram Send","type":"n8n-nodes-base.telegram","typeVersion":1.2,"position":[720,-120],"credentials":{"telegramApi":{"id":"MI5ZSM5d514km2wE","name":"Telegram Bot"}},"id":"9d6c2a9b-2a11-4fbc-b479-57c460706978"},{"parameters":{"operation":"insert","schema":{"__rl":true,"mode":"name","value":"public"},"table":{"__rl":true,"mode":"name","value":"alert_queue"},"columns":{"mappingMode":"defineBelow","value":{"host":"={{ $json.repo }}","alert_type":"={{ $json.alert_type }}","alert_text":"={{ $json.alert_text }}"}},"options":{}},"name":"Queue Insert","type":"n8n-nodes-base.postgres","typeVersion":2.5,"position":[480,120],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}},"id":"e8e2414b-7ac2-459f-8428-bca69e594a4a"}],"connections":{"Webhook":{"main":[[{"node":"Parse","type":"main","index":0}]]},"Parse":{"main":[[{"node":"OnlyCritical","type":"main","index":0},{"node":"Queue Insert","type":"main","index":0}]]},"OnlyCritical":{"main":[[{"node":"Telegram Send","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"nodeGroups":[],"pinData":null,"versionId":"0eb5a8e3-8884-4926-bc3b-ec40f768acc0","activeVersionId":"0eb5a8e3-8884-4926-bc3b-ec40f768acc0","versionCounter":1,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T14:23:27.246Z","createdAt":"2026-10-06T14:23:27.246Z","role":"workflow:owner","workflowId":"eqYDYibHxBt8NPq4","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":null,"description":null}}] +[{"updatedAt":"2026-10-08T16:48:29.376Z","createdAt":"2026-09-11T12:37:51.879Z","id":"TSqu00NJx2JOrtoN","name":"Uptime Kuma → Gitea Self-Healing","description":null,"active":false,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"uptime-kuma","responseMode":"responseNode","options":{}},"name":"Uptime Kuma Webhook","webhookId":"95de5809-c2a6-4ba1-a472-89debbc46fbb","type":"n8n-nodes-base.webhook","typeVersion":2,"position":[144,256],"id":"a4c37fdc-fe82-4d53-8cd9-0d6af7afc90f"},{"parameters":{"jsCode":"const webhookData = $input.first().json;\nconst body = webhookData.body || webhookData;\n\n// УМНАЯ ПРОВЕРКА: если monitor_name пуст или 'Unknown', берем домен из URL\nlet monitorName = body.monitor_name || 'Unknown';\nif (monitorName === 'Unknown' || !monitorName) {\n const url = body.monitor_url || '';\n monitorName = url ? url.replace(/https?:\\/\\//, '').split('/')[0] : 'Unknown Service';\n}\n\nconst monitorUrl = body.monitor_url || 'N/A';\nconst status = parseInt(body.heartbeat_status) || 0;\nconst message = body.heartbeat_message || 'Service is down';\n\nconst ctMatch = monitorName.match(/\\((\\d+)\\)/);\nconst ctId = ctMatch ? ctMatch[1] : null;\n\n// Создаем четкий заголовок для Gitea\nconst giteaTitle = `AUTO-FIX: ${monitorName} DOWN`;\n\nreturn [{\n json: {\n monitorName,\n monitorUrl,\n status,\n message,\n ctId,\n giteaTitle,\n timestamp: new Date().toISOString(),\n shouldAlert: status === 0 && ctId !== null\n }\n}];"},"name":"Extract Info","type":"n8n-nodes-base.code","typeVersion":2,"position":[368,256],"id":"23e46b7d-28db-4d26-b90b-f86f49d216bc"},{"parameters":{"conditions":{"boolean":[{"value1":"={{ $json.shouldAlert }}","value2":true}],"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":1},"combinator":"and"},"options":{}},"name":"Should Create Issue?","type":"n8n-nodes-base.if","typeVersion":2,"position":[608,256],"id":"2b7f557f-8d80-4266-8f67-6b1dc3c38f25"},{"parameters":{"method":"POST","url":"http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token {{GITEA_TOKEN}}"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ JSON.stringify({ title: $json.giteaTitle, body: \"CT_DOWN: \" + $json.ctId + \"\\n\\nАвтоматическое восстановление: \" + $json.monitorName + \".\\n\\nURL: \" + $json.monitorUrl + \"\\nMessage: \" + $json.message + \"\\nTime: \" + $json.timestamp, labels: [2] }) }}","options":{}},"name":"Create Gitea Issue","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[832,160],"id":"40bcfe34-b905-4ab2-ac2d-5de5ad5e9d5b"},{"parameters":{"method":"POST","url":"https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/sendMessage","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"bodyParameters":{"parameters":[{"name":"chat_id","value":"=273442500"},{"name":"text","value":"=🚨 {{ $json.monitorName }} DOWN\n\nURL: {{ $json.monitorUrl }}\nВремя: {{ new Date().toLocaleString(\"ru-RU\") }}\n\n✅ Issue создан в Gitea: {{ $json.giteaTitle }}"},{"name":"parse_mode","value":"HTML"}]},"options":{"allowUnauthorizedCerts":true}},"name":"Notify Telegram","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1088,256],"id":"9cbd83b9-944f-4d3f-9803-62ccf51cd458"},{"parameters":{"respondWith":"json","responseBody":"={{ JSON.stringify({ ok: true, issue_created: $json.html_url || null }) }}","options":{}},"name":"Respond","type":"n8n-nodes-base.respondToWebhook","typeVersion":1.1,"position":[1312,256],"id":"6eac3128-5c63-4315-89af-4fb0be610522"}],"connections":{"Uptime Kuma Webhook":{"main":[[{"node":"Extract Info","type":"main","index":0}]]},"Extract Info":{"main":[[{"node":"Should Create Issue?","type":"main","index":0}]]},"Should Create Issue?":{"main":[[{"node":"Create Gitea Issue","type":"main","index":0}]]},"Create Gitea Issue":{"main":[[{"node":"Notify Telegram","type":"main","index":0}]]},"Notify Telegram":{"main":[[{"node":"Respond","type":"main","index":0}]]}},"settings":{"binaryMode":"separate","executionOrder":"v1"},"staticData":null,"meta":null,"nodeGroups":[],"pinData":{},"versionId":"804c1a12-b975-4e70-853e-5294085461b9","activeVersionId":null,"versionCounter":7,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T17:32:23.758Z","createdAt":"2026-10-06T17:32:23.758Z","role":"workflow:owner","workflowId":"TSqu00NJx2JOrtoN","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":"V2","description":""}},{"updatedAt":"2026-10-08T16:33:21.076Z","createdAt":"2026-08-03T21:21:20.902Z","id":"afdmDW35vpDd6oNs","name":"Buryan Health Monitor","description":null,"active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"buryan-health","options":{}},"type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"id":"4970a1ff-d80f-4b39-a443-07bd2954186b","name":"Webhook","webhookId":"9c0ce777-9b87-44f1-b800-38f5c8fba650"},{"parameters":{"operation":"executeQuery","query":"SELECT CASE WHEN h.host IS NULL THEN 0 ELSE 1 END AS has_prev, COALESCE(h.failed,0) AS failed, COALESCE(h.mem,0) AS mem, COALESCE(h.disk,0) AS disk FROM (VALUES (1)) v LEFT JOIN host_states h ON h.host = '{{ $json.body.host }}'","options":{}},"id":"getprevstate","name":"Get Prev State","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[272,304],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"jsCode":"const body = $('Webhook').first().json.body || {};\nconst prevRows = $('Get Prev State').all();\nconst prev = (prevRows.length && prevRows[0].json.has_prev) ? prevRows[0].json : null;\nconst failed = body.failed || 0, mem = body.mem || 0, disk = body.disk || 0;\nconst alerts = [];\n\nif (!prev) {\n if (failed > 0) alerts.push('❌ Упало контейнеров: ' + failed);\n if (mem >= 90) alerts.push('❌ Память критична: ' + mem + '%');\n if (disk >= 90) alerts.push('❌ Диск критичен: ' + disk + '%');\n} else {\n const pf = prev.failed || 0, pm = prev.mem || 0, pd = prev.disk || 0;\n \n // failed изменения\n if (pf === 0 && failed > 0) alerts.push('❌ Упало контейнеров: ' + failed);\n if (pf > 0 && failed === 0) alerts.push('✅ Контейнеры восстановлены');\n \n // mem изменения (переход через 90)\n if (pm < 90 && mem >= 90) alerts.push('❌ Память критична: ' + mem + '%');\n if (pm >= 90 && mem < 90) alerts.push('✅ Память в норме: ' + mem + '%');\n \n // disk изменения (переход через 90)\n if (pd < 90 && disk >= 90) alerts.push('❌ Диск критичен: ' + disk + '%');\n if (pd >= 90 && disk < 90) alerts.push('✅ Диск в норме: ' + disk + '%');\n}\n\nreturn [{ json: {\n send_alert: alerts.length > 0,\n alert_text: alerts.join('\\n'),\n host: body.host || 'unknown',\n ip: body.ip || '',\n failed: failed,\n restarted: body.restarted || 0,\n mem: mem,\n disk: disk,\n containers: JSON.stringify(body.containers || []).replace(/'/g, \"''\")\n}}];\n"},"name":"Compare States","type":"n8n-nodes-base.code","typeVersion":2,"position":[464,304],"id":"comparestates"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":1},"conditions":[{"leftValue":"={{ $json.send_alert }}","rightValue":true,"operator":{"type":"boolean","operation":"equals","singleValue":true}}],"combinator":"and"},"options":{}},"name":"State Changed?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[672,304],"id":"statechanged"},{"parameters":{"operation":"executeQuery","query":"INSERT INTO host_states (host, ip, failed, restarted, mem, disk, containers, last_report_at, last_alert_sent) VALUES ('{{ $('Compare States').first().json.host }}', '{{ $('Compare States').first().json.ip }}', {{ $('Compare States').first().json.failed }}, {{ $('Compare States').first().json.restarted }}, {{ $('Compare States').first().json.mem }}, {{ $('Compare States').first().json.disk }}, '{{ $('Compare States').first().json.containers }}'::jsonb, NOW(), NOW()) ON CONFLICT (host) DO UPDATE SET ip=EXCLUDED.ip, failed=EXCLUDED.failed, restarted=EXCLUDED.restarted, mem=EXCLUDED.mem, disk=EXCLUDED.disk, containers=EXCLUDED.containers, last_report_at=NOW(), last_alert_sent=NOW()","options":{}},"id":"upsertwithalert","name":"Upsert With Alert","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[1072,112],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"operation":"executeQuery","query":"INSERT INTO host_states (host, ip, failed, restarted, mem, disk, containers, last_report_at)\nVALUES ('{{ $json.host }}', '{{ $json.ip }}', {{ $json.failed }}, {{ $json.restarted }}, {{ $json.mem }}, {{ $json.disk }}, '{{ $json.containers }}'::jsonb, NOW())\nON CONFLICT (host) DO UPDATE SET ip=EXCLUDED.ip, failed=EXCLUDED.failed, restarted=EXCLUDED.restarted, mem=EXCLUDED.mem, disk=EXCLUDED.disk, containers=EXCLUDED.containers, last_report_at=NOW()","options":{}},"id":"upsertnoalert","name":"Upsert No Alert","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[864,464],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"operation":"executeQuery","query":"INSERT INTO alert_queue (host, ip, alert_type, alert_text, mem, disk)\nVALUES (\n '{{ $('Compare States').first().json.host }}',\n '{{ $('Compare States').first().json.ip }}',\n CASE\n WHEN {{ $('Compare States').first().json.failed }} > 0 THEN 'failed_up'\n WHEN {{ $('Compare States').first().json.failed }} = 0 THEN 'failed_down'\n WHEN {{ $('Compare States').first().json.mem }} >= 90 THEN 'mem_up'\n WHEN {{ $('Compare States').first().json.mem }} < 90 THEN 'mem_down'\n WHEN {{ $('Compare States').first().json.disk }} >= 90 THEN 'disk_up'\n WHEN {{ $('Compare States').first().json.disk }} < 90 THEN 'disk_down'\n END,\n '{{ $('Compare States').first().json.alert_text }}',\n {{ $('Compare States').first().json.mem }},\n {{ $('Compare States').first().json.disk }}\n)","options":{}},"id":"insertqueue","name":"Insert Alert Queue","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[864,208],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}}],"connections":{"Webhook":{"main":[[{"node":"Get Prev State","type":"main","index":0}]]},"Get Prev State":{"main":[[{"node":"Compare States","type":"main","index":0}]]},"Compare States":{"main":[[{"node":"State Changed?","type":"main","index":0}]]},"State Changed?":{"main":[[{"node":"Insert Alert Queue","type":"main","index":0}],[{"node":"Upsert No Alert","type":"main","index":0}]]},"Insert Alert Queue":{"main":[[{"node":"Upsert With Alert","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","binaryMode":"separate","availableInMCP":false},"staticData":null,"meta":{"templateCredsSetupCompleted":true},"nodeGroups":[],"pinData":{},"versionId":"09e76e04-d673-46c8-a667-83f204b41ebd","activeVersionId":"48842de3-9f90-406a-a370-97d95d3cac1e","versionCounter":89,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T14:23:30.310Z","createdAt":"2026-10-06T14:23:30.310Z","role":"workflow:owner","workflowId":"afdmDW35vpDd6oNs","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":null,"description":null}},{"updatedAt":"2026-10-08T17:44:54.325Z","createdAt":"2026-08-05T20:15:42.923Z","id":"alertQueueProc01","name":"Alert Queue Processor","description":null,"active":true,"isArchived":false,"nodes":[{"parameters":{"rule":{"interval":[{"field":"minutes","minutesInterval":15}]}},"name":"Every 15 Minutes","type":"n8n-nodes-base.scheduleTrigger","typeVersion":1.2,"position":[-3248,176],"id":"88fea6e5-007b-4b94-86bf-d8df2816a5cb"},{"parameters":{"operation":"executeQuery","query":"SELECT * FROM alert_queue ORDER BY created_at","options":{}},"name":"Get Queue","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-3024,176],"id":"632431bf-21f0-47ac-b5e3-e8735c2544f4","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"jsCode":"const items = $('Get Queue').all();\nif (items.length === 0) return [];\nconst alerts = items.map(i => i.json);\nconst grouped = {};\nfor (const a of alerts) {\n const key = `${a.host}_${a.ip}`;\n if (!grouped[key]) {\n grouped[key] = { symptom_key: key, host: a.host, ip: a.ip, alert_texts: new Set(), count: 0 };\n }\n grouped[key].alert_texts.add(a.alert_text);\n grouped[key].count++;\n}\nreturn Object.values(grouped).map(g => ({ json: { symptom_key: g.symptom_key, host: g.host, ip: g.ip, alert_text: Array.from(g.alert_texts).join('\\n'), alert_count: g.count } }));"},"name":"Group Alerts by Host","type":"n8n-nodes-base.code","typeVersion":2,"position":[-2800,176],"id":"4f318f7c-da0e-41b9-b033-cc2c4fb1e418"},{"parameters":{"operation":"executeQuery","query":"INSERT INTO alert_history (host, ip, alert_text) VALUES ('{{ $json.host }}', '{{ $json.ip }}', '{{ $json.alert_text }}');","options":{}},"name":"Log to History","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-2576,-32],"id":"b63c72a2-4c18-478a-ad31-02931ab10095","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"operation":"executeQuery","query":"SELECT COUNT(*) as failure_count FROM alert_history WHERE host = '{{ $json.host }}' AND created_at >= NOW() - INTERVAL '1 hour';","options":{}},"name":"Check Failure Count","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-2352,176],"id":"be7b88e4-8951-42de-985f-8e0c92badf85","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}},{"parameters":{"url":"http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues?state=open&q={{ $json.symptom_key }}","sendQuery":true,"queryParameters":{"parameters":[{"name":"state","value":"open"},{"name":"q","value":"={{ $json.symptom_key }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token {{GITEA_TOKEN}}"},{"name":"Content-Type","value":"application/json"}]},"options":{}},"name":"Check Gitea Issues","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-2128,64],"id":"c69d7159-79df-4a49-8bd4-f70c5c8bc63e"},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":1},"conditions":[{"id":"1","leftValue":"={{ $input.all().length }}","rightValue":0,"operator":{"type":"number","operation":"gt"}}],"combinator":"and"},"options":{}},"name":"IF: Issue Exists?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[-1904,64],"id":"6c70677e-b95f-499b-b7ef-9a0540d86dfa"},{"parameters":{"method":"POST","url":"=http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues/{{ $json[0].number }}/comments","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token {{GITEA_TOKEN}}"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={\"body\": \"🔄 **Повторный алерт зафиксирован**\\n⏰ Время: {{ $now.format('HH:mm:ss') }}\\n Сбоев за час: {{ $json.failure_count }}\\n\\n📝 Детали:\\n{{ $('Group Alerts by Host').first().json.alert_text }}\"}","options":{}},"name":"Add Comment to Gitea","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-1680,-48],"id":"87b7dcfc-1fbd-4485-b1f2-3d7a706ab260"},{"parameters":{"method":"POST","url":"http://192.168.1.140:3000/api/v1/repos/root/buryan-hub/issues","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Authorization","value":"token {{GITEA_TOKEN}}"},{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={\n \"title\": \"🚨 Алерт: {{ $json.host }} ({{ $json.ip }})\",\n \"body\": \"## Автоматически зафиксирован сбой\\n\\n**Хост:** {{ $json.host }}\\n**IP:** {{ $json.ip }}\\n**Сбоев за час:** {{ $json.failure_count }}\\n\\n### Детали алертов:\\n{{ $json.alert_text }}\",\n \"labels\": {{ $json.failure_count >= 3 ? '[\"alert\", \"sev:1\", \"critical\"]' : '[\"alert\", \"monitoring\"]' }}\n}","options":{}},"name":"Create Gitea Issue","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-1680,176],"id":"b7a93d40-63ad-4551-a4fa-c6026d26f253"},{"parameters":{"jsCode":"// Получаем данные из Group Alerts by Host\nconst groupedAlerts = $('Group Alerts by Host').all();\nconst alerts = groupedAlerts.map(i => i.json);\n\n// Получаем счетчики сбоев из Check Failure Count\nconst failureCounts = $('Check Failure Count').all();\nconst counts = failureCounts.map(i => i.json);\n\n// Объединяем данные\nconst merged = alerts.map((alert, index) => {\n const count = counts[index] || { failure_count: 0 };\n return {\n ...alert,\n failure_count: count.failure_count || 0\n };\n});\n\n// Проверяем, есть ли SEV:1 (3+ сбоя за час)\nconst hasSev1 = merged.some(h => h.failure_count >= 3);\n\nreturn [{\n json: {\n total_hosts: merged.length,\n hosts: merged,\n is_sev1: hasSev1,\n telegram_text: hasSev1\n ? `🚨 SEV:1 КРИТИЧЕСКИЙ ИНЦИДЕНТ\\n\\nВнимание! Один из сервисов превышает лимит сбоев (3+ раза в час).\\n\\n${merged.map(h => `• ${h.host} (${h.ip}): ${h.alert_count} событий\\n⚠️ Сбоев за час: ${h.failure_count}\\n${h.alert_text}`).join('\\n\\n')}\\n\\n Тикеты в Gitea`\n : ` Сводка алертов\\nВсего хостов с проблемами: ${merged.length}\\n\\n${merged.map(h => `• ${h.host} (${h.ip}): ${h.alert_count} событий\\n${h.alert_text}`).join('\\n\\n')}\\n\\n🔗 Тикеты в Gitea`\n }\n}];"},"name":"Aggregate for Telegram","type":"n8n-nodes-base.code","typeVersion":2,"position":[-2320,416],"id":"18613373-8814-47f4-a34e-8fdd1c3778a8"},{"parameters":{"method":"POST","url":"https://193.233.210.184/tg-api/bot8668603602:AAHVmUmq44dcomw8QOfw_qj1aICXuT5c5XU/sendMessage","sendHeaders":true,"headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]},"sendBody":true,"bodyParameters":{"parameters":[{"name":"chat_id","value":"=273442500"},{"name":"text","value":"={{ $json.telegram_text }}"},{"name":"parse_mode","value":"HTML"}]},"options":{"allowUnauthorizedCerts":true}},"name":"Notify Telegram (HTTP)","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[-2096,416],"id":"6474e66a-b860-491e-974f-baa08129f6d1"},{"parameters":{"operation":"executeQuery","query":"DELETE FROM alert_queue","options":{}},"name":"Clear Queue","type":"n8n-nodes-base.postgres","typeVersion":2.4,"position":[-1712,416],"id":"39e6b139-126d-4f23-8a87-c162fa09a77e","credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}}}],"connections":{"Every 15 Minutes":{"main":[[{"node":"Get Queue","type":"main","index":0}]]},"Get Queue":{"main":[[{"node":"Group Alerts by Host","type":"main","index":0}]]},"Group Alerts by Host":{"main":[[{"node":"Log to History","type":"main","index":0},{"node":"Check Failure Count","type":"main","index":0}]]},"Log to History":{"main":[[]]},"Check Failure Count":{"main":[[{"node":"Check Gitea Issues","type":"main","index":0},{"node":"Aggregate for Telegram","type":"main","index":0}]]},"Check Gitea Issues":{"main":[[{"node":"IF: Issue Exists?","type":"main","index":0}]]},"IF: Issue Exists?":{"main":[[{"node":"Add Comment to Gitea","type":"main","index":0}],[{"node":"Create Gitea Issue","type":"main","index":0}]]},"Add Comment to Gitea":{"main":[[{"node":"Clear Queue","type":"main","index":0}]]},"Create Gitea Issue":{"main":[[{"node":"Clear Queue","type":"main","index":0}]]},"Aggregate for Telegram":{"main":[[{"node":"Notify Telegram (HTTP)","type":"main","index":0}]]},"Notify Telegram (HTTP)":{"main":[[{"node":"Clear Queue","type":"main","index":0}]]}},"settings":{"executionOrder":"v1","binaryMode":"separate"},"staticData":{"node:Every 15 Minutes":{"recurrenceRules":[null],"recurrenceRuleSignatures":[null]}},"meta":{"templateCredsSetupCompleted":true},"nodeGroups":[],"pinData":{},"versionId":"ce6b893a-58a9-439a-a94c-d4f2f979204d","activeVersionId":"ce6b893a-58a9-439a-a94c-d4f2f979204d","versionCounter":55,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T17:28:32.499Z","createdAt":"2026-10-06T17:28:32.499Z","role":"workflow:owner","workflowId":"alertQueueProc01","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":"v3.1","description":""}},{"updatedAt":"2026-10-06T15:43:20.990Z","createdAt":"2026-10-06T14:23:27.246Z","id":"eqYDYibHxBt8NPq4","name":"Gitea Task Dispatcher","description":null,"active":true,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"gitea-task","options":{}},"name":"Webhook","type":"n8n-nodes-base.webhook","typeVersion":2.1,"position":[0,0],"webhookId":"fe5c7ad8-99fa-45f5-8e75-a365d7f08ae22","id":"f97c8348-ad40-470f-b891-67d468383566"},{"parameters":{"jsCode":"const w = $input.first().json;\nconst d = w.body || {};\nconst action = d.action || '';\nif (action !== 'opened' && action !== 'closed') return [];\nconst i = d.issue || {};\nconst r = d.repository || {};\nconst prefix = action === 'closed' ? 'CLOSED' : 'NEW';\nconst text = prefix + ' ' + (i.title || '?') + ' #' + (i.number || '?') + ' in ' + (r.full_name || '?') + '\\n' + (i.html_url || '');\nreturn [{ json: { text: text, critical: action === 'closed', repo: r.full_name || '?', alert_type: 'gitea_issue_' + action, alert_text: text } }];"},"name":"Parse","type":"n8n-nodes-base.code","typeVersion":2,"position":[240,0],"id":"d751f61e-ee10-4203-8f53-21ac59196b90"},{"parameters":{"jsCode":"return $input.all().filter(it => it.json.critical);"},"name":"OnlyCritical","type":"n8n-nodes-base.code","typeVersion":2,"position":[480,-120],"id":"2effd388-fee0-47b6-a223-63831696e8e8"},{"parameters":{"chatId":"273442500","text":"={{ $json.text }}"},"name":"Telegram Send","type":"n8n-nodes-base.telegram","typeVersion":1.2,"position":[720,-120],"credentials":{"telegramApi":{"id":"MI5ZSM5d514km2wE","name":"Telegram Bot"}},"id":"9d6c2a9b-2a11-4fbc-b479-57c460706978"},{"parameters":{"operation":"insert","schema":{"__rl":true,"mode":"name","value":"public"},"table":{"__rl":true,"mode":"name","value":"alert_queue"},"columns":{"mappingMode":"defineBelow","value":{"host":"={{ $json.repo }}","alert_type":"={{ $json.alert_type }}","alert_text":"={{ $json.alert_text }}"}},"options":{}},"name":"Queue Insert","type":"n8n-nodes-base.postgres","typeVersion":2.5,"position":[480,120],"credentials":{"postgres":{"id":"8czcy3lV8sUxWTd9","name":"Monitoring"}},"id":"e8e2414b-7ac2-459f-8428-bca69e594a4a"}],"connections":{"Webhook":{"main":[[{"node":"Parse","type":"main","index":0}]]},"Parse":{"main":[[{"node":"OnlyCritical","type":"main","index":0},{"node":"Queue Insert","type":"main","index":0}]]},"OnlyCritical":{"main":[[{"node":"Telegram Send","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":null,"nodeGroups":[],"pinData":null,"versionId":"0eb5a8e3-8884-4926-bc3b-ec40f768acc0","activeVersionId":"0eb5a8e3-8884-4926-bc3b-ec40f768acc0","versionCounter":1,"triggerCount":1,"sourceWorkflowId":null,"tags":[],"shared":[{"updatedAt":"2026-10-06T14:23:27.246Z","createdAt":"2026-10-06T14:23:27.246Z","role":"workflow:owner","workflowId":"eqYDYibHxBt8NPq4","projectId":"Zd9FtLQS8Pbp0htn","project":{"updatedAt":"2026-10-06T14:24:06.720Z","createdAt":"2026-10-06T14:21:02.176Z","id":"Zd9FtLQS8Pbp0htn","name":"Roman Buryan ","type":"personal","icon":null,"description":null,"customTelemetryTags":[],"creatorId":"d78fe973-c496-4595-936e-2bb81cb973f2"}}],"versionMetadata":{"name":null,"description":null}}] diff --git a/ops/creds/add_nc.py b/ops/creds/add_nc.py index 213135a..24eaeac 100644 --- a/ops/creds/add_nc.py +++ b/ops/creds/add_nc.py @@ -20,7 +20,7 @@ def call(path, method="GET", body=None): return None, str(e)[:120] -PASS = "HubNextcloud2026!" +PASS = open("/root/.nextcloud-admin-pass").read().strip() flow, err = call("/api/config/config_entries/flow", "POST", {"handler": "nextcloud"}) if err: print("flow:", err) diff --git a/ops/creds/immich_key2.py b/ops/creds/immich_key2.py index 5b0ef30..1352204 100644 --- a/ops/creds/immich_key2.py +++ b/ops/creds/immich_key2.py @@ -6,7 +6,7 @@ import urllib.request import bcrypt -PW_DB = "Buryan20261016mrAzbQ5SWdxwYg" +PW_DB = open("/root/.pg-superuser-pass").read().strip() NEW_PASS = "HubImmich2026!" EMAIL = "maloyakapg@gmail.com" diff --git a/ops/gitea/cleanup.py b/ops/gitea/cleanup.py index 3ba53c0..92f1337 100644 --- a/ops/gitea/cleanup.py +++ b/ops/gitea/cleanup.py @@ -4,7 +4,7 @@ import urllib.error import urllib.request BASE = "http://192.168.1.140:3000/api/v1" -TOK = "416f50c1a559be2def78bd6e3616a97906b0623d" +TOK = open("/root/.bwork-token").read().strip() H = {"Authorization": "token " + TOK, "Content-Type": "application/json"} diff --git a/ops/matrix/verify.sh b/ops/matrix/verify.sh index 32547b5..a14c77e 100755 --- a/ops/matrix/verify.sh +++ b/ops/matrix/verify.sh @@ -12,9 +12,9 @@ SRC=/root/matrix-backups DEST=/mnt/backups/matrix mkdir -p "$DEST" -TOKEN_LOCAL=5767150402f7d780402c -TOKEN_OFFSITE=747255608a9df3e81d01 -TOKEN_RESTORE=4464c9566e26c42e519c +TOKEN_LOCAL=$(cat /root/.kuma-matrix-local) +TOKEN_OFFSITE=$(cat /root/.kuma-matrix-offsite) +TOKEN_RESTORE=$(cat /root/.kuma-matrix-restore) VPS=root@193.233.210.184 VPS_DIR=/var/backups/matrix diff --git a/ops/media/2026-10-19-seerr/03-admin-and-arr.sh b/ops/media/2026-10-19-seerr/03-admin-and-arr.sh index 4159456..0c075bd 100644 --- a/ops/media/2026-10-19-seerr/03-admin-and-arr.sh +++ b/ops/media/2026-10-19-seerr/03-admin-and-arr.sh @@ -34,7 +34,7 @@ echo echo "=== 4. SONARR ===" CODE=$(curl -s -o /tmp/s4.out -b "$JAR" -w '%{http_code}' --max-time 25 -X POST -H 'Content-Type: application/json' -d '{ "name":"Buryan Hub","hostname":"192.168.1.117","port":8989,"useSsl":false,"urlBase":"", - "apiKey":"7ff2c05ca6cf4b669d1f6f7d3345f1cb","activeProfileId":1,"activeProfileName":"Any", + "apiKey":"'$(cat /root/.sonarr-key)'","activeProfileId":1,"activeProfileName":"Any", "activeDirectory":"/tv","activeLanguageProfileId":1,"activeTags":[],"is4k":false, "isDefault":true,"syncEnabled":true,"preventSearch":false}' "$S/settings/sonarr") echo " ответ: HTTP $CODE $(head -c 160 /tmp/s4.out | tr -d '\n')" @@ -43,7 +43,7 @@ echo echo "=== 5. RADARR ===" CODE=$(curl -s -o /tmp/s5.out -b "$JAR" -w '%{http_code}' --max-time 25 -X POST -H 'Content-Type: application/json' -d '{ "name":"Buryan Hub","hostname":"192.168.1.118","port":7878,"useSsl":false,"urlBase":"", - "apiKey":"f5da223e81244144bb5a14683e415b9f","activeProfileId":1,"activeProfileName":"Any", + "apiKey":"'$(cat /root/.radarr-key)'","activeProfileId":1,"activeProfileName":"Any", "activeDirectory":"/movies","activeLanguageProfileId":1,"activeTags":[],"is4k":false, "isDefault":true,"syncEnabled":true,"preventSearch":false}' "$S/settings/radarr") echo " ответ: HTTP $CODE $(head -c 160 /tmp/s5.out | tr -d '\n')" diff --git a/ops/media/2026-10-19-seerr/04-arr-fix.sh b/ops/media/2026-10-19-seerr/04-arr-fix.sh index 6e0d603..e1bf6a1 100644 --- a/ops/media/2026-10-19-seerr/04-arr-fix.sh +++ b/ops/media/2026-10-19-seerr/04-arr-fix.sh @@ -10,7 +10,7 @@ echo "=== SONARR ===" CODE=$(curl -s -o /tmp/s4.out -b "$JAR" -w '%{http_code}' --max-time 30 -X POST -H 'Content-Type: application/json' -d '{ "name":"Buryan Hub", "hostname":"192.168.1.117","port":8989,"useSsl":false,"urlBase":"", - "apiKey":"7ff2c05ca6cf4b669d1f6f7d3345f1cb", + "apiKey":"'$(cat /root/.sonarr-key)'", "activeProfileId":1,"activeProfileName":"Any","activeDirectory":"/tv", "activeLanguageProfileId":1, "activeAnimeProfileId":null,"activeAnimeProfileName":null,"activeAnimeDirectory":null, @@ -26,7 +26,7 @@ echo "=== RADARR ===" CODE=$(curl -s -o /tmp/s5.out -b "$JAR" -w '%{http_code}' --max-time 30 -X POST -H 'Content-Type: application/json' -d '{ "name":"Buryan Hub", "hostname":"192.168.1.118","port":7878,"useSsl":false,"urlBase":"", - "apiKey":"f5da223e81244144bb5a14683e415b9f", + "apiKey":"'$(cat /root/.radarr-key)'", "activeProfileId":1,"activeProfileName":"Any","activeDirectory":"/movies", "activeLanguageProfileId":1,"minimumAvailability":"released", "activeTags":[],"tags":[], @@ -54,5 +54,5 @@ done echo echo "=== ПРОВЕРКА СВЯЗИ С СЕРВИСАМИ ===" -printf ' sonarr тест: '; curl -s -o /dev/null -w '%{http_code}\n' --max-time 15 -b "$JAR" -X POST "$S/settings/sonarr/test" -H 'Content-Type: application/json' -d '{"hostname":"192.168.1.117","port":8989,"useSsl":false,"urlBase":"","apiKey":"7ff2c05ca6cf4b669d1f6f7d3345f1cb"}' -printf ' radarr тест: '; curl -s -o /dev/null -w '%{http_code}\n' --max-time 15 -b "$JAR" -X POST "$S/settings/radarr/test" -H 'Content-Type: application/json' -d '{"hostname":"192.168.1.118","port":7878,"useSsl":false,"urlBase":"","apiKey":"f5da223e81244144bb5a14683e415b9f"}' +printf ' sonarr тест: '; curl -s -o /dev/null -w '%{http_code}\n' --max-time 15 -b "$JAR" -X POST "$S/settings/sonarr/test" -H 'Content-Type: application/json' -d '{"hostname":"192.168.1.117","port":8989,"useSsl":false,"urlBase":"","apiKey":"'$(cat /root/.sonarr-key)'"}' +printf ' radarr тест: '; curl -s -o /dev/null -w '%{http_code}\n' --max-time 15 -b "$JAR" -X POST "$S/settings/radarr/test" -H 'Content-Type: application/json' -d '{"hostname":"192.168.1.118","port":7878,"useSsl":false,"urlBase":"","apiKey":"'$(cat /root/.radarr-key)'"}' diff --git a/ops/monitoring/2026-10-19-exportarr/01-exportarr.sh b/ops/monitoring/2026-10-19-exportarr/01-exportarr.sh index 27cf696..02b6b7c 100644 --- a/ops/monitoring/2026-10-19-exportarr/01-exportarr.sh +++ b/ops/monitoring/2026-10-19-exportarr/01-exportarr.sh @@ -22,9 +22,9 @@ deploy() { } echo "=== 1. РАЗВЁРТЫВАЮ ЭКСПОРТЁРЫ ===" -deploy exportarr-sonarr sonarr 9707 http://192.168.1.117:8989 7ff2c05ca6cf4b669d1f6f7d3345f1cb -deploy exportarr-radarr radarr 9708 http://192.168.1.118:7878 f5da223e81244144bb5a14683e415b9f -deploy exportarr-prowlarr prowlarr 9709 http://192.168.1.119:9696 284d2086b6454d27a848d2bf81bb9055 +deploy exportarr-sonarr sonarr 9707 http://192.168.1.117:8989 "$(cat /root/.sonarr-key)" +deploy exportarr-radarr radarr 9708 http://192.168.1.118:7878 "$(cat /root/.radarr-key)" +deploy exportarr-prowlarr prowlarr 9709 http://192.168.1.119:9696 "$(cat /root/.prowlarr-key)" BAZKEY=$(pct exec 120 -- bash -c "grep -oE '[^<]+' /opt/bazarr/config/config/config.yaml 2>/dev/null | head -1" 2>/dev/null | tr -d '\r') if [ -z "$BAZKEY" ]; then diff --git a/ops/n8n/creds.py b/ops/n8n/creds.py index b23e564..05b2ee6 100644 --- a/ops/n8n/creds.py +++ b/ops/n8n/creds.py @@ -1,7 +1,7 @@ """Создаёт credentials для n8n (с фиксированными id).""" import json -PW = "Buryan20261016mrAzbQ5SWdxwYg" +PW = open("/root/.pg-superuser-pass").read().strip() creds = [ { @@ -9,7 +9,7 @@ creds = [ "name": "Header Auth account", "type": "httpHeaderAuth", "data": {"name": "Authorization", - "value": "token 416f50c1a559be2def78bd6e3616a97906b0623d"}, + "value": "token " + open("/root/.bwork-token").read().strip()}, }, { "id": "BuryanMonitoring1", diff --git a/ops/n8n/export_workflows.py b/ops/n8n/export_workflows.py index 456a0b1..97ac1ae 100644 --- a/ops/n8n/export_workflows.py +++ b/ops/n8n/export_workflows.py @@ -4,7 +4,7 @@ import os import re import subprocess -PW = "Buryan20261016mrAzbQ5SWdxwYg" +PW = open("/root/.pg-superuser-pass").read().strip() OUT = "/tmp/n8n_import" os.makedirs(OUT, exist_ok=True) DBS = ["n8n_big", "n8n_restore", "n8n_tmp"] diff --git a/ops/scripts/pilot-grafana.sh b/ops/scripts/pilot-grafana.sh index 8bc1d27..4741970 100755 --- a/ops/scripts/pilot-grafana.sh +++ b/ops/scripts/pilot-grafana.sh @@ -31,7 +31,7 @@ CT=113 CONT=grafana DB=grafana_db ROLE=grafana_user -PASS='Grafana_Local_2026!' +PASS="$(cat /root/.grafana-admin-pass)" STAMP=$(date +%Y%m%d_%H%M%S) QUAR="/mnt/backups/retired/${STAMP}-grafana-pilot" WORK="/tmp/grafana-pilot-$STAMP" diff --git a/ops/sprint1/sprint2-tinyproxy.sh b/ops/sprint1/sprint2-tinyproxy.sh index d968e37..9f2b9df 100755 --- a/ops/sprint1/sprint2-tinyproxy.sh +++ b/ops/sprint1/sprint2-tinyproxy.sh @@ -21,5 +21,5 @@ echo "=== Открываем порт 8888 в iptables VPS ===" ssh root@193.233.210.184 'iptables -C INPUT -p tcp --dport 8888 -j ACCEPT 2>/dev/null || iptables -I INPUT 1 -p tcp --dport 8888 -j ACCEPT; iptables-save > /etc/iptables/rules.v4; echo ok' echo "=== Тест: CT108 -> tinyproxy -> api.telegram.org ===" -pct exec 108 -- curl -s -m 10 -x http://n8nrelay:BuryanRelay2026@193.233.210.184:8888 \ +pct exec 108 -- curl -s -m 10 -x http://$(cat /root/.proxy-user):$(cat /root/.proxy-pass)@193.233.210.184:8888 \ -o /dev/null -w "PROXY: code=%{http_code}\n" https://api.telegram.org/ || echo "FAIL proxy"