Netxms 3.1.261 and device discovery

Started by jermudgeon, December 12, 2019, 10:11:19 PM

Previous topic - Next topic

jermudgeon

I have a large class of devices (perhaps mostly Cisco?) that are failing discovery in an odd way.

1) Devices are detected with isSNMP=Yes, GENERIC driver, and added to db
2) Manual inspection shows that devices were added with SNMP 'public' community
3) Devices respond to a snmpwalk using 'public' with the following:
iso.3.6.1.2.1 = No more variables left in this MIB View (It is past the end of the MIB tree)
Note that this is a different response than with an invalid string; with an invalid string, queries just time out. With this (ACLed) string, 'public' simply has no allowed views.
4) Devices (and discovery) are configured with a *different* SNMP string which does actually work via a walk, but not via discovery.

Is there a way to change discovery behavior to try 'public' *last*? There doesn't appear to be an order in the SNMP Configuration that's relevant.

Is there a way to batch change configured SNMP communities on nodes? Batch 'properties' change doesn't seem to exist in the UI. Better yet, can I do this with NXSL? I'm not seeing an attribute that lets me check or set the SNMP community.

Thanks

Filipp Sudanov

Currently community strings are not sorted / prioritized. The value specified in node properties ('public' by default) is tried first, then server tries community strings from settings (in order in which the database returned the list).

There is no way to change community string from NXSL.
The only possible way for now is to use a Jython script launched by nxshell.

jermudgeon

Thank you, Filipp. Has anyone written such a script yet that you know of?

Filipp Sudanov

Here's an example of such script, that will change community string for all nodes, that have SNMP polling enabled
newAuthName = 'public2'
for node in [o for o in session.getAllObjects() if isinstance(o, objects.Node)]: # filter all objects for objects.Node
    if (node.getFlags() & Node.NF_DISABLE_SNMP) = 0: # SNMP polling is not disabled
        if (node.getSnmpAuthName() != newAuthName):
            print('Processing node %s: changing community string from %s to %s' % (node.objectName, node.getSnmpAuthName(), newAuthName))
            md = NXCObjectModificationData(node.objectId)
            md.setSnmpAuthName(newAuthName)
            session.modifyObject(md)


The script is launched like this:
java -jar nxshell-3.1.241.jar script_name.py


There are some examples of Jython scripts in netxms sources in src/client/nxshell/samples/
Some examples are also here: https://wiki.netxms.org/wiki/Using_nxshell_to_automate_bulk_operations
Documentation of API calls is here: https://www.netxms.org/documentation/javadoc/latest/overview-summary.html