Module: check_mk
Branch: master
Commit: e39b7ab31c0a59dd16fd0554de51e448a90f8a8f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e39b7ab31c0a59…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 28 08:55:15 2017 +0100
Add test for host data source selection
Change-Id: I3e86b8bd355d602f69b0cc30d778aea8062baf0a
---
.bugs/3015 | 18 +++++++
.werks/5546 | 11 ++++
tests/cmk_base/test_data_sources.py | 101 ++++++++++++++++++++++++++++++++++++
3 files changed, 130 insertions(+)
diff --git a/.bugs/3015 b/.bugs/3015
new file mode 100644
index 0000000..26f59f8
--- /dev/null
+++ b/.bugs/3015
@@ -0,0 +1,18 @@
+Title: Site condition for EC rules / rule packs
+Component: ec
+State: open
+Date: 2017-11-28 09:06:39
+Targetversion: future
+Class: feature
+
+we currently have some trouble with the „Expect regular messages” option in Event Console
rules.
+
+We have implemented the active Check_Email check to forward mails to the Event Console.
For most of the mails everything is working fine. We get notifications out of the EC when
a mail is sent there.
+
+For selfmonitoring purpose we have implemented also a regular sent Mail. Now we wanted to
use the “Expect regular messages“ option to get an alarm when the regular Mail was
missing. Sadly the EC rule for that is running on all of our distributed monitoring sites,
but the Mail is just forwarded to one of them. This leads to massive number of false
alarms on all other sites.
+
+
+
+To solve this issue it would be very helpful if the EC rules can be applied to single
sites. Like there is the check box “do not apply this rule” it would be perfect to have
additional checkboxes per monitoring site, where to apply a rule or rule pack.
+
+This would also increase the performance of the EC if you have lots of EC rules which are
configured to run just on the sites where they are needed.
diff --git a/.werks/5546 b/.werks/5546
new file mode 100644
index 0000000..d4cf466
--- /dev/null
+++ b/.werks/5546
@@ -0,0 +1,11 @@
+Title: Count, size and age of files (Linux, Windows): Increased input fields of paths
+Level: 1
+Component: agents
+Class: fix
+Compatible: compat
+Edition: cee
+State: unknown
+Version: 1.5.0i2
+Date: 1511858385
+
+
diff --git a/tests/cmk_base/test_data_sources.py b/tests/cmk_base/test_data_sources.py
index 3e35394..bf2af67 100644
--- a/tests/cmk_base/test_data_sources.py
+++ b/tests/cmk_base/test_data_sources.py
@@ -11,6 +11,10 @@ import cmk_base.config as config
import cmk_base.modes
import cmk_base.automations
+#
+# INTEGRATION TESTS
+#
+
@pytest.fixture(scope="module")
def test_cfg(web, site):
print "Applying default config"
@@ -380,3 +384,100 @@ def test_automation_diag_host_caching(test_cfg, monkeypatch):
# Keepalive check
# Keepalive discovery
# TODO: Check the caching age for cluster hosts
+
+#
+# UNIT TESTS
+#
+
+# Automatically refresh caches for each test
+(a)pytest.fixture(scope="function")
+def clear_config_caches(monkeypatch):
+ import cmk_base
+ import cmk_base.caching
+ monkeypatch.setattr(cmk_base, "config_cache",
cmk_base.caching.CacheManager())
+ monkeypatch.setattr(cmk_base, "runtime_cache",
cmk_base.caching.CacheManager())
+
+
+def test_data_sources_of_hosts(clear_config_caches, monkeypatch):
+ hosts = [
+ # Configs from 1.4
+ ("agent-host-14", {
+ "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod",
+ "sources": ['TCPDataSource',
'PiggyBackDataSource'],
+ }),
+ ("ds-host-14", {
+ "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod",
+ "sources": ['DSProgramDataSource',
'PiggyBackDataSource'],
+ }),
+ ("special-host-14", {
+ "tags": "lan|cmk-agent|ip-v4|tcp|ip-v4-only|prod",
+ "sources": ['SpecialAgentDataSource',
'PiggyBackDataSource'],
+ }),
+ ("ping-host-14", {
+ "tags": "lan|ip-v4|ping|ip-v4-only|prod",
+ "sources": ['PiggyBackDataSource'],
+ }),
+ ("snmp-host-14", {
+ "tags": "lan|ip-v4|snmp|snmp-only|ip-v4-only|prod",
+ "sources": ['SNMPDataSource',
'PiggyBackDataSource'],
+ }),
+ ("snmpv1-host-14", {
+ "tags": "lan|ip-v4|snmp|snmp-v1|ip-v4-only|prod",
+ "sources": ['SNMPDataSource',
'PiggyBackDataSource'],
+ }),
+ ("dual-host-14", {
+ "tags": "lan|ip-v4|snmp|tcp|ip-v4-only|prod|snmp-tcp",
+ "sources": ['TCPDataSource', 'SNMPDataSource',
'PiggyBackDataSource'],
+ }),
+ # From current WATO
+ ("agent-host", {
+ "tags":
"lan|ip-v4|cmk-agent|no-snmp|tcp|ip-v4-only|prod",
+ "sources": ['TCPDataSource',
'PiggyBackDataSource'],
+ }),
+ ("ping-host", {
+ "tags":
"lan|ip-v4|ping|no-snmp|ip-v4-only|no-agent|prod",
+ "sources": ['PiggyBackDataSource'],
+ }),
+ ("snmp-host", {
+ "tags":
"lan|ip-v4|snmp|snmp-v2|ip-v4-only|no-agent|prod",
+ "sources": ['SNMPDataSource',
'PiggyBackDataSource'],
+ }),
+ ("snmpv1-host", {
+ "tags":
"lan|ip-v4|snmp|snmp-v1|ip-v4-only|no-agent|prod",
+ "sources": ['SNMPDataSource',
'PiggyBackDataSource'],
+ }),
+ ("dual-host", {
+ "tags":
"lan|ip-v4|cmk-agent|snmp|snmp-v2|ip-v4-only|tcp|prod",
+ "sources": ['TCPDataSource', 'SNMPDataSource',
'PiggyBackDataSource'],
+ }),
+ ("all-agents-host", {
+ "tags":
"lan|all-agents|ip-v4|no-snmp|tcp|ip-v4-only|prod",
+ "sources": ['DSProgramDataSource',
'SpecialAgentDataSource', 'PiggyBackDataSource'],
+ }),
+ ("all-special-host", {
+ "tags":
"lan|ip-v4|no-snmp|tcp|ip-v4-only|special-agents|prod",
+ "sources": ['SpecialAgentDataSource',
'PiggyBackDataSource'],
+ }),
+ ]
+
+ import cmk_base.data_sources
+ import cmk_base.config as config
+
+ all_hosts = [ ("%s|%s" % (name, h["tags"])) for name, h in hosts
]
+ monkeypatch.setattr(config, "all_hosts", all_hosts)
+
+ monkeypatch.setattr(config, "datasource_programs", [
+ ( 'echo 1', [], ['ds-host-14', 'all-agents-host',
'all-special-host' ], {} ),
+ ])
+
+ monkeypatch.setitem(config.special_agents, "jolokia", [
+ ( {}, [], ['special-host-14', 'all-agents-host',
'all-special-host', ], {} ),
+ ])
+
+ config.collect_hosttags()
+
+ for hostname, host_attrs in hosts:
+ sources = cmk_base.data_sources.DataSources(hostname)
+ source_names = [ s.__class__.__name__ for s in sources.get_data_sources() ]
+ assert host_attrs["sources"] == source_names, \
+ "Wrong sources for %s" % hostname