nxshell bulk, missing enable flags
-
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.htmlAnd 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. -
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 -
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) -
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 -
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 getFlagsThen 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)
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