﻿{
    "name":  "VM Monitor",
    "nodes":  [
                  {
                      "parameters":  {
                                         "rule":  {
                                                      "interval":  [
                                                                       {
                                                                           "field":  "weeks",
                                                                           "triggerAtDay":  [
                                                                                                7
                                                                                            ],
                                                                           "triggerAtHour":  12
                                                                       }
                                                                   ]
                                                  }
                                     },
                      "id":  "schedule-trigger",
                      "name":  "Schedule Trigger",
                      "type":  "n8n-nodes-base.scheduleTrigger",
                      "typeVersion":  1,
                      "position":  [
                                       240,
                                       304
                                   ]
                  },
                  {
                      "parameters":  {
                                         "assignments":  {
                                                             "assignments":  [
                                                                                 {
                                                                                     "id":  "vm_list",
                                                                                     "name":  "vm_list",
                                                                                     "type":  "array",
                                                                                     "value":  "=[\"192.168.0.126\", \"homeassistant\", \"n8n\"]"
                                                                                 },
                                                                                 {
                                                                                     "id":  "check_ports",
                                                                                     "name":  "check_ports",
                                                                                     "type":  "array",
                                                                                     "value":  "=[22,80,443,3389]"
                                                                                 }
                                                                             ]
                                                         },
                                         "options":  {

                                                     }
                                     },
                      "id":  "set-vm-list",
                      "name":  "Set VM List",
                      "type":  "n8n-nodes-base.set",
                      "typeVersion":  3.4,
                      "position":  [
                                       464,
                                       304
                                   ]
                  },
                  {
                      "parameters":  {
                                         "fieldToSplitOut":  "vm_list",
                                         "options":  {

                                                     }
                                     },
                      "id":  "split-vm-list",
                      "name":  "Split VM List",
                      "type":  "n8n-nodes-base.splitOut",
                      "typeVersion":  1,
                      "position":  [
                                       688,
                                       304
                                   ]
                  },
                  {
                      "parameters":  {
                                         "method":  "POST",
                                         "url":  "http://nmap-api:3001/vm-health",
                                         "sendBody":  true,
                                         "specifyBody":  "json",
                                         "jsonBody":  "={{ { \"host\": $json.vm_list, \"ports\": $json.check_ports || [22,80,443,3389], \"timeoutMs\": 1500 } }}",
                                         "options":  {
                                                         "response":  {
                                                                          "response":  {
                                                                                           "neverError":  true,
                                                                                           "responseFormat":  "json"
                                                                                       }
                                                                      },
                                                         "timeout":  20000
                                                     }
                                     },
                      "id":  "ssh-disk-check",
                      "name":  "Check VM Health",
                      "type":  "n8n-nodes-base.httpRequest",
                      "typeVersion":  4.3,
                      "position":  [
                                       912,
                                       304
                                   ],
                      "continueOnFail":  true
                  },
                  {
                      "parameters":  {
                                         "content":  "## I\u0027m a note \nEvery 5 minutes â†’ Fetches prices â†’ Compares to 30-min ago price â†’ Calculates % change â†’ Sends urgent alert if \u003e 5%",
                                         "height":  256
                                     },
                      "type":  "n8n-nodes-base.stickyNote",
                      "position":  [
                                       544,
                                       -16
                                   ],
                      "typeVersion":  1,
                      "id":  "0a15ac87-3bd8-4817-a9fe-5299d0689041",
                      "name":  "Sticky Note"
                  },
                  {
                      "parameters":  {
                                         "jsCode":  "const item = $input.first().json || {};\nconst data = item \u0026\u0026 typeof item.body === \u0027object\u0027 ? item.body : item;\nconst host = data.host || item.vm_list || \u0027unknown\u0027;\nconst status = data.status || (data.success ? \u0027UP\u0027 : \u0027ERROR\u0027);\nconst openPorts = Array.isArray(data.openPorts) ? data.openPorts : [];\n\nreturn [{\n  json: {\n    host,\n    status,\n    openPorts,\n    checkedPorts: data.checkedPorts || [],\n    checks: data.checks || [],\n    summary: `${host}: ${status}${openPorts.length ? ` (open: ${openPorts.join(\u0027, \u0027)})` : \u0027\u0027}`\n  }\n}];"
                                     },
                      "id":  "summarize-vm-health",
                      "name":  "Summarize VM Health",
                      "type":  "n8n-nodes-base.code",
                      "typeVersion":  2,
                      "position":  [
                                       1136,
                                       304
                                   ]
                  }
              ],
    "pinData":  {

                },
    "connections":  {
                        "Set VM List":  {
                                            "main":  [
                                                         [
                                                             {
                                                                 "node":  "Split VM List",
                                                                 "type":  "main",
                                                                 "index":  0
                                                             }
                                                         ]
                                                     ]
                                        },
                        "Split VM List":  {
                                              "main":  [
                                                           [
                                                               {
                                                                   "node":  "Check VM Health",
                                                                   "type":  "main",
                                                                   "index":  0
                                                               }
                                                           ]
                                                       ]
                                          },
                        "Schedule Trigger":  {
                                                 "main":  [
                                                              [
                                                                  {
                                                                      "node":  "Set VM List",
                                                                      "type":  "main",
                                                                      "index":  0
                                                                  }
                                                              ]
                                                          ]
                                             },
                        "Check VM Health":  {
                                                "main":  [
                                                             {
                                                                 "node":  "Summarize VM Health",
                                                                 "type":  "main",
                                                                 "index":  0
                                                             }
                                                         ]
                                            }
                    },
    "active":  false,
    "settings":  {
                     "executionOrder":  "v1",
                     "saveDataErrorExecution":  "all",
                     "saveDataSuccessExecution":  "all",
                     "saveManualExecutions":  true,
                     "saveExecutionProgress":  true,
                     "callerPolicy":  "workflowsFromSameOwner",
                     "availableInMCP":  false
                 },
    "versionId":  "42fe96d9-60da-496f-9860-91a81f26df90",
    "meta":  {
                 "instanceId":  "e09d1f0f8b9f78e80ac70b6dc8726dd263b0b6ffc4300b0eee3b58f6da316f29"
             },
    "id":  "kKHLMmCJGilhyNgG",
    "tags":  [

             ]
}
