Search in sources :

Example 1 with SnmpV2TrapBuilder

use of org.opennms.netmgt.snmp.SnmpV2TrapBuilder in project opennms by OpenNMS.

the class SnmpTrapForwarderHelper method sendV2EndSyncInform.

public void sendV2EndSyncInform() {
    long trapTimeStamp = 0;
    try {
        SnmpV2TrapBuilder inform = snmpTrapHelper.createV2Inform(".1.3.6.1.4.1.5813.1.6", Long.toString(trapTimeStamp));
        inform.sendInform(getIp(), getPort(), getTimeout(), getRetries(), getCommunity());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SnmpV2TrapBuilder(org.opennms.netmgt.snmp.SnmpV2TrapBuilder) UnknownHostException(java.net.UnknownHostException)

Example 2 with SnmpV2TrapBuilder

use of org.opennms.netmgt.snmp.SnmpV2TrapBuilder in project opennms by OpenNMS.

the class SnmpTrapForwarderHelper method sendV2StartSyncInform.

public void sendV2StartSyncInform() {
    long trapTimeStamp = 0;
    try {
        SnmpV2TrapBuilder inform = snmpTrapHelper.createV2Inform(".1.3.6.1.4.1.5813.1.5", Long.toString(trapTimeStamp));
        inform.sendInform(getIp(), getPort(), getTimeout(), getRetries(), getCommunity());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : SnmpV2TrapBuilder(org.opennms.netmgt.snmp.SnmpV2TrapBuilder) UnknownHostException(java.net.UnknownHostException)

Example 3 with SnmpV2TrapBuilder

use of org.opennms.netmgt.snmp.SnmpV2TrapBuilder in project opennms by OpenNMS.

the class SnmpTrapHelper method forwardV2Inform.

/**
     * Create an SNMP V2 inform 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 forwardV2Inform(SnmpTrapConfig trapConfig) throws SnmpTrapException {
    SnmpV2TrapBuilder trap = SnmpUtils.getV2InformBuilder();
    populateTrapBuilder(trap, trapConfig);
    try {
        SnmpAgentConfig config = getAgentConfig(trapConfig);
        trap.sendInform(config.getAddress().getHostName(), config.getPort(), config.getTimeout(), config.getRetries(), config.getReadCommunity());
    } catch (Throwable e) {
        throw new SnmpTrapException("Failed to send trap " + e.getMessage(), e);
    }
}
Also used : SnmpAgentConfig(org.opennms.netmgt.snmp.SnmpAgentConfig) SnmpV2TrapBuilder(org.opennms.netmgt.snmp.SnmpV2TrapBuilder)

Example 4 with SnmpV2TrapBuilder

use of org.opennms.netmgt.snmp.SnmpV2TrapBuilder in project opennms by OpenNMS.

the class SnmpTrapHelper method createV2Inform.

/**
     * Create an SNMP V2 inform 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 SnmpV2TrapBuilder createV2Inform(String trapOid, String sysUpTime) throws SnmpTrapHelperException {
    SnmpV2TrapBuilder packet = SnmpUtils.getV2InformBuilder();
    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 : SnmpV2TrapBuilder(org.opennms.netmgt.snmp.SnmpV2TrapBuilder)

Example 5 with SnmpV2TrapBuilder

use of org.opennms.netmgt.snmp.SnmpV2TrapBuilder 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)

Aggregations

SnmpV2TrapBuilder (org.opennms.netmgt.snmp.SnmpV2TrapBuilder)6 UnknownHostException (java.net.UnknownHostException)4 SnmpTrapBuilder (org.opennms.netmgt.snmp.SnmpTrapBuilder)2 SnmpAgentConfig (org.opennms.netmgt.snmp.SnmpAgentConfig)1