org.snmp4j.smi.OID.toString()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.snmp4j.smi.OID.toString()方法的一些代码示例,展示了OID.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OID.toString()方法的具体详情如下:
包路径:org.snmp4j.smi.OID
类名称:OID
方法名:toString

OID.toString介绍

[英]Return a string representation that can be parsed again to this OIDby #OID(String).
[中]返回可以再次解析到此OIDby#OID(字符串)的字符串表示形式。

代码示例

代码示例来源:origin: apache/nifi

/**
   * @see org.apache.nifi.snmp.processors.SNMPWorker#toString()
   */
  @Override
  public String toString() {
    return super.toString() + ", OID:" + this.oid.toString();
  }
}

代码示例来源:origin: OpenNMS/opennms

private Variable findValueForOID(final OID oid) throws SnmpErrorStatusException {
  final Object val = m_vars.get(oid);
  if (val == null) {
    return null;
  } else if (val instanceof Variable) {
    return (Variable)val;
  }
  return getVariableFromValueString(oid.toString(), (String)val);
}

代码示例来源:origin: org.opennms.tests/org.opennms.tests.mock-snmp-agent

private Variable findValueForOID(final OID oid) throws SnmpErrorStatusException {
  final Object val = m_vars.get(oid);
  if (val == null) {
    return null;
  } else if (val instanceof Variable) {
    return (Variable)val;
  }
  return getVariableFromValueString(oid.toString(), (String)val);
}

代码示例来源:origin: org.openhab.binding/org.openhab.binding.snmp

@Override
public String toString() {
  return "SnmpBindingConfigElement [address=" + address.toString() + ", oid=" + oid.toString()
      + ", refreshInterval=" + refreshInterval + ", community=" + community.toString() + "]";
}

代码示例来源:origin: org.apache.nifi/nifi-snmp-processors

/**
   * @see org.apache.nifi.snmp.processors.SNMPWorker#toString()
   */
  @Override
  public String toString() {
    return super.toString() + ", OID:" + this.oid.toString();
  }
}

代码示例来源:origin: fbacchella/jrds

/**
 * If the key type is an OID, it is directly the OID suffix, no look up will
 * be done
 * 
 * @param indexKey
 */
public boolean configure(OID indexKey) {
  this.indexKey = indexKey.toString();
  this.key = indexKey;
  return configure();
}

代码示例来源:origin: com.github.kaitoy.sneo/sneo-core

@Override
public String toString() {
 return context.toString() + oid.toString();
}

代码示例来源:origin: org.jboss.jbossas/jboss-snmp

private void processPDUv2c(PDU pdu){
   StringBuffer sbuf = new StringBuffer();
   sbuf.append("\nV2 Trap from agent ").append(this.bindAddress.toString());
   sbuf.append(" on port ").append(this.port);
   sbuf.append("\n");
  
   Vector bindings = pdu.getVariableBindings();
   Iterator it = bindings.iterator();
   int counter = 0;
   while (it.hasNext())
   {
     VariableBinding vb = (VariableBinding)it.next();
     if (vb != null) {
       sbuf.append("Varbind[").append(counter++).append("] := ");
       sbuf.append(vb.getOid().toString()).append(" --> ");
       sbuf.append(vb.getVariable().toString()).append("\n");
     }
   }
   sbuf.append("\nLength............. ").append(counter);
   log.debug(sbuf.toString());
}

代码示例来源:origin: org.jboss.jbossas/jboss-snmp

private void processScopedPDU(ScopedPDU pdu) {
  //****
   StringBuffer sbuf = new StringBuffer();
   sbuf.append("\nV3 Trap from agent ").append(this.bindAddress.toString());
   sbuf.append(" on port ").append(this.port);
   sbuf.append("\n");
  
   Vector bindings = pdu.getVariableBindings();
   Iterator it = bindings.iterator();
   int counter = 0;
   while (it.hasNext())
   {
     VariableBinding vb = (VariableBinding)it.next();
     if (vb != null) {
       sbuf.append("Varbind[").append(counter++).append("] := ");
       sbuf.append(vb.getOid().toString()).append(" --> ");
       sbuf.append(vb.getVariable().toString()).append("\n");
     }
   }
   sbuf.append("\nLength............. ").append(counter);
   log.debug(sbuf.toString());
  
}

代码示例来源:origin: org.mobicents.tools.snmp.adaptor/core

private void processPDUv2c(PDU pdu){
   StringBuffer sbuf = new StringBuffer();
   sbuf.append("\nV2 Trap from agent ").append(this.bindAddress.toString());
   sbuf.append(" on port ").append(this.port);
   sbuf.append("\n");
  
   Vector bindings = pdu.getVariableBindings();
   Iterator it = bindings.iterator();
   int counter = 0;
   while (it.hasNext())
   {
     VariableBinding vb = (VariableBinding)it.next();
     if (vb != null) {
       sbuf.append("Varbind[").append(counter++).append("] := ");
       sbuf.append(vb.getOid().toString()).append(" --> ");
       sbuf.append(vb.getVariable().toString()).append("\n");
     }
   }
   sbuf.append("\nLength............. ").append(counter);
   log.debug(sbuf.toString());
}

