{
  "id": "veLZQlpr9v5pEgDx",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Snapshot API VPS Hostinger",
  "tags": [
    {
      "id": "JCeTWzAG1RlEvpld",
      "name": "Hostinger",
      "createdAt": "2025-04-30T02:53:12.363Z",
      "updatedAt": "2025-04-30T02:53:12.363Z"
    }
  ],
  "nodes": [
    {
      "id": "66922063-7f2a-46a3-9618-abae57e1ee8c",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -100,
        500
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "da6b9112-0bb3-4ac3-94ee-e067545568dc",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        500,
        360
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "response"
      },
      "typeVersion": 1
    },
    {
      "id": "827df7d7-19ba-40b8-9e74-9c0c09b7bf88",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -480
      ],
      "parameters": {
        "color": 4,
        "width": 609,
        "height": 496,
        "content": "## Hostinger Snapshot with VPS Metrics\nAutomate the creation of snapshots of all your Hostinger VPS, receive success or failure alerts via WhatsApp, use in n8n self-hosting.\n\n### Prerequisites (Community Nodes):\nn8n-nodes-hostinger-api\nn8n-nodes-evolution-api (you can use another notification method, but copy first content message model)\n\n### Setup:\n1 - Install Community Nodes\n2 - Create Hostinger API Key: https://hpanel.hostinger.com/profile/api\n3 - Create credential in first node and set in next nodes;\n4 - Configure notifications Evolution API (WhatsApp) or other means;\n\nNote: Hostinger allows one snapshot per VPS and the previous one will always be replaced.\n\nWorkflow by [Leandro Melo]\nbuy me a coffe!\u2615\ud83d\ude00\nPaypal/Pix: contato@sistemanaweb.com\n"
      },
      "typeVersion": 1
    },
    {
      "id": "308532f7-edb5-48cf-bc52-e4af021c31b5",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1280,
        360
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "ab42fce7-ca08-41f8-be53-f1ae3ca085e9",
      "name": "Wait 2 seg",
      "type": "n8n-nodes-base.wait",
      "position": [
        2340,
        360
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "fc54f299-b001-4171-9433-6cf4c5d36814",
      "name": "Every day 4:00am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -100,
        260
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 4
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6dbcc6a5-07a2-42d4-a41d-e5a81c2247a2",
      "name": "Hostinger API list VPS",
      "type": "n8n-nodes-hostinger-api.hostingerApi",
      "position": [
        300,
        360
      ],
      "parameters": {
        "vpsAction": "listVms"
      },
      "credentials": {
        "hostingerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6cf2b19c-079b-44e1-8491-42aaa0c207b0",
      "name": "Avaliables VPS",
      "type": "n8n-nodes-base.filter",
      "position": [
        660,
        360
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "10bde94d-4ca9-479a-98d6-b39695fe7b78",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.state }}",
              "rightValue": "running"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "242a2705-1d27-450c-a935-082b5388ee1b",
      "name": "Get VPS Metrics",
      "type": "n8n-nodes-hostinger-api.hostingerApi",
      "position": [
        860,
        360
      ],
      "parameters": {
        "date_to": "={{ $now.minus({ minute: 0 }).toISO() }}",
        "date_from": "={{ $now.minus({ minute: 30 }).toISO() }}",
        "vpsAction": "getVmMetrics",
        "virtualMachineId": "={{ $('Avaliables VPS').item.json.id }}"
      },
      "credentials": {
        "hostingerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fb71f5bc-41ba-4293-8967-53f5380752d2",
      "name": "WhatsApp Message (success)",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        1560,
        220
      ],
      "parameters": {
        "resource": "messages-api",
        "remoteJid": "55119999999",
        "messageText": "=\ud83d\udcbe Info Snapshot Hostinger:\n\n\ud83d\udd39Status: {{ $('Create Snapshot').item.json.response.state === \"sent\" ? \"SUCCESS\" : $('Create Snapshot').item.json.response.state }}\n\ud83d\udd39Date: {{ $now.setZone(\"America/Sao_Paulo\").toFormat(\"dd/MM/yyyy HH:mm\") }}\n\ud83d\udd39Server: {{ $('Calculate metrics').item.json.plan }} / {{ $('Calculate metrics').item.json.hostname }}\n\ud83d\udd39IP: {{ $('Calculate metrics').item.json.IP }}\n\n\u2699\ufe0f M\u00e9trics: \n\ud83d\udd39 {{ $('Calculate metrics').item.json.cpus }}vCPUs \n\ud83d\udd39 {{ $('Calculate metrics').item.json.ram_usage }} \n\ud83d\udd39 {{ $('Calculate metrics').item.json.disco }} \n\ud83d\udd39 {{ $('Calculate metrics').item.json.OS }}(SO) \n\ud83d\udd39 Uptime: {{ $('Calculate metrics').item.json.uptime }}",
        "instanceName": "alertasinstance",
        "options_message": {}
      },
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c9891a04-3b3b-48c6-b476-bf343940b8eb",
      "name": "Create Snapshot",
      "type": "n8n-nodes-hostinger-api.hostingerApi",
      "onError": "continueErrorOutput",
      "position": [
        1880,
        380
      ],
      "parameters": {
        "vpsAction": "createSnapshot",
        "subcategory": "snapshots",
        "virtualMachineId": "={{ $json.id }}"
      },
      "credentials": {
        "hostingerApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "dfd2073c-c2c2-4b1c-b5a0-36f35eb5d269",
      "name": "Next VPS",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2160,
        360
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c9cde1f1-38b0-4c9a-b018-9a0e794a908a",
      "name": "WhatsApp Message (error)",
      "type": "n8n-nodes-evolution-api.evolutionApi",
      "position": [
        1560,
        600
      ],
      "parameters": {
        "resource": "messages-api",
        "remoteJid": "55119999999",
        "messageText": "=\ud83d\udea8\u26a0\ufe0f Error Snapshot Hostinger:\n\n\ud83d\udd39Status: {{ $('Create Snapshot').item.json.response.state }}\n\ud83d\udd39Date: {{ $now.setZone(\"America/Sao_Paulo\").toFormat(\"dd/MM/yyyy HH:mm\") }}\n\ud83d\udd39Server: {{ $('Calculate metrics').item.json.plan }} / {{ $('Calculate metrics').item.json.hostname }}\n\ud83d\udd39IP: {{ $('Calculate metrics').item.json.IP }}",
        "instanceName": "alertsinstance",
        "options_message": {}
      },
      "credentials": {
        "evolutionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ad294b56-763b-4c6e-9561-05f4dac14939",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -320
      ],
      "parameters": {
        "width": 340,
        "height": 340,
        "content": "### VPS Metrics avaliables (send in messages):\n\n\n\ud83d\udd39Status: snapshot status\n\ud83d\udd39Date: snapshot date time\n\ud83d\udd39Server: server name\n\ud83d\udd39IP: external server IP\n\n\u2699\ufe0f M\u00e9trics: \n\ud83d\udd39 Number of vCPUs \n\ud83d\udd39 Ram usage / avaliable \n\ud83d\udd39 Hard Disk usage / avaliable\n\ud83d\udd39 Operational Sys and version\n\ud83d\udd39 Uptime time (days, hours)"
      },
      "typeVersion": 1
    },
    {
      "id": "37e8ea8c-731b-49a6-a82f-14c352134fbb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        100
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 680,
        "content": "### Set Hostinger API credential"
      },
      "typeVersion": 1
    },
    {
      "id": "1942c744-48b7-4774-8250-9bc4ff6d87c7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        100
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 680,
        "content": "### Set Hostinger API credential"
      },
      "typeVersion": 1
    },
    {
      "id": "a08c8234-15bc-4d75-b9a5-20b513a13d59",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1820,
        100
      ],
      "parameters": {
        "color": 6,
        "width": 220,
        "height": 680,
        "content": "### Set Hostinger API credential"
      },
      "typeVersion": 1
    },
    {
      "id": "2e8eece6-3f7e-4355-a52f-7ccdc088125b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        100
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 680,
        "content": "### Set destination alert message (use message model inside)"
      },
      "typeVersion": 1
    },
    {
      "id": "9a1ccbac-1c25-403d-a67c-826ad8491387",
      "name": "Calculate metrics",
      "type": "n8n-nodes-base.set",
      "position": [
        1080,
        360
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "08aea2dd-4226-46d5-ae08-3f1d764bd658",
              "name": "id",
              "type": "number",
              "value": "={{ $('Avaliables VPS').item.json.id }}"
            },
            {
              "id": "3115465b-24ed-4f9e-a9af-53e34d2db384",
              "name": "plan",
              "type": "string",
              "value": "={{ $('Avaliables VPS').item.json.plan }}"
            },
            {
              "id": "1611cd7b-cc97-4c12-822c-6e8da601c508",
              "name": "hostname",
              "type": "string",
              "value": "={{ $('Avaliables VPS').item.json.hostname }}"
            },
            {
              "id": "c1e1edd4-7c45-4f96-a7e0-2c67c6aa8968",
              "name": "cpus",
              "type": "number",
              "value": "={{ $('Avaliables VPS').item.json.cpus }}"
            },
            {
              "id": "78e6cf5e-979f-4e31-908c-f4c6b95cb316",
              "name": "disk",
              "type": "number",
              "value": "={{ $('Avaliables VPS').item.json.disk }}"
            },
            {
              "id": "58e18048-6200-40fc-8957-5022810c7474",
              "name": "IP",
              "type": "string",
              "value": "={{ $('Avaliables VPS').item.json.ipv4[0].address }}"
            },
            {
              "id": "e8f2e562-9a96-479f-b3ca-a0770296d343",
              "name": "OS",
              "type": "string",
              "value": "={{ $('Avaliables VPS').item.json.template.name }}"
            },
            {
              "id": "c18f9dc3-7190-4f38-b4b8-2068a1c89023",
              "name": "cpu_usage",
              "type": "string",
              "value": "={{ $('Get VPS Metrics').item.json.response.cpu_usage.usage.values().last() }}%"
            },
            {
              "id": "47607d2b-5980-4e27-9232-06e166c70193",
              "name": "ram_usage",
              "type": "string",
              "value": "={{\n  \"RAM: \" + \n  ($('Get VPS Metrics').item.json.response.ram_usage.usage.values().last() / 1073741824).toFixed(2) + \n  \" GB (\" + \n  (($('Get VPS Metrics').item.json.response.ram_usage.usage.values().last() / ($('Avaliables VPS').item.json.memory * 1048576)) * 100).toFixed(2) + \n  \"%) | Free: \" + \n  (($('Avaliables VPS').item.json.memory - ($('Get VPS Metrics').item.json.response.ram_usage.usage.values().last() / 1048576)) / 1024).toFixed(2) + \n  \" GB\"\n}}"
            },
            {
              "id": "b2fd1374-1199-4020-a2b4-00b9d9496c77",
              "name": "uptime",
              "type": "string",
              "value": "={{ \n  \"Days: \" + Math.floor($('Get VPS Metrics').item.json.response.uptime.usage.values().last() / 86400) + \n  \" | Hours: \" + Math.floor(($('Get VPS Metrics').item.json.response.uptime.usage.values().last() % 86400) / 3600)\n}}"
            },
            {
              "id": "a6b3ecbf-e734-48cd-b1d0-9094cf52c7ec",
              "name": "disco",
              "type": "string",
              "value": "={{ \"Used: \" + ($('Get VPS Metrics').item.json.response.disk_space.usage.values().last() / 1073741824).toFixed(2) + \" GB (\" + (($('Get VPS Metrics').item.json.response.disk_space.usage.values().last() / 1073741824) / ($('Avaliables VPS').item.json.disk / 1024) * 100).toFixed(2) + \"%) | Free: \" + ($('Avaliables VPS').item.json.disk / 1024 - $('Get VPS Metrics').item.json.response.disk_space.usage.values().last() / 1073741824).toFixed(2) + \" GB\" }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b7e68847-f530-4df7-b7d1-1b557b1718c1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        80
      ],
      "parameters": {
        "color": 3,
        "width": 2840,
        "height": 720,
        "content": ""
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3791c97d-8433-438e-a8c2-b0fae6926186",
  "connections": {
    "Next VPS": {
      "main": [
        [
          {
            "node": "Wait 2 seg",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Avaliables VPS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 2 seg": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Avaliables VPS": {
      "main": [
        [
          {
            "node": "Get VPS Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Snapshot": {
      "main": [
        [
          {
            "node": "Next VPS",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "WhatsApp Message (error)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get VPS Metrics": {
      "main": [
        [
          {
            "node": "Calculate metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "WhatsApp Message (success)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Snapshot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every day 4:00am": {
      "main": [
        [
          {
            "node": "Hostinger API list VPS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate metrics": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hostinger API list VPS": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "WhatsApp Message (success)": {
      "main": [
        []
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Hostinger API list VPS",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}