Module: check_mk
Branch: master
Commit: 10a01921e4010e1eedbdde2aa10bd24d21095249
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=10a01921e4010e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 15 10:35:58 2011 +0100
New config variable distributed_wato_site
This variable is intended for internal use by
WATO
---
modules/check_mk.py | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 4d8c9d5..cd8b14e 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -296,6 +296,7 @@ summary_host_notification_periods = []
summary_service_notification_periods = []
ipaddresses = {} # mapping from hostname to ipaddress
only_hosts = None
+distributed_wato_site = None # used by distributed WATO
extra_host_conf = {}
extra_summary_host_conf = {}
extra_service_conf = {}
@@ -1075,18 +1076,29 @@ def output_conf_header(outfile):
""")
def all_active_hosts():
- if only_hosts == None:
- return strip_tags(all_hosts)
- else:
- return [ hostname for hostname in strip_tags(all_hosts) \
- if in_binary_hostlist(hostname, only_hosts) ]
+ return filter_active_hosts(all_hosts)
def all_active_clusters():
- if only_hosts == None:
- return strip_tags(clusters.keys())
- else:
- return [ hostname for hostname in strip_tags(clusters.keys()) \
+ return filter_active_hosts(clusters.keys())
+
+def filter_active_hosts(hostlist):
+ if only_hosts == None and distributed_wato_site == None:
+ return strip_tags(hostlist)
+ elif only_hosts == None:
+ site_tag = "site:" + distributed_wato_site
+ return [ hostname for hostname in strip_tags(hostlist)
+ if site_tag in tags_of_host(hostname) ]
+ elif distributed_wato_site == None:
+ return [ hostname for hostname in strip_tags(hostlist)
if in_binary_hostlist(hostname, only_hosts) ]
+ else:
+ site_tag = "site:" + distributed_wato_site
+ return [ hostname for hostname in strip_tags(hostlist)
+ if in_binary_hostlist(hostname, only_hosts)
+ and site_tag in tags_of_host(hostname) ]
+
+
+
def hostgroups_of(hostname):
return host_extra_conf(hostname, host_groups)