Module: check_mk
Branch: master
Commit: 52aaaffa9273df218d6492518254b0deda055cd0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=52aaaffa9273df…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Jul 6 11:45:56 2015 +0200
mod_contacts_mk.py: Treasures script to modify the contacts.mk file used by wato
---
doc/treasures/mod_contacts_mk.py | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/doc/treasures/mod_contacts_mk.py b/doc/treasures/mod_contacts_mk.py
new file mode 100755
index 0000000..c0b1b15
--- /dev/null
+++ b/doc/treasures/mod_contacts_mk.py
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+# This script can be used to modify the contacts.mk file
+# The core mus be reloaded after changes
+import sys, os
+
+if len(sys.argv) != 4:
+ print "Usage: ./mod_contacts_mk.py USERID FIELD NEW CONTENT"
+ sys.exit()
+try:
+ path = os.environ.pop('OMD_ROOT')
+ pathlokal = "~/etc/check_mk/conf.d/wato/"
+ pathlokal = os.path.expanduser(pathlokal)
+ contacts_mk = pathlokal + "contacts.mk"
+except:
+ print "Run this script inside a OMD site"
+ sys.exit()
+
+
+user_id = sys.argv[1]
+field = sys.argv[2]
+content = sys.argv[3]
+
+contacts = {}
+
+eval(file(contacts_mk).read())
+
+contacts[user_id][field] = content
+
+file(contacts_mk, "w").write( """
+# Written by Multisite UserDB
+# encoding: utf-8
+
+contacts.update(
+%s)""" % str(contacts))