Module: check_mk
Branch: master
Commit: 82c34f5a93f4b1d7be7dd227413bb571e1bf875b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=82c34f5a93f4b1…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Feb 27 09:12:07 2018 +0100
Unconditionally import SNMP modules.
This saves only <200ms on startup when --snmptrap is not used, which is
basically nothing compared to loading the rest of the modules, the
configuration, and the status file. Furthermore, it complicates two things:
Extracting global statements into a main() function and type checking via
mypy. Both things could be worked around somehow, but this wouldn't exactly
result in the kind of code to be proud of... :-}
Change-Id: I5743ab999f02505c80f01e802dbcbf72bd0f2ede
---
bin/mkeventd | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/bin/mkeventd b/bin/mkeventd
index 3389cb7..c4b0df7 100755
--- a/bin/mkeventd
+++ b/bin/mkeventd
@@ -49,6 +49,19 @@ import traceback
import json
import pathlib2 as pathlib
+# Needed for receiving traps
+from pysnmp.entity import engine as snmp_engine
+from pysnmp.entity import config as snmp_config
+from pysnmp.entity.rfc3413 import ntfrcv as snmp_ntfrcv
+from pysnmp.proto.api import v2c as snmp_v2c, v1 as snmp_v1
+
+# Needed for trap translation
+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
+from pyasn1.error import ValueConstraintError
+
import cmk
import cmk.ec.settings
import cmk.log
@@ -5037,20 +5050,6 @@ if __name__ == "__main__":
cmk.log.open_log(sys.stderr)
cmk.log.set_verbosity(settings.options.verbosity)
- if settings.options.snmptrap_udp is not None:
- # Needed for receiving traps
- from pysnmp.entity import engine as snmp_engine
- from pysnmp.entity import config as snmp_config
- from pysnmp.entity.rfc3413 import ntfrcv as snmp_ntfrcv
- from pysnmp.proto.api import v2c as snmp_v2c, v1 as snmp_v1
-
- # Needed for trap translation
- 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
- from pyasn1.error import ValueConstraintError
-
settings.paths.log_file.value.parent.mkdir(parents=True, exist_ok=True)
if not settings.options.foreground:
cmk.log.open_log(str(settings.paths.log_file.value))