NetXMS Support Forum

English Support => Feature Requests => Topic started by: Borgso on March 26, 2014, 10:55:14 PM

Title: nxshell bulk, missing enable flags
Post by: Borgso on March 26, 2014, 10:55:14 PM
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.
Title: Re: nxshell bulk, missing enable flags
Post by: Victor Kirhenshtein on March 27, 2014, 03:46:29 PM
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
Title: Re: nxshell bulk, missing enable flags
Post by: Borgso on March 28, 2014, 08:26:56 AM
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)
Title: Re: nxshell bulk, missing enable flags
Post by: Victor Kirhenshtein on March 31, 2014, 11:36:27 AM
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
Title: Re: nxshell bulk, missing enable flags
Post by: Borgso on March 31, 2014, 03:24:44 PM
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)