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. Template autoapply rules

Template autoapply rules

Scheduled Pinned Locked Moved Support
5 Posts 3 Posters 39.9k 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.
  • M
    M
    mmarin11
    wrote on last edited by
    #1

    Dear community.

    I'm trying to apply a template for ICMP monitoring to devices that are under specific containers and I'm having issues with the Automatic apply rule configuration

    for (p : $node->parents) {
        if (p->type == 5 && (p->id==109031 || p->id==42342))
            return true;
    }

    What would be the best way to apply a template if the device is under specific containers?

    Has someone used the new function isDirectParent(object)?

    Thank you

     


    Properties for ICMP 2021-08-15 12-36-33.png

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

      chances are that adding

      else
      {
        return false;
      }
      

      will fix the issue.

      In overall you can use
      trace(0, "your debug");
      PollerTrace("your debug");
      to debug what's happeing. First one adds to server log, the latter - to the output of poll messages when you do e.g. Configuration poll from node's context menu.

      1 Reply Last reply
      0
      • L
        L
        lweidig
        wrote on last edited by
        #3

        In addition to what Filipp stated the screenshot attached does not actually match the code in the message.  You simply have return; and not return true;.  I would probably not include the return false; in an else clause either, but simply as the last statement so that anything falling through gets tagged like this.

        1 Reply Last reply
        0
        • M
          M
          mmarin11
          wrote on last edited by
          #4

          The code that worked is:

          Thanks Filipp/Iweidig

          parents = GetNodeParents($node);
          for (p : parents) {
              if (p->type == 5 && (p->id==109031 || p->id==55839 ||p->id==177))
                  {
                  
                  return true;
              }
          }
          return false;

          1 Reply Last reply
          0
          • L
            L
            lweidig
            wrote on last edited by
            #5

            Glad to hear it is working, mark topic [SOLVED]!

            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