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. Alarm notification call API

Alarm notification call API

Scheduled Pinned Locked Moved Support
8 Posts 3 Posters 49.7k 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.
  • R
    R
    richard21
    wrote on last edited by
    #1

    Hi is it possible to set up an Alarm action that will call an external systems API

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

      Add "server action" in EPP rule where you are creating alarm

      1 Reply Last reply
      0
      • R
        R
        richard21
        wrote on last edited by
        #3

        I have found the Variables and they are now passing to the API via the alarm action as below but is there a variable for the Alarm ID as shown in the UI

        /etc/netxms/scripts/send_event.sh "%K" "%I" "%n" "%S" "%c" "%A"

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

          Yes, right, these are the macros described here: https://netxms.org/documentation/adminguide/event-processing.html#macros-for-event-processing

          There's no built-in macro for alarm ID, but there's %[script_name] which will call a script from script library. There'll be a few variables set in the script, specifically:
          $object - always is set
          $node - set if event is created on a node
          $event - when script is called from EPP
          $alarm - if at given moment of event processing by EPP rules an alarm is already created.

          $alarm variable has Alarm class described here: https://netxms.org/documentation/nxsl-latest/#class-alarm , so simple script

          return $alarm.id;

          should do the job.

          1 Reply Last reply
          0
          • R
            R
            richard21
            wrote on last edited by
            #5

            Hi Filipp

            thanks for the assistance that works great for new alarms unfortunately when it runs for a terminating alarm it doesn't return the alarm id

            Regards
            Richard

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

              Well, while not being a LLM, I've hallucinated about $alarm :). It does not actually exist.

              But in $event there's lastAlarmKey attribute, so we can use that to get alarm's ID:

              a = FindAlarmByKey($event.lastAlarmKey);
              return a.id;
              

              Or course, alarm should have a key and this key should be unique.

              At some point we will add lastAlarmID attribute to $event.

              1 Reply Last reply
              0
              • R
                R
                richard21
                wrote on last edited by
                #7

                Hi Filipp,

                thanks for the reply that also works for new Alarms but this issue I have is when the event is raised for terminating the alarm it doesn't work and raises the below

                Error:
                Minor vm-netxms-srev SYS_SCRIPT_ERROR Script (getAlarmID) execution error: Error 14 in line 3: Function or operation argument is not an object 07.10.2025 08:58:16

                Script:
                //return $event.id;
                a = FindAlarmByKey($event.lastAlarmKey);
                return a.id;

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

                  Well, yes, FindAlarmByKey() is not searching through already terminated alarms, only current ones. And even if everything happens within one  EPP rule, alarm termination happens first and server action happens after that.

                  So the solution for now is to store the ID somehow before alarm termination. We can use filtering script in the EPP rule:

                  a = FindAlarmByKey($event.lastAlarmKey);
                  $event.setNamedParameter("lastAlarmID", a.id);
                  return true;
                  

                  return true; is needed since this is filtering script and EPP rule will be processed further only if this script returns true.

                  And in your script that is used by the %[script] macro:

                  return $event.getParameter("lastAlarmID");
                  

                  We are adding a new parameter to the event. This parameter will be accessible in any EPP rule that goes below the one where it's being added.

                  Ah, and actually you don't need the %[script] thing any more - you can just use %<lastAlarmID> macro - this should return value of event's parameter.

                  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