use of org.opennms.netmgt.alarmd.northbounder.snmptrap.TrapData in project opennms by OpenNMS.
the class TrapUtils method getTrapData.
/**
* Gets the trap identity.
*
* @param trapNotification the trap notification
* @return the identity
*/
public static TrapData getTrapData(TrapInformation trapNotification) {
if (trapNotification instanceof Snmp4JV1TrapInformation) {
Snmp4JV1TrapInformation info = (Snmp4JV1TrapInformation) trapNotification;
TrapIdentity identity = info.getTrapIdentity();
TrapData data = new TrapData(identity.getEnterpriseId(), identity.getGeneric(), identity.getSpecific());
for (int i = 0; i < info.getPduLength(); i++) {
VariableBinding v = info.getVarBindAt(i);
SnmpValue value = new Snmp4JValue(v.getVariable());
data.addParameter("." + v.getOid().toString(), value.toDisplayString());
}
return data;
} else if (trapNotification instanceof Snmp4JV2TrapInformation) {
Snmp4JV2TrapInformation info = (Snmp4JV2TrapInformation) trapNotification;
TrapIdentity identity = info.getTrapIdentity();
TrapData data = new TrapData(identity.getEnterpriseId(), identity.getGeneric(), identity.getSpecific());
for (int i = 0; i < info.getPduLength(); i++) {
VariableBinding v = info.getVarBindAt(i);
SnmpValue value = new Snmp4JValue(v.getVariable());
data.addParameter("." + v.getOid().toString(), value.toDisplayString());
}
return data;
}
return null;
}
Aggregations