From 06d2dc8823dbc63f5a0dae1955ac9b21a8928b90 Mon Sep 17 00:00:00 2001 From: Lars Michelsen Date: Wed, 29 Apr 2015 13:25:12 +0200 Subject: [PATCH] Trap translation is now working --- mkeventd/.f12 | 2 -- mkeventd/bin/mkeventd | 25 ++++++++----------------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/mkeventd/.f12 b/mkeventd/.f12 index 55f07255231..37ab83eed42 100644 --- a/mkeventd/.f12 +++ b/mkeventd/.f12 @@ -23,5 +23,3 @@ sudo omd restart $SITE apache echo "Starte EC neu..." sudo omd status $SITE mkeventd && sudo omd restart $SITE mkeventd - - diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd index 69eb4c6d565..07975bb354b 100755 --- a/mkeventd/bin/mkeventd +++ b/mkeventd/bin/mkeventd @@ -1199,15 +1199,20 @@ class EventServer: # MIB node object (like OBJECT-TYPE or other SMI MACROs) node = mib_var.getMibNode() + mod, sym, indices = mib_var.getMibSymbol() + # Only care about the first indice reported. Why should we care about multiple? + # Do we have such cases here? + translated_oid = '%s::%s.%s' % (mod, sym, indices[0].prettyPrint()) + # This MACRO supports SYNTAX clause? if hasattr(node, 'getSyntax'): # Cast value to MIB SYNTAX type (TEXTUAL-CONVENTION) value = node.getSyntax().clone(value) units = node.getUnits() - var_binds.append((oid.prettyPrint(), value.prettyPrint() + ' ' + units)) + var_binds.append((translated_oid, value.prettyPrint() + ' ' + units)) else: - var_binds.append((oid.prettyPrint(), value)) + var_binds.append((translated_oid, value)) return var_binds def process_snmptrap(self, (whole_msg, (ipaddress, port))): @@ -1235,20 +1240,6 @@ class EventServer: else: break # Skip unhandled version - #if proto_version == pysnmp_api.protoVersion1: - # # These fields are available by specification in v1, but not in v2. - - # # use the enterprise oid as application - # application = proto.apiTrapPDU.getEnterprise(req_pdu).prettyPrint() - # # Get the host name from the trap - # host = proto.apiTrapPDU.getAgentAddr(req_pdu).prettyPrint() - - # trap = [] - # trap.append(('Generic-Trap', proto.apiTrapPDU.getGenericTrap(req_pdu)._value)) - # trap.append(('Specific-Trap', proto.apiTrapPDU.getSpecificTrap(req_pdu)._value)) - # trap.append(('Uptime', self.fmt_timeticks(proto.apiTrapPDU.getTimeStamp(req_pdu)._value))) - # trap += self.snmptrap_convert_var_binds(proto.apiTrapPDU.getVarBinds(req_pdu)) - trap = self.snmptrap_convert_var_binds(proto.apiPDU.getVarBinds(pdu)) # Use the trap sender IP address as host name host = ipaddress @@ -1256,7 +1247,7 @@ class EventServer: # use the trap-oid as application application = '' for index, (oid, val) in enumerate(trap): - if oid == '1.3.6.1.6.3.1.1.4.1.0': + if oid in ['1.3.6.1.6.3.1.1.4.1.0', 'SNMPv2-MIB::snmpTrapOID.0']: application = trap.pop(index)[1] break