HTTPとメールアラートによるサーバー自動健康チェック

中級

これは自動化ワークフローで、12個のノードを含みます。主にSsh, EmailSend, Agent, ScheduleTrigger, LmChatAzureOpenAiなどのノードを使用。 SSH、Azure GPT-4分析、そしてメールアラートを使った自動化のなサーバー健全性チェック

前提条件
  • OpenAI API Key

カテゴリー

-
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "ZrSNA55iSMYyBkl5",
  "meta": {
    "instanceId": "8b88b19fd2b6fddee571a93766ad18ff729288d5a4d5105aab5d8a8d2b41a9ac",
    "templateCredsSetupCompleted": true
  },
  "name": "Automated Health Check for Servers via HTTP and Email Alerts",
  "tags": [],
  "nodes": [
    {
      "id": "8bb22fc0-2ae6-43cf-9ac1-d44efdb77596",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -512,
        -240
      ],
      "parameters": {
        "text": "=You are an AI system report generator. You will receive raw SSH output from a Linux server. Your task is to generate a structured system report with actionable recommendations, prioritization, and an executive summary.\n\nOutput JSON must strictly follow this schema:\n\n{\n  \"executiveSummary\": string,\n  \"summary\": string,\n  \"details\": string,\n  \"status\": string, // OK, WARNING, CRITICAL\n  \"recommendations\": [\n    {\n      \"issue\": string,\n      \"priority\": string, // HIGH, MEDIUM, LOW\n      \"action\": string\n    }\n  ]\n}\n\nRequirements:\n1. Executive Summary: 2–3 lines for management, highlighting critical issues and overall system health.\n2. Summary: concise technical overview of CPU, memory, disk, network, and critical processes.\n3. Details: generate a professional, modern HTML report. Include tables, inline styles, colored highlights, simple inline graphs, and actionable recommendations.\n4. Recommendations: list each issue detected, assign a priority (HIGH/MEDIUM/LOW), and suggest a specific action.\n5. Status: determine overall system health based on thresholds (CPU >80%, memory <10% free, disk >90%, network saturation >80%, top processes consuming high CPU).\n6. Return only JSON matching the schema. Do not add extra fields.\n\nHere is the raw SSH output:\n\n {{ $json.stdout }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "a4ec3064-2773-491d-8b8b-4e93b94288e0",
      "name": "構造化出力パーサー",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -436,
        -16
      ],
      "parameters": {
        "autoFix": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"executiveSummary\": {\n      \"type\": \"string\",\n      \"description\": \"2–3 line summary suitable for management highlighting critical issues and overall system health.\"\n    },\n    \"summary\": {\n      \"type\": \"string\",\n      \"description\": \"Concise technical overview highlighting key metrics like CPU, memory, disk, network, and critical processes.\"\n    },\n    \"details\": {\n      \"type\": \"string\",\n      \"description\": \"HTML report ready for email, with inline styling, tables, colored highlights, simple graphs, and actionable recommendations.\"\n    },\n    \"status\": {\n      \"type\": \"string\",\n      \"enum\": [\"OK\", \"WARNING\", \"CRITICAL\"],\n      \"description\": \"Overall system health based on analyzed metrics.\"\n    },\n    \"recommendations\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"issue\": { \"type\": \"string\" },\n          \"priority\": { \"type\": \"string\", \"enum\": [\"HIGH\", \"MEDIUM\", \"LOW\"] },\n          \"action\": { \"type\": \"string\" }\n        },\n        \"required\": [\"issue\", \"priority\", \"action\"]\n      }\n    }\n  },\n  \"required\": [\"executiveSummary\", \"summary\", \"details\", \"status\", \"recommendations\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "6acaee4a-890b-4c69-9635-ef1fef7057ad",
      "name": "コマンド実行",
      "type": "n8n-nodes-base.ssh",
      "position": [
        -736,
        -240
      ],
      "parameters": {
        "command": "echo \"---SYSTEM INFO---\"; hostname; uptime;\necho \"---CPU---\"; top -bn1 | grep \"Cpu(s)\";\necho \"---MEMORY---\"; free -m;\necho \"---DISK---\"; df -h;\necho \"---SERVICES---\"; systemctl list-units --type=service --state=running;\necho \"---NETWORK---\"; ip -s link;\necho \"---TOP PROCESSES---\"; ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head -n 10\n",
        "authentication": "privateKey"
      },
      "typeVersion": 1
    },
    {
      "id": "67574230-5dfa-47ac-9862-d7736173e10d",
      "name": "Azure OpenAIチャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        -560,
        96
      ],
      "parameters": {
        "model": "gpt-4.1",
        "options": {},
        "authentication": "azureEntraCognitiveServicesOAuth2Api"
      },
      "typeVersion": 1
    },
    {
      "id": "7d8866bd-5698-4285-8f43-adadcf8956dc",
      "name": "スケジュールトリガー",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -960,
        -240
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c7151766-7c55-4e13-a9ee-e4745c541753",
      "name": "メール送信",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        -68,
        -240
      ],
      "webhookId": "fbfeca12-7de1-49c6-b8ce-787c39fd9aac",
      "parameters": {
        "html": "={{ $json.output.details }}",
        "options": {},
        "subject": "=Health Report - Server |  {{ $json.output.status }}"
      },
      "credentials": {
        "smtp": {
          "id": "NEZj4r0c5aKzf2aJ",
          "name": "SMTP account 2"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "252e2019-fb19-4fa3-96ad-df6b8541942a",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1760,
        -1376
      ],
      "parameters": {
        "width": 928,
        "height": 928,
        "content": "## Automated Server Health Check with AI & Email Alerts\n\n## **Purpose:**\nThis workflow automatically gathers **system health data** from a server, analyzes it using an AI Agent, and sends **email alerts** if anything unusual is detected. It’s ideal for DevOps teams or sysadmins who want an automated health check without installing heavy monitoring software.\n\n## **How it works:**\n\n1. **Schedule Trigger** – Runs the workflow at set intervals (e.g., every 5 minutes).\n2. **Execute Command** – Runs shell commands to collect system info, CPU, memory, disk usage, running services, network stats, and top processes:\n\n   * `echo \"---SYSTEM INFO---\"; hostname; uptime;` → Server identity and uptime\n   * `echo \"---CPU---\"; top -bn1 | grep \"Cpu(s)\";` → CPU usage\n   * `echo \"---MEMORY---\"; free -m;` → Memory usage in MB\n   * `echo \"---DISK---\"; df -h;` → Disk usage\n   * `echo \"---SERVICES---\"; systemctl list-units --type=service --state=running;` → Running services\n   * `echo \"---NETWORK---\"; ip -s link;` → Network interface stats\n   * `echo \"---TOP PROCESSES---\"; ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head -n 10` → Top 10 CPU-consuming processes\n3. **AI Agent** – Analyzes command outputs to detect anomalies or potential issues.\n4. **Structured Output Parser** – Formats AI output so it can be used for email alerts.\n5. **Send Email** – Notifies recipients with server health summary or detected issues.\n\n## **Setup Instructions:**\n\n* Replace the commands in the **Execute Command node** if you want custom server checks.\n* Configure the **Azure OpenAI Chat** node with your API credentials in n8n credentials.\n* Update the **Email node** with your SMTP credentials and recipient addresses.\n* Adjust the **Schedule Trigger** interval according to your monitoring needs.\n\n## **Notes:**\n\n* All credentials should be stored securely; do **not hardcode API keys**.\n* Multiple servers can be monitored by adding more command nodes or duplicating the workflow.\n* Suitable for Self-Hosted Instances also."
      },
      "typeVersion": 1
    },
    {
      "id": "1372afc9-a9aa-4ff1-8936-a4078e9acccf",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 224,
        "height": 128,
        "content": "**Schedule Trigger:**\n   *“Triggers the workflow at your chosen interval to run server health checks automatically.”*"
      },
      "typeVersion": 1
    },
    {
      "id": "bf182b47-8461-45b0-a0e8-d15bfbec602f",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -784,
        -416
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "content": "**Execute Command:**\n   *“Collects detailed server metrics: hostname, uptime, CPU, memory, disk, services, network stats, and top processes.”*"
      },
      "typeVersion": 1
    },
    {
      "id": "2fd3f1b4-4bf6-451f-b6bf-1909f77d2a76",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -496,
        -416
      ],
      "parameters": {
        "color": 5,
        "content": "**AI Agent:**\n   *“Analyzes the collected server data for anomalies and prepares structured results.”*\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c3e55927-518a-4915-b0b5-b620b3ce9cbd",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -32
      ],
      "parameters": {
        "color": 5,
        "content": "**Structured Output Parser:**\n   *“Ensures AI output is formatted correctly for the email alert.”*"
      },
      "typeVersion": 1
    },
    {
      "id": "297baae0-7057-46e1-a919-3f71ce0ffef2",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -416
      ],
      "parameters": {
        "color": 5,
        "content": "\n\n**Send Email:**\n   *“Sends an alert email summarizing the server health or any detected issues.”*"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3b37f074-af91-4655-ab83-68f8baab578d",
  "connections": {
    "8bb22fc0-2ae6-43cf-9ac1-d44efdb77596": {
      "main": [
        [
          {
            "node": "c7151766-7c55-4e13-a9ee-e4745c541753",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7d8866bd-5698-4285-8f43-adadcf8956dc": {
      "main": [
        [
          {
            "node": "6acaee4a-890b-4c69-9635-ef1fef7057ad",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6acaee4a-890b-4c69-9635-ef1fef7057ad": {
      "main": [
        [
          {
            "node": "8bb22fc0-2ae6-43cf-9ac1-d44efdb77596",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "67574230-5dfa-47ac-9862-d7736173e10d": {
      "ai_languageModel": [
        [
          {
            "node": "8bb22fc0-2ae6-43cf-9ac1-d44efdb77596",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "a4ec3064-2773-491d-8b8b-4e93b94288e0",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "a4ec3064-2773-491d-8b8b-4e93b94288e0": {
      "ai_outputParser": [
        [
          {
            "node": "8bb22fc0-2ae6-43cf-9ac1-d44efdb77596",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

中級

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
中級
ノード数12
カテゴリー-
ノードタイプ7
難易度説明

経験者向け、6-15ノードの中程度の複雑さのワークフロー

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34