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. Actions - Parameter?

Actions - Parameter?

Scheduled Pinned Locked Moved Support
9 Posts 2 Posters 38.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.
  • J
    J
    jdl
    wrote on last edited by
    #1

    Hi all,

    Having defined several actions, I was wondering whether there is a way to define actions (remote or not) in the server related panel to which some parameters could be given when called through an event policy.

    That would be very interesting as a defined action could be so generic that it would be called in several events but with different parameters. Example, a script "start_process.pl" to which you would give the process name and the user whose rights shall be used to start it. You may also want to provide the remote node name on which to start this process...

    Cheers,
    Jdamien

    1 Reply Last reply
    0
    • J
      J
      jdl
      wrote on last edited by
      #2

      In the same context...

      Would be nice to pass as argument the email addresses for the "sendmail" action!
      And why not also content and subject or a specific template... well a bit more flexibility around here would be very powerful.

      Cheers,

      Jdamien

      1 Reply Last reply
      0
      • J
        J
        jdl
        wrote on last edited by
        #3

        I would appreciate if someone could take some time to put some inputs here on this subject...

        Possible? Not possible?
        Another example: Imagine you want to send an email to different staff in function of the alarm/event... do you have to create a specific action for each email?

        Thanks in advance for ur support and time.
        Rgds,

        Jdamien

        1 Reply Last reply
        0
        • V
          V
          Victor Kirhenshtein
          wrote on last edited by
          #4

          Hello!

          You cannot pass parameters to actions directly in event processing policy. However, you can use macros in defined actions - this can cover basic things like host name, event message text, severity, and so on easily. You can also use node's custom attributes (via %{..} macro). And for event more complicated things, you can call NXSL script when expanding macros in actions (via %[..] macro). When called, this script has access to node and event information via $node and $event global variables. You can also set global variable CUSTOM_MESSAGE in event matching script and later insert this value into alarms or actions via %M macro.

          Little example of using scripts

          Goal: send e-mail to different people depending on node's domain name.

          Steps:

          1. create e-mail action as usual, in recipient address field enter %[SelectEmail]
          2. create script in script library, named SelectEmail:
          sub main()
          {
             if (right($node->name, 11) == ".domain.com")
                return "[email protected]";
             if (right($node->name, 12) == ".domain2.com")
                return "[email protected]";
             return "[email protected]";
          }
          
          1. in event processing policy, use defined action as usual

          Best regards,
          Victor

          1 Reply Last reply
          0
          • J
            J
            jdl
            wrote on last edited by
            #5

            Jesus... that's great!
            Thanks for the info...

            But you know my next question, don't you 😉

            Where can I find a description of $node and $event variables/objects?

            So I found $nodes object attributes:
            Attributes of node object:

            name Node name
            id Object identifier
            status Node status (0 = Normal, 1 = Warning, 2 = Minor, 3 = Major, 4 = Critical, 5 = Unknown, 6 = Unmanaged)
            ipAddr Node primary IP address (as text string, like 10.2.1.4)
            isAgent Agent presense flag: 1 if NetXMS agent present on node, 0 if not
            isSNMP SNMP support flag: 1 if SNMP is supported by node, 0 if not
            isBridge Bridge flag: 1 if node is bridge or switch, 0 if not
            isRouter IP router flag: 1 if node is Ip router (can forward IP packets), 0 if not
            isPrinter Printer flag: 1 if node detected to be a network printer, 0 if not
            isCDP CDP (Cisco Discovery Protocol) support flag: 1 node supports CDP, 0 if not
            isSONMP SONMP (SynOptics Network Management Protocol) support flag: 1 node supports SONMP, 0 if not
            isLLDP LLDP (Link Layer Discovery Protocol) support flag: 1 node supports LLDP, 0 if not
            snmpVersion SNMP version used for communication with node's SNMP agent
            snmpOID SNMP object ID
            agentVersion NetXMS agent version (as string, like 0.2.26)
            platformName Platform name, as returned by NetXMS agent (for example, windows-i386)

            Remains $event object attribute...

            Regards,
            JDamien

            1 Reply Last reply
            0
            • V
              V
              Victor Kirhenshtein
              wrote on last edited by
              #6

              Event object (represented by $event variable) has the following attributes:

              code Event code
              id Event ID
              severity Severity code (0=Normal 1=Warning 2=Minor 3=Major 4=Critical)
              timestamp Timestamp as number of seconds since 1 Jan 1970 00:00:00 UTC
              message Message text
              customMessage Custom message text (added in 0.2.27)
              userTag User tag
              parameters Event parameters (this property is an array with first element started at 1)

              Also, starting from version 0.2.27 you can access node's custom attributes directly via object referenced by $node variable, if attribute's name conforms to NXSL identifier naming restrictions (contains only letters, digits, underscore and dollar sign, and not starts with digit). For example, if you define custom attribute terminalId, you can access it in script as following:

              $node->terminalId
              

              Best regards,
              Victor

              1 Reply Last reply
              0
              • J
                J
                jdl
                wrote on last edited by
                #7

                Thanks for this rapid feedback!

                Regards,
                Jdamien

                1 Reply Last reply
                0
                • J
                  J
                  jdl
                  wrote on last edited by
                  #8

                  Hi

                  One more in this topic...

                  Using $event->message we get the message text defined in the "event" panel.
                  How do you differentiate between this message text and the one you can re-define in the "event processing" panel when defining an alarm? Is there a property to the $event object that covers this one?

                  In the script, the $event->message refers to the text message defined in the event not in the alarm which can be more specific as we get additional macro's at that level, right?

                  Regards,
                  Jdamien

                  1 Reply Last reply
                  0
                  • V
                    V
                    Victor Kirhenshtein
                    wrote on last edited by
                    #9

                    Yes, you right - alarm message is unavailable within script. For the next version, I add new global variable $alarmMessage which will hold alarm's text. It's not part of event object (it's only created based on event data), so it will be incorrect and technically slightly harder to put it as $event attribute.

                    Currently you able to pass alarm message to action via %A macro - this can help if you don't need it in script.

                    @jdl said in Actions - Parameter?:

                    In the script, the $event->message refers to the text message defined in the event not in the alarm which can be more specific as we get additional macro's at that level, right?

                    You have only two additional macros at alarm definition level - %m (event's message text) and %M (custom message, if set in matching script). All other macros are the same (including scripts and custom node attributes).

                    Best regards,
                    Victor

                    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