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. Auto apply Rules bases on SNMP Value

Auto apply Rules bases on SNMP Value

Scheduled Pinned Locked Moved Support
5 Posts 3 Posters 19.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.
  • F
    F
    francoism
    wrote on last edited by
    #1

    Hi Guys,

    First off, great program. I have been using it for about 2 weeks. I want this to be my Dude server replacement. It has so many uses and I am very excited in what it can do.

    Anyways, I need some help with applying a Template.

    Here is my code

    snmp = CreateSNMPTransport($node);
    oid = SNMPGetValue(snmp,".1.2.840.10036.3.1.2.1.3.10"); // Device name
    if (oid == "PowerBeam AC 500")
        return true;

    The idea is to apply the filter if the SNMP returns "PowerBeam AC 500". It does when I snmpwalk it. So there must be something wrong with how I am trying to use the script.

    Please help.

    1 Reply Last reply
    0
    • T
      T
      tomaskir
      wrote on last edited by
      #2

      Here is a script with error handling and a bit better recognition (using regex ~= rather then just total comparison ==)

      oid = ".1.2.840.10036.3.1.2.1.3.10.0";
      
      tube = CreateSNMPTransport($node);
      if (tube == null)
        return false;
      
      value = SNMPGetValue(tube, oid);
      if (value == null)
        return false;
      
      return value ~= "PowerBeam AC 500";
      
      1 Reply Last reply
      0
      • F
        F
        francoism
        wrote on last edited by
        #3

        I have added this rule but does not seem to work. Is there a way to debug these rules to see output?

        1 Reply Last reply
        0
        • T
          T
          tomaskir
          wrote on last edited by
          #4

          Sure, just add some

          trace(0, "some message");
          

          Into the code, and then look at netxmsd log file.

          1 Reply Last reply
          0
          • Z
            Z
            zsing82
            wrote on last edited by
            #5

            This worked for me:

            return $node->sysDescription like "HP*Switch*";
            

            You can replace sysDescription with other node attributes:
            https://wiki.netxms.org/wiki/NXSL:Node

            It's an indirect SNMP call, but I thought it might help.

            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