@Override public void addVarBind(SnmpTrapBuilder trap, String name, String encoding, String value) throws SnmpTrapException { if (EventConstants.XML_ENCODING_TEXT.equals(encoding)) { try { trap.addVarBind(SnmpObjId.get(name), SnmpUtils.getValueFactory().getCounter64(new BigInteger(value))); } catch (IllegalArgumentException e) { throw new SnmpTrapException("Value " + value + "is invalid for SnmpCounter64"); } catch (NullPointerException e) { throw new SnmpTrapException("Value is null for SnmpCounter64"); } } else { throw new SnmpTrapException("Encoding " + encoding + "is invalid for SnmpCounter64"); } } }
trap.addVarBind(SnmpObjId.get(name), SnmpUtils.getValueFactory().getCounter64(new BigInteger(value)));
SnmpValue snmpValue1 = SnmpUtils.getValueFactory().getCounter64(n.toBigInteger()); SnmpCollectionResource resource1 = new IfInfo(resourceType, agent, ifData); resource1.setAttributeValue(objectType, snmpValue1); SnmpValue snmpValue2 = SnmpUtils.getValueFactory().getCounter64(new BigInteger("40000")); SnmpCollectionResource resource2 = new IfInfo(resourceType, agent, ifData); resource2.setAttributeValue(objectType, snmpValue2);
private SnmpAttribute addAttributeToCollectionResource(SnmpCollectionResource resource, String attributeName, AttributeType attributeType, String attributeInstance, BigInteger value) { MibObject object = createMibObject(attributeType, attributeName, attributeInstance); SnmpAttributeType objectType = new NumericAttributeType(resource.getResourceType(), "default", object, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE)); SnmpValue snmpValue = SnmpUtils.getValueFactory().getCounter64(value); resource.setAttributeValue(objectType, snmpValue); return new SnmpAttribute(resource, objectType, snmpValue); }