Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-12775

interfaceSnmpByIfIndex fails if SNMP interface has no physical address

    XMLWordPrintable

    Details

    • Sprint:
      Horizon 2020 - July 8, Horizon 2020 - July 22
    • Backlog Status:
      Backlog

      Description

      When trying to fetch interface metrics for an SNMP interface, resource retrieval from Newts fails if the interface has no physical address attached.

      Steps to reproduce:
      1) Import a node into OpenNMS and configure SNMP to collect interfaces.
      2) Attempt to retrieve measurements for an interface which has no physical address: 

      GET /rest/measurements/node[<nodeid>].interfaceSnmpByIfIndex[<ifindex>]/ifHCInOctets

      An error will be thrown in web.log:

      2020-06-24 10:03:03,958 WARN  [NewtsFetchStrateg-3484] o.o.n.d.s.DefaultResourceDao: Could not get resource for resource ID "node[<nodeid>].interfaceSnmpByIfIndex[<ifindex>]"
      org.springframework.orm.ObjectRetrievalFailureException: Could not find child resource '<ifindex>' with resource type 'interfaceSnmpByIfIndex' on resource '<ifindex>'
              at org.opennms.netmgt.dao.support.DefaultResourceDao.getChildResource(DefaultResourceDao.java:393) ~[opennms-dao-26.1.0.jar:?]
              at org.opennms.netmgt.dao.support.DefaultResourceDao.getResourceById(DefaultResourceDao.java:313) [opennms-dao-26.1.0.jar:?]
              at jdk.internal.reflect.GeneratedMethodAccessor1200.invoke(Unknown Source) ~[?:?]
              at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
              at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
              at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) [org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
              at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [org.apache.servicemix.bundles.spring-tx-4.2.9.RELEASE_1.jar:?]
              at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [org.apache.servicemix.bundles.spring-tx-4.2.9.RELEASE_1.jar:?]
              at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [org.apache.servicemix.bundles.spring-tx-4.2.9.RELEASE_1.jar:?]
              at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
              at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) [org.apache.servicemix.bundles.spring-aop-4.2.9.RELEASE_1.jar:?]
              at com.sun.proxy.$Proxy140.getResourceById(Unknown Source) [?:?]
              at org.opennms.netmgt.measurements.impl.NewtsFetchStrategy$1.call(NewtsFetchStrategy.java:261) [org.opennms.features.newts-26.1.0.jar:?]
              at org.opennms.netmgt.measurements.impl.NewtsFetchStrategy$1.call(NewtsFetchStrategy.java:258) [org.opennms.features.newts-26.1.0.jar:?]
              at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
              at java.lang.Thread.run(Thread.java:834) [?:?]
      

      I believe this is due to how potential resource keys are computed in InterfaceSnmpResourceType.getKeysFor(): https://github.com/OpenNMS/opennms/blob/opennms-26.1.0-1/opennms-dao/src/main/java/org/opennms/netmgt/dao/support/InterfaceSnmpResourceType.java#L180

      The computed keys do not factor resources in newts without a mac address or trailing hyphen:

      return new String[] {
          replacedIfName + "-",
          replacedIfDescr + "-",
          replacedIfName + "-" + snmpInterface.getPhysAddr(),
          replacedIfDescr + "-" + snmpInterface.getPhysAddr()
      };
      

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              justin.wood Justin Wood
              Reporter:
              justin.wood Justin Wood
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Grooming Date: