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. emailing action variables

emailing action variables

Scheduled Pinned Locked Moved Support
5 Posts 2 Posters 11.0k 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
    raindrop
    wrote on last edited by
    #1

    Hi,

    I am hoping that someone can point me in the right direction with my query.  I have been searching both the forums and google, but so far not come up with an answer.

    I am very new to NetXMS and still learning my way around it.

    What I am hoping to achieve is that when an Alarm is triggered, an email gets sent to me with details about the alarm. I have managed to get quite a lot of information on the email based on the "macros for event processing" (https://www.netxms.org/documentation/adminguide/event-processing.html#macros-for-event-processing), however what I would like is to be able to include the Container Path of where the object is.

    e.g. Under Infrastructure Services I have 3 containers:-

    Company A
    Company B
    Company C

    within each company I then have sub-containers called "Servers", "Workstation", "Switches", "Routers" etc.

    If a server in Company B triggered a NODE_DOWN alarm, the email would include "Company B > Servers > Server Name".

    I can get the Server Name using %n  but I cannot seem to find how I could get the container names.

    I hope I have explained clearly what I want, and also that someone can point me in the right direction.

    Thank you,
    Phil

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

      Hi,

      there is %[script_name] macro, that calls a script from script library. This way you can prepare any text that will go into your notifications.
      When developing scripts, it's easier to open "Execute script" from context menu of any node. In this case script will be running in context of that node (special variables like $object or $node will be pointing to that specific node). So if you try below script on any node:

      sub getParents(o, path) {
        if (o->id == 2) {  // Infrastructure services
          println(path);
        }
        for (p : o->parents) {
          if (path == "") {
            getParents(p, p->name);
          }
          else
          {
            getParents(p, p->name . " > " . path);
          }
        }
      }
      getParents($object, "");
      

      In will print paths from "Infrastructure services" to that node. The problem is, that a node can be located under several container paths (it's actually a cool feature, as you can arrange your nodes in various ways, e.g. by location, by OS, or you may have a container with nodes that have specific software, require upgrade or attention, etc).
      If there are several possible paths, scrip can just print first that it finds, or you can have some ways to instruct the script what path to take, e.g. you can have a custom attribute on some container under "Infrastructure services" and script will be taking only paths that contain that container.

      Now we just need to modify above script to return the value instead of printing it:

      global r = "";
      sub getParents(o, path) {
        if (o->id == 2 and r == "") {  // Infrastructure services
          r = path;
        }
        for (p : o->parents) {
          if (path == "") {
            getParents(p, p->name);
          }
          else
          {
            getParents(p, p->name . " > " . path);
          }
        }
      }
      getParents($object, "");
      return r;
      

      and this is the script that you have to save into script library. It will return first found path.

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

        Thank you Filipp,

        I have copied your code, and saved it as a new script called "pipsPath" in the Script Library, and then in my email report, added   %[pipsPath]   but when the email comes through it doesn't show any information.

        I am guessing that I haven't done something correctly, have tried searching to see if I can find out what, but have had no luck.

        😞
        Thanks,
        Phil.

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

          Make sure you've copied all lines of second script - last line should be "return r;"

          Try executing this script on any node - right-click a node in object tree, select "Execute script". Paste the script into "Source" and click "Execute" button. In the output it should print, e.g.:

          *** FINISHED ***

          Result: Infrastructure Services

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

            Thanks Filipp,

            You are correct, I had missed the last line.

            This now gives me a path that I can experiment with.

            Thank you again,
            Phil.

            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