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. Feature Requests
  3. nxshell bulk, missing enable flags

nxshell bulk, missing enable flags

Scheduled Pinned Locked Moved Feature Requests
5 Posts 2 Posters 16.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.
  • B
    B
    Borgso
    wrote on last edited by
    #1

    I managed to set SNMP and NXCP to disable via nxshell bulk, but could not find a way to set flags to enable.
    https://www.netxms.org/documentation/javadoc/latest/org/netxms/client/objects/Node.html

    And does a new discovered node get all flags enabled by default?
    Wouldnt it be better if NetXMS disable SNMP/NetXMS poll if node does not reply to this when Network Discover finds it?
    Ie trying x times and if no reply set flag to disable when creating the node.

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

      Hi!

      If you can disable SNMP (by setting appropriate bit flag), then you can enable it back by clearing same bit flag. If you show me the code I probably will be able to suggest how to change it so it will work.

      Newly discovered nodes comes with all communication channels enabled. They are checked on each configuration poll to detect any changes. System cannot predict why SNMP is not responding for example - vecause it is not enabled and never will, or because of misconfiguration, or it will e enabled next day.

      With latest patches (that will be part of 1.2.14 release) it is also possible to disable let say SNMP for each new discovered node using NXSL script called on SYS_NODE_ADDED event.

      Best regards,
      Victor

      1 Reply Last reply
      0
      • B
        B
        Borgso
        wrote on last edited by
        #3

        Snipcode of the script. the rest is not important to netxms as it just filteres the nodes by name.

        import org.netxms.client.NXCObjectModificationData
        from org.netxms.client.objects import Node
        
        for node in [o for o in s.getAllObjects() if isinstance(o, objects.Node)]:
          name=node.getObjectName()
        
          #newFlags = node.getFlags() | Node.NF_DISABLE_SNMP | Node.NF_DISABLE_NXCP
          #newFlags = node.getFlags() | Node.NF_DISABLE_SNMP
        
          newFlags = node.getFlags() | Node.NF_DISABLE_NXCP
          md = NXCObjectModificationData(node.getObjectId())
          md.setObjectFlags(newFlags)
          session.modifyObject(md)
        
        1 Reply Last reply
        0
        • V
          V
          Victor Kirhenshtein
          wrote on last edited by
          #4

          Then to clear flag you can use the following construct:

            newFlags = node.getFlags() & ~Node.NF_DISABLE_NXCP
            #newFlags = node.getFlags() & ~(Node.NF_DISABLE_NXCP | Node.NF_DISABLE_SNMP)
            md = NXCObjectModificationData(node.getObjectId())
            md.setObjectFlags(newFlags)
            session.modifyObject(md)
          

          Best regards,
          Victor

          1 Reply Last reply
          0
          • B
            B
            Borgso
            wrote on last edited by
            #5

            Ok, managed to understand how it works.

            Wrote my own function to archieve this as i could not get your example to work(?):

            def changeFlags(getFlags, flag, status):
              if flag == "snmp":
                bit=24
              elif flag == "nxcp":
                bit=25
              else:
                return "ERROR, flag missing or not found"
            
              if status == "on":
                getFlags &= ~(1 << bit);
              else:
                getFlags |= (1 << bit);
              return getFlags
            

            Then changing with this:

            getFlags=node.getFlags()
            getFlags = changeFlags(getFlags, "snmp", "on")
            getFlags = changeFlags(getFlags, "nxcp", "off")
            md = NXCObjectModificationData(node.getObjectId())
            md.setObjectFlags(getFlags)
            session.modifyObject(md)
            
            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