代码示例来源:origin: org.mobicents.tools.snmp.adaptor/core

private void processScopedPDU(ScopedPDU pdu) {
  //****
   StringBuffer sbuf = new StringBuffer();
   sbuf.append("\nV3 Trap from agent ").append(this.bindAddress.toString());
   sbuf.append(" on port ").append(this.port);
   sbuf.append("\n");
  
   Vector bindings = pdu.getVariableBindings();
   Iterator it = bindings.iterator();
   int counter = 0;
   while (it.hasNext())
   {
     VariableBinding vb = (VariableBinding)it.next();
     if (vb != null) {
       sbuf.append("Varbind[").append(counter++).append("] := ");
       sbuf.append(vb.getOid().toString()).append(" --> ");
       sbuf.append(vb.getVariable().toString()).append("\n");
     }
   }
   sbuf.append("\nLength............. ").append(counter);
   log.debug(sbuf.toString());
  
}

代码示例来源:origin: org.jboss.jbossas/jboss-snmp

private void processPDUv1(PDUv1 pdu) {
   StringBuffer sbuf = new StringBuffer();
   sbuf.append("\nV1 Trap from agent ").append(this.bindAddress.toString());
   sbuf.append(" on port ").append(this.port);
   sbuf.append("\nIP Address......... ").append(pdu.getAgentAddress().toString());
   sbuf.append("\nEnterprise Id...... ").append(pdu.getEnterprise());
   sbuf.append("\nGeneric ........... ").append(pdu.getGenericTrap());
   sbuf.append("\nSpecific .......... ").append(pdu.getSpecificTrap());
   sbuf.append("\nTimeStamp ......... ").append(pdu.getTimestamp());
   
   sbuf.append("\n");
  
   Vector bindings = pdu.getVariableBindings();
   Iterator it = bindings.iterator();
   int counter = 0;
   while (it.hasNext())
   {
     VariableBinding vb = (VariableBinding)it.next();
     if (vb != null) {
       sbuf.append("Varbind[").append(counter++).append("] := ");
       sbuf.append(vb.getOid().toString()).append(" --> ");
       sbuf.append(vb.getVariable().toString()).append("\n");
     }
   }
   sbuf.append("\nLength............. ").append(counter);
   log.debug(sbuf.toString());
}

代码示例来源:origin: org.mobicents.tools.snmp.adaptor/core

private void processPDUv1(PDUv1 pdu) {
   StringBuffer sbuf = new StringBuffer();
   sbuf.append("\nV1 Trap from agent ").append(this.bindAddress.toString());
   sbuf.append(" on port ").append(this.port);
   sbuf.append("\nIP Address......... ").append(pdu.getAgentAddress().toString());
   sbuf.append("\nEnterprise Id...... ").append(pdu.getEnterprise());
   sbuf.append("\nGeneric ........... ").append(pdu.getGenericTrap());
   sbuf.append("\nSpecific .......... ").append(pdu.getSpecificTrap());
   sbuf.append("\nTimeStamp ......... ").append(pdu.getTimestamp());
   
   sbuf.append("\n");
  
   Vector bindings = pdu.getVariableBindings();
   Iterator it = bindings.iterator();
   int counter = 0;
   while (it.hasNext())
   {
     VariableBinding vb = (VariableBinding)it.next();
     if (vb != null) {
       sbuf.append("Varbind[").append(counter++).append("] := ");
       sbuf.append(vb.getOid().toString()).append(" --> ");
       sbuf.append(vb.getVariable().toString()).append("\n");
     }
   }
   sbuf.append("\nLength............. ").append(counter);
   log.debug(sbuf.toString());
}

代码示例来源:origin: org.apache.servicemix/servicemix-snmp

public void convertToJBI(MessageExchange exchange, NormalizedMessage inMsg, PDU request, PDU response)
    throws MessagingException {
    // the output buffer
    StringBuffer sb = new StringBuffer();
    
    // prepare the header
    sb.append(SNMP_TAG_OPEN);
        
    // now loop all variables of the response
    for (Object o : response.getVariableBindings()) {
      VariableBinding b = (VariableBinding)o;

      sb.append(ENTRY_TAG_OPEN);
      sb.append(OID_TAG_OPEN);
      sb.append(b.getOid().toString());
      sb.append(OID_TAG_CLOSE);
      sb.append(VALUE_TAG_OPEN);
      sb.append(b.getVariable().toString());
      sb.append(VALUE_TAG_CLOSE);
      sb.append(ENTRY_TAG_CLOSE);
    }
    
    // prepare the footer
    sb.append(SNMP_TAG_CLOSE);
    
    // now put the buffer to the message content
    inMsg.setContent(new StringSource(sb.toString()));
  }
}

