Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Flatly)
  • No Skin
Collapse
Brand Logo

NetXMS Forum

  1. Home
  2. Support
  3. Sending alarms to N8N?

Sending alarms to N8N?

Scheduled Pinned Locked Moved Support
6 Posts 3 Posters 20.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    S
    Sorikan
    wrote on last edited by
    #1

    Has anyone been able to come up with a way to send alarms to an N8N instance? I have tried Hook::AlarmStateChange, and a notification channel and nothing works. I was on 5.2.4 but upgraded to 5.2.6 to see if that opens anything up.

    I have been hitting up Google and all the LLM's, to no avail.

    I am attempting to sedn JSON from netxms to N8N.

    Thanks!

    1 Reply Last reply
    0
    • F
      F
      Filipp Sudanov
      wrote on last edited by
      #2

      Can you point me to n8n documentation on the api call you are trying to use

      1 Reply Last reply
      0
      • S
        S
        Sorikan
        wrote on last edited by
        #3

        Thats not really a thing? I am trying to get all of the alarm information I can into N8N. You can see the documentation in the link below. I had attempted to build the JSON in hook::AlarmStateChange, but that appears to be a dead end at this point? I am now trying to just dump the data to a script with a shell notification channel - but I am not getting any actual alarm data in the fields yet.

        Link Preview Image
        Webhook | Nodes | n8n Docs

        Learn how to use the Webhook node in n8n. Follow technical documentation to integrate Webhook node into your workflows.

        favicon

        (docs.n8n.io)

        Thanks.

        1 Reply Last reply
        0
        • S
          S
          Sorikan
          wrote on last edited by
          #4

          I tried doing something like this, but kept hitting various walls, when using hook::alarmstatechange

          function main()
          {
            webhook = "https://my.host.hstgr.cloud/webhook-test/netxms-alarm";

            payload = "{"
                + "\"id\":\""        + ToString($alarm->id) + "\","
                + "\"state\":\""    + ToString($alarm->state) + "\","
                + "\"severity\":\""  + ToString($alarm->severity) + "\","
                + "\"message\":\""  + EscapeString(($alarm->message != null) ? $alarm->message : "") + "\","
                + "\"source\":\""    + (($alarm->sourceObject != null) ? EscapeString($alarm->sourceObject->name) : "") + "\","
                + "\"eventCode\":\"" + ToString($alarm->eventCode) + "\","
                + "\"eventName\":\"" + EscapeString(($alarm->eventName != null) ? $alarm->eventName : "") + "\""
                + "}";

            WriteLog(0, "Alarm JSON: " + payload);

            cmd = "curl -s -X POST -H 'Content-Type: application/json' -d '" + payload + "' " + webhook;
            Execute(cmd);
          }

          function EscapeString(s)
          {
            if (s == null)
                return "";
            s = Replace(s, "\\", "\\\\"); 
            s = Replace(s, "\"", "\\\""); 
            return s;
          }

          1 Reply Last reply
          0
          • A
            A
            Alex Kirhenshtein
            wrote on last edited by
            #5

            There are no "Execute()" function in the NXSL, and you can't execute external commands in any way - that's by design.

            What I'd do:

            • create Action which runs external shell script to form  json and send query using curl. Pass required event fields as arguments to the script.
            • add this Action to EPP (I'd create separate rule just for this integration - this way you can control what exactly being sent)

            Or, you setup web service (Settings -> Web service definition), and call it from NXSL. But again, I'd use action for that, not hook.

            Note on the json string escaping: instead of manual processing, you can use construct https://netxms.org/documentation/nxsl-latest/#class-jsonobject and produce perfectly valid json.

            1 Reply Last reply
            0
            • A
              A
              Alex Kirhenshtein
              wrote on last edited by
              #6

              also you don't need "function main()", just write code.

              something like this:

              source = FindObject($alarm.sourceObject());
              
              j = JsonObject();
              j.set("id", $alarm.id);
              j.set("state", $alarm.state);
              j.set("severity", $alarm.severity);
              j.set("message", $alarm.message);
              j.set("source", source ? source.name : "");
              j.set("eventCode", $alarm.eventCode);
              j.set("eventName", $alarm.eventName);
              
              trace(0, j.serialize());
              

              I highly recommend you to read https://www.netxms.org/documentation/nxsl-latest/.

              1 Reply Last reply
              0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              Powered by NodeBB Contributors
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups