in collector/snmp/src/main/java/org/apache/karaf/decanter/collector/snmp/SnmpPoller.java [212:244]
public void onResponse(ResponseEvent event) {
((Snmp) event.getSource()).cancel(event.getRequest(), this);
if (event.getRequest() == null || event.getResponse() == null) {
return;
}
PDU pdu = event.getResponse();
Map<String, Object> data = new HashMap<>();
data.put("type", "snmp.poll");
data.put("peerAddress", event.getPeerAddress());
try {
PropertiesPreparator.prepare(data, configuration);
} catch (Exception e) {
LOGGER.warn("Can't prepare event data", e);
}
// PDU v1 specific variables
if (pdu.getType() == PDU.V1TRAP) {
PDUv1 v1pdu = (PDUv1) pdu;
data.put("enterprise", v1pdu.getEnterprise().toString());
data.put("agentAddress", v1pdu.getAgentAddress().toString());
data.put("genericTrap", v1pdu.getGenericTrap());
data.put("specificTrap", v1pdu.getSpecificTrap());
data.put("timestamp", v1pdu.getTimestamp());
}
// all variables
for (VariableBinding variableBinding : pdu.getVariableBindings()) {
data.put(variableBinding.getOid().toString(), variableBinding.getVariable().toString());
}
// send event
String topic = (configuration.get(EventConstants.EVENT_TOPIC) != null) ? (String) configuration.get(EventConstants.EVENT_TOPIC) : "decanter/collector/snmp";
dispatcher.postEvent(new Event(topic, data));
}