There's no way to rediscover SNMP properties on a discovered node handled by Provisiond

Description

Steps to reproduce the problem:

1) Plain OpenNMS Installation using the default content for the default foreign source.
2) Configure a bad community for an specific IP
3) Send a newSuspect event for that IP through the WebUI
4) Check that SNMP was not discovered (as expected)
5) Fix the bad community through the WebUI
6) Hit Rescan from the node's page
7) Check that the SNMP service was detected

Expected behavior that it not happen:

The node level SNMP Information is populated (like nodeSysOID, etc.)
The SNMP Interfaces are discovered
Collectd starts its job

Current workaround:

Delete the node and send a newSuspect again.

Acceptance / Success Criteria

None

Attachments

1
  • 06 Oct 2014, 02:10 PM

Lucidchart Diagrams

Activity

Show:

Alejandro Galue October 7, 2014 at 9:41 AM

Fixed on revision 2b83a159952867ddb83568617bdbe58cebbd340e for 1.14

Alejandro Galue October 6, 2014 at 2:35 PM
Edited

The attached file contains the code changes required. I tested it on my lab and works as expected.

Alejandro Galue October 6, 2014 at 1:51 PM

I've tested the solution and it works, I mean, the node has now the SNMP settings populated, as well as the IP and SNMP interfaces. If I rerun the rescan again, it will use the primary interface (because now node is going to have one) .....

My doubt is related with how the schedule is created. To me, it seems like that is going to be a one-time run, and the node scan won't be scheduled anymore.

Here is another version of the handler:

@EventHandler(uei = EventConstants.FORCE_RESCAN_EVENT_UEI) public void handleForceRescan(Event e) { final Integer nodeId = new Integer(e.getNodeid().intValue()); removeNodeFromScheduleQueue(nodeId); Runnable r = new Runnable() { @Override public void run() { try { ForceRescanScan scan = createForceRescanScan(nodeId); Task t = scan.createTask(); t.schedule(); t.waitFor(); NodeScanSchedule scheduleForNode = getProvisionService().getScheduleForNode(nodeId, false); // It has 'false' because a node scan was already executed. if (scheduleForNode != null) { addToScheduleQueue(scheduleForNode); } } catch (InterruptedException ex) { LOG.error("Task interrupted waiting for rescan of nodeId {} to finish", nodeId, ex); } catch (ExecutionException ex) { LOG.error("An expected execution occurred waiting for rescan of nodeId {} to finish", nodeId, ex); } } }; m_scheduledExecutor.execute(r);

The difference is that it is going to create a schedule without forcing it (as the node scan has been executed already).

Alejandro Galue October 6, 2014 at 12:08 PM
Edited

I think that we should create a class called ForceRescanScan based on org.opennms.netmgt.provision.service.NewSuspectScan.

Here are the key differences:

1) The constructor should receive a nodeId instead of an IP Address:

public ForceRescanScan(final Integer nodeId, final ProvisionService provisionService, final EventForwarder eventForwarder, final SnmpAgentConfigFactory agentConfigFactory, final DefaultTaskCoordinator taskCoordinator) { m_nodeId = nodeId; m_provisionService = provisionService; m_eventForwarder = eventForwarder; m_agentConfigFactory = agentConfigFactory; m_taskCoordinator = taskCoordinator; }

2) The task should scan an existing node if it has a primary IP interface (which is required for SNMP):

public void run(final BatchTask phase) { scanExistingNode(phase); } protected void scanExistingNode(final BatchTask phase) { LOG.info("Attempting to re-scan node with Id {}", m_nodeId); final OnmsNode node = m_provisionService.getNode(m_nodeId); if (node != null) { OnmsIpInterface iface = m_provisionService.getPrimaryInterfaceForNode(node); if (iface == null) { // NMS-6380, a discovered node added that doesn't have a primary interface yet. iface = node.getIpInterfaces().isEmpty() ? null : node.getIpInterfaces().iterator().next(); } else { LOG.info("The node with ID OP does not have a primary interface", m_nodeId); } if (iface == null) { LOG.info("The node with ID {} does not have any IP addresses", m_nodeId); } else { phase.getBuilder().addSequence( new NodeInfoScan(node, iface.getIpAddress(), node.getForeignSource(), createScanProgress(), m_agentConfigFactory, m_provisionService, node.getId()), new IpInterfaceScan(node.getId(), iface.getIpAddress(), node.getForeignSource(), m_provisionService), new NodeScan(node.getId(), node.getForeignSource(), node.getForeignId(), m_provisionService, m_eventForwarder, m_agentConfigFactory, m_taskCoordinator) ); } } else { LOG.info("Can't find node with ID {}", m_nodeId); } }

Then, we should modify the handler of the forceRescan:

@EventHandler(uei = EventConstants.FORCE_RESCAN_EVENT_UEI) public void handleForceRescan(Event e) { final Integer nodeId = new Integer(e.getNodeid().intValue()); removeNodeFromScheduleQueue(nodeId); Runnable r = new Runnable() { @Override public void run() { try { ForceRescanScan scan = createForceRescanScan(nodeId); Task t = scan.createTask(); t.schedule(); t.waitFor(); } catch (InterruptedException ex) { LOG.error("Task interrupted waiting for rescan of nodeId {} to finish", nodeId, ex); } catch (ExecutionException ex) { LOG.error("An expected execution occurred waiting for rescan of nodeId {} to finish", nodeId, ex); } } }; m_scheduledExecutor.execute(r); } public ForceRescanScan createForceRescanScan(Integer nodeId) { LOG.info("createForceRescanScan called with nodeId: "+nodeId); return new ForceRescanScan(nodeId, m_provisionService, m_eventForwarder, m_agentConfigFactory, m_taskCoordinator); }

That way we are sure that the node information scan, the IP addresses scan, and the standard node scan are going to be executed for the existing node, instead of just the node scan (which only covers running the detectors and policies).

Alejandro Galue September 29, 2014 at 1:47 PM

Also, if there is a change on the physical interfaces, the only way to grab those changes is by re-scanning ifTable and ifXTable and I'm not sure if this functionality is included on one of the mentioned scan tasks.

If you rescan a node managed by Capsd and there are changes on the SNMP interfaces and/or IP interfaces, those changes are going to be persisted properly.

Fixed

Details

Assignee

Reporter

Sprint

Fix versions

Affects versions

Priority

PagerDuty

Created February 3, 2014 at 5:08 PM
Updated October 7, 2014 at 1:39 PM
Resolved October 7, 2014 at 9:41 AM

Flag notifications