Module: check_mk
Branch: master
Commit: 4d04510157dfde25bb5ba1c32a4978f1dcd74120
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4d04510157dfde…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Apr 17 16:50:54 2012 +0200
Do not put users in dummy contact group check_mk
---
.bugs/675 | 6 ++++--
ChangeLog | 2 ++
modules/check_mk.py | 16 +++++++++-------
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/.bugs/675 b/.bugs/675
index ab69d9d..99bb7bb 100644
--- a/.bugs/675
+++ b/.bugs/675
@@ -1,9 +1,9 @@
Title: User is added to default contact group check_mk, but should not
Component: core
-State: open
+Class: bug
+State: done
Date: 2012-04-10 16:30:42
Targetversion: 1.2.0
-Class: bug
We did:
- Create a contact group "alle"
@@ -16,3 +16,5 @@ Happened:
- BUT: hh and omdadmin are members of check_mk automatically
(and should not)
- and thus hh receives notifications, but should not
+
+2012-04-17 16:50:38: changed state open -> done
diff --git a/ChangeLog b/ChangeLog
index d5444b3..2d46bf6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,8 @@
* FIX: Automation try-inventory: Fixed problem on where checks which
produce equal service descriptions could lead to invalid inventory
results on cluster hosts.
+ * FIX: do not create contacts if they won't be assigned to any host
+ or service. Do *not* assign to dummy catch-all group "check_mk".
WATO:
* Added new permission "move hosts" to allow/deny moving of hosts in WATO
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 535674d..3f03bd2 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1877,6 +1877,15 @@ def create_nagios_config_contacts(outfile):
cnames.sort()
for cname in cnames:
contact = contacts[cname]
+ # If the contact is in no contact group or all of the contact groups
+ # of the contact have neither hosts nor services assigned - in other
+ # words if the contact is not assigned to any host or service, then
+ # we do not create this contact in Nagios. It's useless and wil produce
+ # warnings.
+ cgrs = [ cgr for cgr in contact.get("contactgroups", []) if cgr in
contactgroups_to_define ]
+ if not cgrs:
+ continue
+
outfile.write("define contact {\n contact_name\t\t\t%s\n" %
cname)
if "alias" in contact:
outfile.write(" alias\t\t\t\t%s\n" %
contact["alias"].encode("utf-8"))
@@ -1891,13 +1900,6 @@ def create_nagios_config_contacts(outfile):
outfile.write(" %s_notification_period\t%s\n" % (what,
contact.get("notification_period", "24X7")))
outfile.write(" %s_notification_commands\tcheck-mk-notify\n" %
what)
- # Refer only to those contact groups that actually have objects assigned to.
Otherwise
- # we will run into problems since Nagios does not allow contact groups that
- # are not assigned to at least one host or service?
- cgrs = [ cgr for cgr in contact.get("contactgroups", []) if cgr in
contactgroups_to_define ]
- # Use dummy group if none is set. Nagios will not start otherwise
- if not cgrs:
- cgrs = [ "check_mk" ]
outfile.write(" contactgroups\t\t\t%s\n" % ",
".join(cgrs))
outfile.write("}\n\n")