Module: check_mk
Branch: master
Commit: 073fd27f39632bd236f5919ab40bedf1b7c01a6f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=073fd27f39632b…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 8 14:38:10 2015 +0200
#2673 FIX SNMP-Traps: Fixed translation of OIDs which are parts of trap values
Some traps send SNMP OIDs as values of traps which were not translated correctly
in the past. For example default SNMPv2 traps had a non-translated numeric OID
in the "Application" field of the events. This has now been changed to be
translated too.
Please note: If you already have created rules which refer to the numeric OIDs
while having trap translation enabled, you will need to update the rules.
---
.werks/2673 | 15 +++++++++++++++
ChangeLog | 2 ++
mkeventd/bin/mkeventd | 41 +++++++++++++++--------------------------
3 files changed, 32 insertions(+), 26 deletions(-)
diff --git a/.werks/2673 b/.werks/2673
new file mode 100644
index 0000000..8176e33
--- /dev/null
+++ b/.werks/2673
@@ -0,0 +1,15 @@
+Title: SNMP-Traps: Fixed translation of OIDs which are parts of trap values
+Level: 1
+Component: ec
+Compatible: incomp
+Version: 1.2.7i3
+Date: 1444307734
+Class: fix
+
+Some traps send SNMP OIDs as values of traps which were not translated correctly
+in the past. For example default SNMPv2 traps had a non-translated numeric OID
+in the "Application" field of the events. This has now been changed to be
+translated too.
+
+Please note: If you already have created rules which refer to the numeric OIDs
+while having trap translation enabled, you will need to update the rules.
diff --git a/ChangeLog b/ChangeLog
index 2cd26f9..bc8ee0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -336,6 +336,8 @@
* 2534 FIX: Fixed implementation of skipping rule packs
* 2614 FIX: Fixed exception when processing events with umlaut in names from history
* 2644 FIX: Fix exception in executing actions or notifications when match groups
contain non-ASCII characters
+ * 2673 FIX: SNMP-Traps: Fixed translation of OIDs which are parts of trap values...
+ NOTE: Please refer to the migration notes!
Livestatus:
* 2493 FIX: Fixed wrong JSON format when using stats queries together with header
columns...
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 611862b..3612007 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -1212,32 +1212,14 @@ class EventServer:
def snmptrap_translate_varbinds(self, var_bind_list):
var_binds = []
for oid, value in var_bind_list:
- mib_var = MibVariable(oid).resolveWithMib(self._mib_resolver)
-
- if not mib_var.isFullyResolved():
- log('MIB for %s is not loaded' % oid.prettyPrint())
- var_binds.append((str(oid), value)) # add untranslated
- else:
- # 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?
- if not indices:
- translated_oid = '%s::%s' % (mod, sym)
- else:
- 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()
+ try:
+ mib_var = ObjectType(ObjectIdentity(oid),
value).resolveWithMib(self._mib_resolver)
+ node = mib_var[0].getMibNode()
+ translated_oid = mib_var[0].prettyPrint().replace("\"",
"")
+ translated_value = mib_var[1].prettyPrint()
- translated_value = value.prettyPrint() + ' ' + units
- else:
- translated_value = value
+ if hasattr(node, "getUnits"):
+ translated_value += ' ' + node.getUnits()
if hasattr(node, "getDescription") \
and type(g_config["translate_snmptraps"]) == tuple \
@@ -1245,6 +1227,12 @@ class EventServer:
translated_value += "(%s)" % node.getDescription()
var_binds.append((translated_oid, translated_value))
+
+ except SmiError, e:
+ # Failed to translate? add untranslated
+ log('Failed to translate OID %s: %s' % (oid.prettyPrint(), e))
+ var_binds.append((str(oid), str(value))) # add untranslated
+
return var_binds
def process_snmptrap(self, (whole_msg, (ipaddress, port))):
@@ -3851,9 +3839,10 @@ try:
from pyasn1.codec.ber import decoder as pyasn_decoder
import pysnmp.proto.proxy.rfc2576
# Needed for trap translation
- from pysnmp.entity.rfc3413.oneliner.mibvar import MibVariable
from pysnmp.smi.builder import MibBuilder, DirMibSource
from pysnmp.smi.view import MibViewController
+ from pysnmp.smi.rfc1902 import ObjectType, ObjectIdentity
+ from pysnmp.smi.error import SmiError
if not g_pipe_path:
bail_out("Please specify the path to the pipe (using -P).")