use of org.opennms.netmgt.snmp.SnmpTrapBuilder in project opennms by OpenNMS.
the class TrapdIT method testSnmpV2cTrapSend.
@Test
public void testSnmpV2cTrapSend() throws Exception {
String localhost = "127.0.0.1";
InetAddress localAddr = InetAddressUtils.addr(localhost);
SnmpObjId enterpriseId = SnmpObjId.get(".1.3.6.1.4.1.5813");
SnmpObjId trapOID = SnmpObjId.get(enterpriseId, new SnmpInstId(1));
SnmpTrapBuilder pdu = SnmpUtils.getV2TrapBuilder();
pdu.addVarBind(SnmpObjId.get(".1.3.6.1.2.1.1.3.0"), SnmpUtils.getValueFactory().getTimeTicks(0));
pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.1.0"), SnmpUtils.getValueFactory().getObjectId(trapOID));
pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.3.0"), SnmpUtils.getValueFactory().getObjectId(enterpriseId));
EventBuilder defaultTrapBuilder = new EventBuilder("uei.opennms.org/default/trap", "trapd");
defaultTrapBuilder.setInterface(localAddr);
defaultTrapBuilder.setSnmpVersion("v2c");
m_mockEventIpcManager.getEventAnticipator().anticipateEvent(defaultTrapBuilder.getEvent());
EventBuilder newSuspectBuilder = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, "trapd");
newSuspectBuilder.setInterface(localAddr);
m_mockEventIpcManager.getEventAnticipator().anticipateEvent(newSuspectBuilder.getEvent());
pdu.send(localhost, m_trapdConfig.getSnmpTrapPort(), "public");
// Allow time for Trapd and Eventd to do their magic
Thread.sleep(5000);
}
use of org.opennms.netmgt.snmp.SnmpTrapBuilder in project opennms by OpenNMS.
the class EventdStresser method executeStressTest.
private static void executeStressTest() {
SnmpTrapBuilder builder = null;
try {
builder = createBuilder();
stressEventd(builder);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
use of org.opennms.netmgt.snmp.SnmpTrapBuilder 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.SnmpTrapBuilder in project opennms by OpenNMS.
the class SnmpTrapForwarderHelper method sendV1StartSyncTrap.
public void sendV1StartSyncTrap() {
try {
SnmpTrapBuilder trap = snmpTrapHelper.createV1Trap(".1.3.6.1.4.1.5813.1", getSource_ip(), 6, 5, 0);
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 sendV2EndSyncTrap.
public void sendV2EndSyncTrap() {
long trapTimeStamp = 0;
try {
SnmpTrapBuilder trap = snmpTrapHelper.createV2Trap(".1.3.6.1.4.1.5813.1.6", Long.toString(trapTimeStamp));
trap.send(getIp(), getPort(), getCommunity());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations