Search in sources :

Example 21 with SnmpTrapBuilder

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();
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) SnmpTrapBuilder(org.opennms.netmgt.snmp.SnmpTrapBuilder)

Example 22 with SnmpTrapBuilder

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();
    }
}
Also used : SnmpV3TrapBuilder(org.opennms.netmgt.snmp.SnmpV3TrapBuilder) UnknownHostException(java.net.UnknownHostException) SnmpTrapBuilder(org.opennms.netmgt.snmp.SnmpTrapBuilder)

Example 23 with SnmpTrapBuilder

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();
    }
}
Also used : SnmpV2TrapBuilder(org.opennms.netmgt.snmp.SnmpV2TrapBuilder) UnknownHostException(java.net.UnknownHostException) SnmpTrapBuilder(org.opennms.netmgt.snmp.SnmpTrapBuilder)

Example 24 with SnmpTrapBuilder

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;
}
Also used : SnmpTrapBuilder(org.opennms.netmgt.snmp.SnmpTrapBuilder)

Example 25 with SnmpTrapBuilder

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();
    }
}
Also used : SnmpV2TrapBuilder(org.opennms.netmgt.snmp.SnmpV2TrapBuilder) UnknownHostException(java.net.UnknownHostException) SnmpTrapBuilder(org.opennms.netmgt.snmp.SnmpTrapBuilder)

Aggregations

SnmpTrapBuilder (org.opennms.netmgt.snmp.SnmpTrapBuilder)26 UnknownHostException (java.net.UnknownHostException)15 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)5 SnmpObjId (org.opennms.netmgt.snmp.SnmpObjId)5 SnmpV3TrapBuilder (org.opennms.netmgt.snmp.SnmpV3TrapBuilder)5 Test (org.junit.Test)2 SnmpV2TrapBuilder (org.opennms.netmgt.snmp.SnmpV2TrapBuilder)2 InetAddress (java.net.InetAddress)1 SQLException (java.sql.SQLException)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 CamelBlueprintTest (org.opennms.core.test.camel.CamelBlueprintTest)1 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)1 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)1 Parm (org.opennms.netmgt.xml.event.Parm)1 Snmp (org.opennms.netmgt.xml.event.Snmp)1 Value (org.opennms.netmgt.xml.event.Value)1 OctetString (org.snmp4j.smi.OctetString)1