Module: check_mk
Branch: master
Commit: 931ea6c6b827bc7a8632869291a2bd07ebc29c20
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=931ea6c6b827bc…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Feb 26 12:12:48 2012 +0100
WATO: create basic sample configuration
---
ChangeLog | 2 +
web/htdocs/valuespec.py | 2 +-
web/htdocs/wato.py | 68 ++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 68 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 32cc746..66a912a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@
of host and service (= downtime alerts)
WATO:
+ * Create very basic sample configuration when using
+ WATO the first time (three tag groups, two rules)
* Much more checks are configurable via WATO now
* Distributed WATO: Made all URL calls using curl now
* FIX: fix bug in inventory in validate_datatype()
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 15ffa89..3291e5b 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -839,7 +839,7 @@ class ListChoice(ValueSpec):
# In case of overloaded functions with dynamic elements
def load_elements(self):
- if self._choices:
+ if self._choices != None:
self._elements = self._choices
return
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index b78e235..db4f0f2 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -894,9 +894,10 @@ def mode_folder(phase):
"paths of that tree. The usage of folders is
optional."))])
def prepare_folder_info():
+ load_all_folders() # load information about all folders
+ create_sample_config() # if called for the very first time!
declare_host_tag_attributes() # create attributes out of tag definitions
declare_site_attribute() # create attribute for distributed WATO
- load_all_folders() # load information about all folders
set_current_folder() # set g_folder from HTML variable
@@ -9334,8 +9335,6 @@ def get_tag_conditions():
elif mode == "isnot":
tag_list.append("!" + id)
- html.debug_vars()
- html.debug(tag_list)
return tag_list
@@ -9612,6 +9611,69 @@ def page_user_profile():
html.footer()
#.
+#.
+# .--Sampleconfig--------------------------------------------------------.
+# | ____ _ __ _ |
+# | / ___| __ _ _ __ ___ _ __ | | ___ ___ ___ _ __ / _(_) __ _ |
+# | \___ \ / _` | '_ ` _ \| '_ \| |/ _ \/ __/ _ \| '_ \| |_| |/ _` | |
+# | ___) | (_| | | | | | | |_) | | __/ (_| (_) | | | | _| | (_| | |
+# | |____/ \__,_|_| |_| |_| .__/|_|\___|\___\___/|_| |_|_| |_|\__, | |
+# | |_| |___/ |
+# +----------------------------------------------------------------------+
+# | Functions for creating an example configuration |
+# '----------------------------------------------------------------------'
+
+# Create a very basic sample configuration, but only if no host tags
+# or rules have been defined *ever*.
+def create_sample_config():
+ if os.path.exists(multisite_dir + "hosttags.mk") \
+ or os.path.exists(multisite_dir + "rules.mk"):
+ return
+
+ # Example values for host tags
+ wato_host_tags = \
+ [('agent',
+ u'Agent type',
+ [('cmk-agent', u'Check_MK Agent (Server)', ['tcp']),
+ ('snmp-only', u'SNMP (Networking device, Appliance)',
['snmp']),
+ ('snmp-v1', u'Legacy SNMP device (using V1)', ['snmp']),
+ ('snmp-tcp', u'Dual: Check_MK Agent + SNMP', ['snmp',
'tcp']),
+ ('ping', u'Only PING this device', [])]),
+ ('criticality',
+ u'Criticality',
+ [('prod', u'Productive system', []),
+ ('critical', u'Business critical', []),
+ ('test', u'Test system', []),
+ ('offline', u'Do not monitor this host', [])]),
+ ('networking',
+ u'Networking Segment',
+ [('lan', u'Local network (low latency)', []),
+ ('wan', u'WAN (high latency)', []),
+ ('dmz', u'DMZ (low latency, secure access)', [])])]
+
+ wato_aux_tags = \
+ [('snmp', u'monitor via SNMP'),
+ ('tcp', u'monitor via Check_MK Agent')]
+
+ save_hosttags(wato_host_tags, wato_aux_tags)
+
+ # Example values for rules
+ rulesets = {
+ 'only_hosts': [
+ (['!offline'], ['@all'])],
+ 'ping_levels': [
+ ({'loss': (80.0, 100.0),
+ 'packets': 6,
+ 'rta': (1500.0, 3000.0),
+ 'timeout': 20}, ['wan'], ['@all'])],
+ 'bulkwalk_hosts': [
+ (['!snmp-v1'], ['@all'])],
+ }
+
+ save_rulesets(g_root_folder, rulesets)
+
+
+
# .-Hooks-&-API----------------------------------------------------------.
# | _ _ _ ___ _ ____ ___ |
# | | | | | ___ ___ | | _____ ( _ ) / \ | _ \_ _| |