use of org.opennms.netmgt.snmp.SnmpV3TrapBuilder in project opennms by OpenNMS.
the class SnmpTrapHelper method forwardV3Trap.
/**
* Create an SNMP V3 trap based on the content of the specified trap configuration, and send it to the appropriate destination.
*
* @param trapConfig The trap configuration mapping object
* @throws SnmpTrapException if any.
*/
private void forwardV3Trap(SnmpTrapConfig trapConfig) throws SnmpTrapException {
SnmpV3TrapBuilder trap = SnmpUtils.getV3TrapBuilder();
populateTrapBuilder(trap, trapConfig);
try {
SnmpAgentConfig config = getAgentConfig(trapConfig);
trap.send(config.getAddress().getHostAddress(), config.getPort(), config.getSecurityLevel(), config.getSecurityName(), config.getAuthPassPhrase(), config.getAuthProtocol(), config.getPrivPassPhrase(), config.getPrivProtocol());
} catch (Throwable e) {
throw new SnmpTrapException("Failed to send trap " + e.getMessage(), e);
}
}
use of org.opennms.netmgt.snmp.SnmpV3TrapBuilder in project opennms by OpenNMS.
the class SnmpTrapForwarderHelper method sendV3AlarmInform.
public void sendV3AlarmInform(Event event, boolean sync) throws UnknownHostException, SnmpTrapHelperException {
long trapTimeStamp = 0;
SnmpTrapBuilder trap = snmpTrapHelper.createV3Inform(".1.3.6.1.4.1.5813.1.3", Long.toString(trapTimeStamp));
trap = buildAlarmTrap(event, sync, trap);
SnmpV3TrapBuilder inform = (SnmpV3TrapBuilder) trap;
try {
inform.sendInform(getIp(), getPort(), getTimeout(), getRetries(), getSecurityLevel(), getSecurityname(), getAuthPassPhrase(), getAuthProtocol(), getPrivPassPhrase(), getPrivprotocol());
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.opennms.netmgt.snmp.SnmpV3TrapBuilder in project opennms by OpenNMS.
the class SnmpTrapHelper method createV3Trap.
/**
* Create an SNMP V3 trap with the specified trap object ID, and sysUpTime
* value.
*
* @param trapOid
* The trap object id.
* @param sysUpTime
* The system up time.
* @return The newly-created trap.
* @exception Throws
* SnmpTrapHelperException if the trap cannot be created for
* any reason.
* @throws org.opennms.netmgt.scriptd.helper.SnmpTrapHelperException if any.
*/
public SnmpV3TrapBuilder createV3Trap(String trapOid, String sysUpTime) throws SnmpTrapHelperException {
SnmpV3TrapBuilder packet = SnmpUtils.getV3TrapBuilder();
addVarBinding(packet, SNMP_SYSUPTIME_OID, EventConstants.TYPE_SNMP_TIMETICKS, sysUpTime);
addVarBinding(packet, SNMP_TRAP_OID, EventConstants.TYPE_SNMP_OBJECT_IDENTIFIER, trapOid);
return packet;
}
use of org.opennms.netmgt.snmp.SnmpV3TrapBuilder in project opennms by OpenNMS.
the class SnmpTrapHelper method createV3Inform.
/**
* Create an SNMP V3 trap with the specified trap object ID, and sysUpTime
* value.
*
* @param trapOid
* The trap object id.
* @param sysUpTime
* The system up time.
* @return The newly-created trap.
* @exception Throws
* SnmpTrapHelperException if the trap cannot be created for
* any reason.
* @throws org.opennms.netmgt.scriptd.helper.SnmpTrapHelperException if any.
*/
public SnmpV3TrapBuilder createV3Inform(String trapOid, String sysUpTime) throws SnmpTrapHelperException {
SnmpV3TrapBuilder packet = SnmpUtils.getV3InformBuilder();
addVarBinding(packet, SNMP_SYSUPTIME_OID, EventConstants.TYPE_SNMP_TIMETICKS, sysUpTime);
addVarBinding(packet, SNMP_TRAP_OID, EventConstants.TYPE_SNMP_OBJECT_IDENTIFIER, trapOid);
return packet;
}
use of org.opennms.netmgt.snmp.SnmpV3TrapBuilder in project opennms by OpenNMS.
the class SnmpTrapForwarderHelper method sendV3StartSyncInform.
public void sendV3StartSyncInform() {
long trapTimeStamp = 0;
try {
SnmpV3TrapBuilder inform = snmpTrapHelper.createV3Inform(".1.3.6.1.4.1.5813.1.5", Long.toString(trapTimeStamp));
inform.sendInform(getIp(), getPort(), getTimeout(), getRetries(), getSecurityLevel(), getSecurityname(), getAuthPassPhrase(), getAuthProtocol(), getPrivPassPhrase(), getPrivprotocol());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations