private void updateSnmpDataForSnmpInterfaces() {
    if (m_collector != null && m_collector.hasIfTable()) {

      for (IfTableEntry entry : m_collector.getIfTable()) {

        Integer ifIndex = entry.getIfIndex();

        if (ifIndex == null) continue;

        LOG.debug("Updating SNMP Interface with ifIndex {}", ifIndex);

        // first look to see if an snmpIf was created already
        OnmsSnmpInterface snmpIf = m_node.getSnmpInterfaceWithIfIndex(ifIndex);

        if (snmpIf == null) {
          // if not then create one
          snmpIf = new OnmsSnmpInterface(m_node, ifIndex);
        }

        snmpIf.setIfAlias(m_collector.getIfAlias(ifIndex));
        snmpIf.setIfName(m_collector.getIfName(ifIndex));
        snmpIf.setIfType(getIfType(ifIndex));
        snmpIf.setNetMask(getNetMask(ifIndex));
        snmpIf.setIfAdminStatus(getAdminStatus(ifIndex));
        snmpIf.setIfDescr(m_collector.getIfDescr(ifIndex));
        snmpIf.setIfSpeed(m_collector.getInterfaceSpeed(ifIndex));
        snmpIf.setPhysAddr(m_collector.getPhysAddr(ifIndex));
      }
    }
  }
Ejemplo n.º 2
0
 public OnmsSnmpInterface createInterfaceFromRow() {
   final OnmsSnmpInterface snmpIface = new OnmsSnmpInterface(null, getIfIndex());
   snmpIface.setIfAdminStatus(getIfAdminStatus());
   snmpIface.setIfAlias(getIfAlias());
   snmpIface.setIfDescr(getIfDescr());
   snmpIface.setIfName(getIfName());
   snmpIface.setIfOperStatus(getIfOperStatus());
   snmpIface.setIfSpeed(getSpeed());
   snmpIface.setIfType(getIfType());
   snmpIface.setPhysAddr(getPhysAddr());
   return snmpIface;
 }
Ejemplo n.º 3
0
 @Override
 public void run() {
   try {
     OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
     snmpIface.setIfIndex(m_ifIndex);
     snmpIface.setIfName(m_ifName);
     m_upsertService.upsert(m_nodeId, snmpIface, 1000);
   } catch (Throwable t) {
     t.printStackTrace();
     m_throwable.set(t);
   }
 }
Ejemplo n.º 4
0
  @Test
  @JUnitTemporaryDatabase
  public void testInsert() {
    String newIfName = "newIf0";
    assertEquals(0, countIfs(m_populator.getNode1().getId(), 1001, newIfName));

    // add non existent snmpiface
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
    snmpIface.setNode(m_populator.getNode1());
    snmpIface.setIfIndex(1001);
    snmpIface.setIfName(newIfName);

    m_upsertService.upsert(m_populator.getNode1().getId() /* nodeid */, snmpIface, 0);

    assertEquals(1, countIfs(m_populator.getNode1().getId(), 1001, newIfName));
  }
Ejemplo n.º 5
0
  @Test
  @JUnitTemporaryDatabase
  public void testUpdate() {
    String oldIfName = "eth0";
    String newIfName = "newIf0";
    assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
    assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, newIfName));

    // add non existent snmpiface
    OnmsSnmpInterface snmpIface = new OnmsSnmpInterface();
    snmpIface.setIfIndex(2);
    snmpIface.setIfName(newIfName);

    m_upsertService.upsert(m_populator.getNode1().getId(), snmpIface, 0);

    assertEquals(0, countIfs(m_populator.getNode1().getId(), 2, oldIfName));
    assertEquals(1, countIfs(m_populator.getNode1().getId(), 2, newIfName));
  }
  private void updateSnmpDataForInterface(OnmsIpInterface ipIf) {
    if (m_collector == null || !m_collector.hasIpAddrTable() || !m_collector.hasIfTable()) {
      return;
    }

    final InetAddress inetAddr = ipIf.getIpAddress();
    final String ipAddr = InetAddressUtils.str(inetAddr);

    LOG.debug("Creating SNMP info for interface {}", ipAddr);

    int ifIndex = m_collector.getIfIndex(inetAddr);
    if (ifIndex == -1) {
      return;
    }

    // first look to see if an snmpIf was created already
    OnmsSnmpInterface snmpIf = m_node.getSnmpInterfaceWithIfIndex(ifIndex);

    if (snmpIf == null) {
      // if not then create one
      snmpIf = new OnmsSnmpInterface(m_node, ifIndex);
      snmpIf.setIfAlias(m_collector.getIfAlias(ifIndex));
      snmpIf.setIfName(m_collector.getIfName(ifIndex));
      snmpIf.setIfType(getIfType(ifIndex));
      snmpIf.setNetMask(getNetMask(ifIndex));
      snmpIf.setIfAdminStatus(getAdminStatus(ifIndex));
      snmpIf.setIfDescr(m_collector.getIfDescr(ifIndex));
      snmpIf.setIfSpeed(m_collector.getInterfaceSpeed(ifIndex));
      snmpIf.setPhysAddr(m_collector.getPhysAddr(ifIndex));
    }

    snmpIf.setCollectionEnabled(true);

    ipIf.setSnmpInterface(snmpIf);

    // FIXME: Improve OpenNMS to provide these values
    // ifOperStatus

  }