代码示例来源:origin: activequant/aq2o

/**
 * Method to set an SNMP value on the facade.
 * 
 * @param key
 * @param value
 */
public void setValue(String key, Integer value) throws Exception {
  if (!scalars.containsKey(key)) {
    if (!oidMap.containsKey(key))
      throw new Exception("OID for " + key + " not registered. ");
    OID oid = oidMap.get(key);
    MOScalar mo = MOScalarFactory.createReadOnly(oid, key);
    scalars.put(key, mo);
    registerManagedObject(mo, oid.toString());
  }
  MOScalar mo = scalars.get(key);
  if (mo != null) {
    mo.setValue(new Integer32(value));
  }
}

代码示例来源:origin: com.rogueai/snmp2bean

private void parseV1(PDUv1 pdu) {
  // parse headers
  valueMap.put(ENTERPRISE, pdu.getEnterprise().toString());
  valueMap.put(AGENT_ADDR, pdu.getAgentAddress());
  valueMap.put(GENERIC_TRAP, pdu.getGenericTrap());
  valueMap.put(SPECIFIC_TRAP, pdu.getSpecificTrap());
  valueMap.put(TIME_STAMP, pdu.getTimestamp());
  OID trapOid = SnmpConstants.getTrapOID(pdu.getEnterprise(), pdu
      .getGenericTrap(), pdu.getSpecificTrap());
  valueMap.put(TRAP_OID, trapOid.toString());
  // parse variable bindings
  Vector vbs = pdu.getVariableBindings();
  for (Iterator it = vbs.iterator(); it.hasNext();) {
    VariableBinding vb = (VariableBinding) it.next();
    OID oid = vb.getOid();
    Variable var = vb.getVariable();
    valueMap.put(oid.toString(), ((OID) var).getValue());
  }
}

代码示例来源:origin: com.rogueai/snmp2bean

private void parseV2c(PDU pdu) {
  //set the agent address the same to peer address
  valueMap.put(AGENT_ADDR, getPeerAddr());
  // parse header
  Vector vbs = pdu.getVariableBindings();
  for (Iterator it = vbs.iterator(); it.hasNext();) {
    VariableBinding vb = (VariableBinding) it.next();
    OID oid = vb.getOid();
    Variable var = vb.getVariable();
    if (oid.equals(SnmpConstants.snmpTrapOID)) {
      valueMap.put(TRAP_OID, ((OID) var).getValue().toString());
    } else if (oid.equals(SnmpConstants.sysUpTime)) {
      valueMap.put(TIME_STAMP, ((OID) var).getValue());
    } else {
      valueMap.put(oid.toString(), ((OID) var).getValue());
    }
  }
}

代码示例来源:origin: com.rogueai/snmp2bean

protected void populateProperties(Object object, PDU pdu) throws InstantiationException, IllegalAccessException {
  Field[] propFields = SnmpServiceUtil.getPropFields(object.getClass());
  Vector<? extends VariableBinding> variableBindings = pdu.getVariableBindings();
  for (Field propField : propFields) {
    propField.setAccessible(true);
    MibObjectType mot = propField.getAnnotation(MibObjectType.class);
    OID oid = new OID(mot.oid());
    VariableBinding variableBinding = findVariableBindingByOid(oid, variableBindings);
    if (variableBinding != null) {
      Object value = null;
      
      if (mot.smiType() == SmiType.OID) {
        value = variableBinding.getOid().toString();
      }
      else 
        value = getValueFromVariableAndType(variableBinding.getVariable(), mot);
      
      if (value != null) propField.set(object, value);
    }
  }
}

代码示例来源:origin: org.snmp4j/snmp4j

} else {
  out.print("REPORT contains unknown OID ("
      + oid.toString() + ").");

代码示例来源:origin: org.openscada.atlantis/org.openscada.da.server.snmp

private SNMPItem createItem ( final OID oid )
{
  String itemId;
  if ( oid.size () > 0 )
  {
    itemId = oid.toString ();
  }
  else
  {
    itemId = "";
  }
  final String id = getItemIDPrefix () + "." + itemId;
  final SNMPItem item = new SNMPItem ( this, id, oid );
  final MapBuilder<String, Variant> builder = new MapBuilder<String, Variant> ();
  builder.put ( "snmp.oid", Variant.valueOf ( oid.toString () ) );
  if ( this.mibManager != null )
  {
    this.mibManager.fillAttributes ( oid.toString (), builder );
  }
  this.storage.added ( new ItemDescriptor ( item, builder.getMap () ) );
  ChainCreator.applyDefaultInputChain ( item );
  this.hive.registerItem ( item );
  return item;
}

相关文章