Module: check_mk
Branch: master
Commit: 4530277e128cd6de75a7619fb1bdaf6f9b94dcce
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4530277e128cd6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Feb 25 12:18:26 2012 +0100
Only create contacts in Nagios that are group members
---
ChangeLog | 2 ++
modules/check_mk.py | 4 +++-
web/htdocs/wato.py | 12 ++++++++----
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dd84683..a4790ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,8 @@
* FIX: honor permissions for "bulk cleanup" and "bulk edit"
* FIX: honor write permissions and source folder when moving hosts
* FIX: honor permissions on hosts also on bulk inventory
+ * Only create contacts in Nagios if they are member of at
+ least one contact group.
Checks & Agents:
* hpux_if: fix missing default parameter errors
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 0d3b12c..b022c49 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1891,7 +1891,9 @@ 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
+ # 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:
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 1795a19..468e62b 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7106,10 +7106,14 @@ def save_users(profiles):
non_contact_keys = [ "roles", "password", "locked",
"automation_secret", "language" ]
multisite_keys = [ "roles", "language" ]
- # Remove multisite keys in contacts
- contacts = dict([ (id, split_dict(user, non_contact_keys, False))
- for (id, user)
- in profiles.items() ])
+ # Remove multisite keys in contacts. And use only such entries
+ # that have any contact groups assigned to.
+ contacts = dict(
+ e for e in
+ [ (id, split_dict(user, non_contact_keys, False))
+ for (id, user)
+ in profiles.items() ]
+ if e[1].get("contactgroups"))
# Only allow explicit defined attributes to be written to multisite config
users = {}