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. Automatic Apply Rule for template not working

Automatic Apply Rule for template not working

Scheduled Pinned Locked Moved Support
4 Posts 3 Posters 32.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.
  • C
    C
    ChrisC
    wrote on last edited by
    #1

    I am trying to make some SNMP templates for devices, but I am having trouble getting them to apply automatically.
    For example, I want to log the POE power usage for switches.
    I can apply them manually and they work, but if I leave it for NetXMS to apply them automatically, nothing happens.
    Please see the attached image.
    For some switches, there is no 2nd PSU, could this be why it doesn't apply automatically?

    Secondly, for switches that don't have a second PSU, is there any way of making the 2nd set of DCIs (1435, 1436 and 1437) optional so it doesn't error?
    I assume I should really be using a loop somehow to find anything under the root of the PSU OID, but I have no idea how to do that yet!
    Thanks!


    Screenshot 2021-09-17 084817.png

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

      In context menu of that node you can select "Execute server script" and try your script there; The node that you right-clicked will be available as $node, so all the attributes will be there.
      You can do

      println $node->snmpOID;
      

      to see what's actually in there.

      Match operation ~= looks to be correct, but you could just use simple comparison with == , then you'd not need to escape with backslashes.
      In out-of-the-box templates there's e.g. SNMP->UPS->APC that has automatic apply rule that is checking some SNMP data.

      The other debugging approach is to use
      PollerTrace("your text");
      or
      trace(0, "your text");
      First one will produce debug output in nxmc when you do Poll-> Configuration poll from node context menu.
      Second will put debug to server log (at debug level 0 in this example)

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

        Hi,

        \ is an escape character in NXSL string, so for actually passing \ to regex processor, you can escape it, like this: "^\\.1\\.3\\.6".

        In simple cases you can use like instead of regexp matching. For example, to match all OIDs starting with .1.3.6.1.2.1 you can use condition

        if (oid like ".1.3.6.1.2.1.*")
        {
           /* match, dio something */
        }
        

        Best regards,
        Victor

        1 Reply Last reply
        0
        • C
          C
          ChrisC
          wrote on last edited by
          #4

          Thanks, it was the "\" causing the problems.
          Once I found the contents of println $node->snmpOID; for the node and use that, it applied with out problems.
          Using "like" will also help for other templates I am trying to make.

          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