Module: check_mk
Branch: master
Commit: 36e300da0aef81eb4f7f5abc4bd6b744923321d9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=36e300da0aef81…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Nov 26 18:12:56 2013 +0100
livedump: new option to include contact_groups instead of contacts when dumping
configuration
---
.werks/71 | 8 ++++++
ChangeLog | 1 +
doc/treasures/livedump/livedump | 56 ++++++++++++++++++++++++++-------------
3 files changed, 47 insertions(+), 18 deletions(-)
diff --git a/.werks/71 b/.werks/71
new file mode 100644
index 0000000..19c3d59
--- /dev/null
+++ b/.werks/71
@@ -0,0 +1,8 @@
+Title: livedump: new option to include contact_groups instead of contacts when dumping
configuration
+Level: 1
+Component: multisite
+Version: 1.2.3i7
+Date: 1385485919
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 1542298..f223fc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,7 @@
* 0050 New concept of favorite hosts and services plus matching filters and views...
* 0211 GUI Notify: Added notify method "popup" to really create popup
windows...
* 0215 Added option to make HTML escape in plugin outputs configurable...
+ * 0071 livedump: new option to include contact_groups instead of contacts when
dumping configuration
* 0043 FIX: LDAP: Improved error reporting during synchronisation...
* 0044 FIX: LDAP: Fixed error with empty groups during non nested group sync...
* 0045 FIX: LDAP: Fixed error when synchronizing non nested groups to roles...
diff --git a/doc/treasures/livedump/livedump b/doc/treasures/livedump/livedump
index ad391cc..337b7c4 100755
--- a/doc/treasures/livedump/livedump
+++ b/doc/treasures/livedump/livedump
@@ -96,30 +96,44 @@ def livedump_config():
encode_row(row)
check_commands.add(row["check_command"])
row["contactsstring"] =
(",".join(row["contacts"])).encode("utf-8")
-
+ row["contact_groups"] =
(",".join(row["contact_groups"])).encode("utf-8")
# Dump host config
query = \
"GET hosts\n" \
"Columns: name alias address groups check_command " \
- "max_check_attempts contacts\n" + \
+ "max_check_attempts contacts contact_groups\n" + \
opt_host_headers + \
opt_host_only_headers
for row in g_connection.query_table_assoc(query):
prepare_row(row)
row["groupstring"] = ",".join(row["groups"])
- sys.stdout.write(
- "define host {\n"
- " use livedump-host\n"
- " host_name %(name)s\n"
- " alias %(alias)s\n"
- " address %(address)s\n"
- " host_groups %(groupstring)s\n"
- " contacts %(contactsstring)s\n"
- " check_command %(check_command)s\n"
- " max_check_attempts %(max_check_attempts)d\n"
- "}\n\n"
- % row)
+ if opt_groups:
+ sys.stdout.write(
+ "define host {\n"
+ " use livedump-host\n"
+ " host_name %(name)s\n"
+ " alias %(alias)s\n"
+ " address %(address)s\n"
+ " host_groups %(groupstring)s\n"
+ " contact_groups %(contact_groups)s\n"
+ " check_command %(check_command)s\n"
+ " max_check_attempts %(max_check_attempts)d\n"
+ "}\n\n"
+ % row)
+ else:
+ sys.stdout.write(
+ "define host {\n"
+ " use livedump-host\n"
+ " host_name %(name)s\n"
+ " alias %(alias)s\n"
+ " address %(address)s\n"
+ " host_groups %(groupstring)s\n"
+ " contacts %(contactsstring)s\n"
+ " check_command %(check_command)s\n"
+ " max_check_attempts %(max_check_attempts)d\n"
+ "}\n\n"
+ % row)
# Dump service config
query = \
@@ -212,6 +226,9 @@ output=%(plugin_output)s|%(perf_data)s
def omd_root():
return os.getenv("OMD_ROOT")
+def omd_site():
+ return os.getenv("OMD_SITE")
+
def verbose(x):
if opt_verbose:
sys.stderr.write("%s\n" % x)
@@ -259,10 +276,11 @@ def print_version():
# | Main entry point, getopt, etc. |
# '----------------------------------------------------------------------'
-short_options = 'hVvc:H:S:O:TCM'
+short_options = 'hVvc:H:S:O:TCMG'
long_options = [ "help", "version", "verbose",
"debug", "socket=",
"host-header=", "host-only-header=",
"service-header=",
- "dump-templates", "config", "state",
"mark-mode" ]
+ "dump-templates", "config", "state",
"mark-mode",
+ "include-groups" ]
opt_verbose = False
opt_debug = False
@@ -272,6 +290,7 @@ opt_host_headers = ""
opt_host_only_headers = ""
opt_service_headers = ""
opt_dump_templates = False
+opt_groups = False
try:
opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
@@ -306,7 +325,8 @@ for o,a in opts:
opt_dump_templates = True
elif o in [ '-M', '--mark-mode' ]:
opt_mark_mode = True
-
+ elif o in [ '-G', '--include-groups' ]:
+ opt_groups = True
# Main modes
try:
@@ -314,7 +334,7 @@ try:
for o, a in opts:
if o in [ '-C', '--config' ]:
if opt_mark_mode:
- print "config"
+ print "config", omd_site()
livedump_config()
sys.exit(0)
if opt_mark_mode: