use of org.opennms.netmgt.snmp.SnmpTrapBuilder in project opennms by OpenNMS.
the class SnmpTrapForwarderHelper method sendV2EventTrap.
public void sendV2EventTrap(Event event) throws UnknownHostException, SnmpTrapHelperException {
long trapTimeStamp = 0;
SnmpTrapBuilder trap = snmpTrapHelper.createV2Trap(".1.3.6.1.4.1.5813.1.1", Long.toString(trapTimeStamp));
trap = buildEventTrap(event, trap, null);
try {
trap.send(getIp(), getPort(), getCommunity());
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.opennms.netmgt.snmp.SnmpTrapBuilder in project opennms by OpenNMS.
the class SnmpTrapForwarderHelper method sendV3EventTrap.
public void sendV3EventTrap(Event event) throws UnknownHostException, SnmpTrapHelperException {
long trapTimeStamp = 0;
SnmpTrapBuilder trap = snmpTrapHelper.createV3Trap(".1.3.6.1.4.1.5813.1.1", Long.toString(trapTimeStamp));
trap = buildEventTrap(event, trap, null);
SnmpV3TrapBuilder v3trap = (SnmpV3TrapBuilder) trap;
try {
v3trap.send(getIp(), getPort(), getSecurityLevel(), getSecurityname(), getAuthPassPhrase(), getAuthProtocol(), getPrivPassPhrase(), getPrivprotocol());
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.opennms.netmgt.snmp.SnmpTrapBuilder in project opennms by OpenNMS.
the class SnmpTrapForwarderHelper method sendV2AlarmInform.
public void sendV2AlarmInform(Event event, boolean sync) throws UnknownHostException, SnmpTrapHelperException {
long trapTimeStamp = 0;
SnmpTrapBuilder trap = snmpTrapHelper.createV2Inform(".1.3.6.1.4.1.5813.1.3", Long.toString(trapTimeStamp));
trap = buildAlarmTrap(event, sync, trap);
SnmpV2TrapBuilder inform = (SnmpV2TrapBuilder) trap;
try {
inform.sendInform(getIp(), getPort(), getTimeout(), getRetries(), getCommunity());
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.opennms.netmgt.snmp.SnmpTrapBuilder in project opennms by OpenNMS.
the class SnmpTrapHelper method createV2Trap.
/**
* Create an SNMP V2 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 SnmpTrapBuilder createV2Trap(String trapOid, String sysUpTime) throws SnmpTrapHelperException {
SnmpTrapBuilder packet = SnmpUtils.getV2TrapBuilder();
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.SnmpTrapBuilder in project opennms by OpenNMS.
the class SnmpTrapForwarderHelper method sendV2EventInform.
public void sendV2EventInform(Event event) throws UnknownHostException, SnmpTrapHelperException {
long trapTimeStamp = 0;
SnmpTrapBuilder trap = snmpTrapHelper.createV2Inform(".1.3.6.1.4.1.5813.1.1", Long.toString(trapTimeStamp));
trap = buildEventTrap(event, trap, null);
SnmpV2TrapBuilder inform = (SnmpV2TrapBuilder) trap;
try {
inform.sendInform(getIp(), getPort(), getTimeout(), getRetries(), getCommunity());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations