Module: check_mk
Branch: master
Commit: e323b12d5b836a1c383a209884365783f1da592e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e323b12d5b836a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Feb 21 07:21:10 2019 +0100
Moved oid_range_limits attribute to SNMPHostConfig
Change-Id: I3a8370cefbd573d6acc3718ef7837580ff89a253
---
cmk_base/automations/check_mk.py | 1 +
cmk_base/data_sources/snmp.py | 1 +
cmk_base/snmp.py | 1 +
cmk_base/snmp_utils.py | 1 +
tests/integration/cmk_base/snmp/test_snmp.py | 4 ++++
tests/unit/cmk_base/snmp/test_classic_snmp.py | 7 +++++++
6 files changed, 15 insertions(+)
diff --git a/cmk_base/automations/check_mk.py b/cmk_base/automations/check_mk.py
index 39924db..dada8f0 100644
--- a/cmk_base/automations/check_mk.py
+++ b/cmk_base/automations/check_mk.py
@@ -1238,6 +1238,7 @@ class AutomationDiagHost(Automation):
'timeout': snmp_timeout,
'retries': snmp_retries,
},
+ oid_range_limits=config.oid_range_limits_of(hostname),
)
data = snmp.get_snmp_table(
host_config,
diff --git a/cmk_base/data_sources/snmp.py b/cmk_base/data_sources/snmp.py
index 42a7f5b..4cf84a0 100644
--- a/cmk_base/data_sources/snmp.py
+++ b/cmk_base/data_sources/snmp.py
@@ -86,6 +86,7 @@ class SNMPDataSource(DataSource):
is_snmpv2c_host=self._is_snmpv2c_host,
bulk_walk_size_of=config.bulk_walk_size_of(self._hostname),
timing=config.snmp_timing_of(self._hostname),
+ oid_range_limits=config.oid_range_limits_of(self._hostname),
)
def describe(self):
diff --git a/cmk_base/snmp.py b/cmk_base/snmp.py
index 5b63415..f482791 100644
--- a/cmk_base/snmp.py
+++ b/cmk_base/snmp.py
@@ -153,6 +153,7 @@ def create_snmp_host_config(hostname):
is_snmpv2c_host=config.is_snmpv2c_host(hostname),
bulk_walk_size_of=config.bulk_walk_size_of(hostname),
timing=config.snmp_timing_of(hostname),
+ oid_range_limits=config.oid_range_limits_of(hostname),
)
diff --git a/cmk_base/snmp_utils.py b/cmk_base/snmp_utils.py
index bc83791..84bb921 100644
--- a/cmk_base/snmp_utils.py
+++ b/cmk_base/snmp_utils.py
@@ -88,4 +88,5 @@ SNMPHostConfig = NamedTuple(
("bulk_walk_size_of", int),
# TODO: Cleanup to named tuple
("timing", dict),
+ ("oid_range_limits", list),
])
diff --git a/tests/integration/cmk_base/snmp/test_snmp.py
b/tests/integration/cmk_base/snmp/test_snmp.py
index 6c568c7..e57e549 100644
--- a/tests/integration/cmk_base/snmp/test_snmp.py
+++ b/tests/integration/cmk_base/snmp/test_snmp.py
@@ -77,6 +77,7 @@ def snmpsim(site, request, tmp_path_factory):
is_snmpv2c_host=True,
bulk_walk_size_of=10,
timing={},
+ oid_range_limits=[],
)
# Ensure that snmpsim is ready for clients before starting with the tests
@@ -149,6 +150,7 @@ def test_get_single_oid_ipv6(snmpsim, backend):
is_snmpv2c_host=True,
bulk_walk_size_of=10,
timing={},
+ oid_range_limits=[],
)
result = snmp.get_single_oid(host_config, ".1.3.6.1.2.1.1.1.0")
assert result == "Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016
i686"
@@ -168,6 +170,7 @@ def test_get_single_oid_snmpv3(snmpsim, backend):
is_snmpv2c_host=True,
bulk_walk_size_of=10,
timing={},
+ oid_range_limits=[],
)
result = snmp.get_single_oid(host_config, ".1.3.6.1.2.1.1.1.0")
assert result == "Linux zeus 4.8.6.5-smp #2 SMP Sun Nov 13 14:58:11 CDT 2016
i686"
@@ -272,6 +275,7 @@ def test_get_single_oid_not_resolvable(snmpsim, backend):
is_snmpv2c_host=True,
bulk_walk_size_of=10,
timing={},
+ oid_range_limits=[],
)
assert snmp.get_single_oid(host_config, ".1.3.6.1.2.1.1.7.0") is None
diff --git a/tests/unit/cmk_base/snmp/test_classic_snmp.py
b/tests/unit/cmk_base/snmp/test_classic_snmp.py
index 613416b..1df1b91 100644
--- a/tests/unit/cmk_base/snmp/test_classic_snmp.py
+++ b/tests/unit/cmk_base/snmp/test_classic_snmp.py
@@ -19,6 +19,7 @@ def test_snmp_port_spec(port, expected):
is_snmpv2c_host=False,
bulk_walk_size_of=10,
timing={},
+ oid_range_limits=[],
)
assert classic_snmp._snmp_port_spec(host_config) == expected
@@ -38,6 +39,7 @@ def test_snmp_proto_spec(monkeypatch, is_ipv6, expected):
is_snmpv2c_host=False,
bulk_walk_size_of=10,
timing={},
+ oid_range_limits=[],
)
assert classic_snmp._snmp_proto_spec(host_config) == expected
@@ -63,6 +65,7 @@ SNMPSettings = collections.namedtuple("SNMPSettings", [
"timeout": 2,
"retries": 3
},
+ oid_range_limits=[],
),
context_name=None,
), [
@@ -83,6 +86,7 @@ SNMPSettings = collections.namedtuple("SNMPSettings", [
"timeout": 5,
"retries": 1
},
+ oid_range_limits=[],
),
context_name="blabla",
), [
@@ -103,6 +107,7 @@ SNMPSettings = collections.namedtuple("SNMPSettings", [
"timeout": 5,
"retries": 1
},
+ oid_range_limits=[],
),
context_name="blabla",
), [
@@ -123,6 +128,7 @@ SNMPSettings = collections.namedtuple("SNMPSettings", [
"timeout": 5,
"retries": 1
},
+ oid_range_limits=[],
),
context_name=None,
), [
@@ -143,6 +149,7 @@ SNMPSettings = collections.namedtuple("SNMPSettings", [
"timeout": 5,
"retries": 1
},
+ oid_range_limits=[],
),
context_name=None,
), [