49 lines
3.5 KiB
JSON
49 lines
3.5 KiB
JSON
{
|
|
"name": "每日系統狀態報告",
|
|
"nodes": [
|
|
{
|
|
"parameters": { "rule": { "interval": [{ "field": "cronExpression", "expression": "0 9 * * *" }] } },
|
|
"id": "schedule", "name": "每日 9:00", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.1, "position": [0, 0]
|
|
},
|
|
{
|
|
"parameters": { "url": "http://192.168.0.110:5001/health", "options": { "timeout": 10000 } },
|
|
"id": "http-health", "name": "應用健康", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [220, -100]
|
|
},
|
|
{
|
|
"parameters": { "url": "http://192.168.0.110:5001/api/system/backup/status", "options": { "timeout": 10000 } },
|
|
"id": "http-backup", "name": "備份狀態", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [220, 0]
|
|
},
|
|
{
|
|
"parameters": { "url": "http://192.168.0.110:5001/api/system/crawler/status", "options": { "timeout": 10000 } },
|
|
"id": "http-crawler", "name": "爬蟲狀態", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [220, 100]
|
|
},
|
|
{
|
|
"parameters": { "mode": "chooseBranch" },
|
|
"id": "merge", "name": "合併結果", "type": "n8n-nodes-base.merge", "typeVersion": 2.1, "position": [440, 0]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const items = $input.all();\nconst health = items[0]?.json || {};\nconst backup = items[1]?.json || {};\nconst crawler = items[2]?.json || {};\n\nconst appOk = health.status === 'healthy';\nconst backupOk = backup.healthy;\nconst crawlerOk = crawler.healthy;\n\nconst date = new Date().toISOString().split('T')[0];\nconst appStatus = appOk ? '✅ 正常' : '❌ 異常';\nconst backupStatus = backupOk ? '✅ 正常' : '⚠️ 需注意';\nconst crawlerStatus = crawlerOk ? '✅ 正常' : '⚠️ 需檢查';\nconst lastBackup = backup.last_backup ? backup.last_backup.name : 'N/A';\nconst overallStatus = appOk && backupOk && crawlerOk ? '🟢' : '🟡';\n\nconst text = overallStatus + ' *每日系統狀態報告*\\n\\n' +\n '📅 日期: ' + date + '\\n\\n' +\n '🖥️ 應用程式: ' + appStatus + '\\n' +\n '💾 資料備份: ' + backupStatus + '\\n' +\n '🕷️ 爬蟲排程: ' + crawlerStatus + '\\n\\n' +\n '📦 最新備份: ' + lastBackup;\n\nreturn [{ json: { telegramBody: { chat_id: '5619078117', text: text, parse_mode: 'Markdown' } } }];"
|
|
},
|
|
"id": "code", "name": "生成報告", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [660, 0]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"method": "POST", "url": "https://api.telegram.org/bot<TELEGRAM_BOT_TOKEN>/sendMessage",
|
|
"sendBody": true, "specifyBody": "json",
|
|
"jsonBody": "={{ JSON.stringify($json.telegramBody) }}"
|
|
},
|
|
"id": "telegram", "name": "發送報告", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [880, 0]
|
|
}
|
|
],
|
|
"connections": {
|
|
"每日 9:00": { "main": [[{ "node": "應用健康", "type": "main", "index": 0 }, { "node": "備份狀態", "type": "main", "index": 0 }, { "node": "爬蟲狀態", "type": "main", "index": 0 }]] },
|
|
"應用健康": { "main": [[{ "node": "合併結果", "type": "main", "index": 0 }]] },
|
|
"備份狀態": { "main": [[{ "node": "合併結果", "type": "main", "index": 1 }]] },
|
|
"爬蟲狀態": { "main": [[{ "node": "合併結果", "type": "main", "index": 2 }]] },
|
|
"合併結果": { "main": [[{ "node": "生成報告", "type": "main", "index": 0 }]] },
|
|
"生成報告": { "main": [[{ "node": "發送報告", "type": "main", "index": 0 }]] }
|
|
},
|
|
"settings": { "executionOrder": "v1" }
|
|
}
|