Module: check_mk
Branch: master
Commit: 96c0ecb0e2e92e368b0b00f04b25ceb8b5c5b1ad
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=96c0ecb0e2e92e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 20 11:46:52 2012 +0200
Added new hook "sites-saved"
---
ChangeLog | 1 +
web/htdocs/wato.py | 8 ++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3fd76f1..738e1ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@
(that garbled the logical layout)
* Rules now have an optional comment and can be disabled without
deleting them.
+ * Added new hook "sites-saved"
BI:
* Great speed up of rule compilation in large environments
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3fe4de2..a911887 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -6705,6 +6705,9 @@ def save_sites(sites):
rewrite_config_files_below(g_root_folder) # fix site attributes
need_sidebar_reload()
+ # Call the sites saved hook
+ call_hook_sites_saved(sites)
+
# Makes sure, that in distributed mode we monitor only
# the hosts that are directly assigned to our (the local)
# site.
@@ -11180,6 +11183,11 @@ def call_hook_roles_saved(roles):
if hook_registered('roles-saved'):
call_hooks("roles-saved", roles)
+# This hook is executed when the save_sites() function is called
+def call_hook_sites_saved(sites):
+ if hook_registered('sites-saved'):
+ call_hooks("sites-saved", sites)
+
# This hook is called in order to determine if a host has a 'valid'
# configuration. It used for displaying warning symbols in the
# host list and in the host detail view.
Module: check_mk
Branch: master
Commit: 7e0366c2a1a181aacbc99e38344eaff93c043fb4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7e0366c2a1a181…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 20 13:14:39 2012 +0200
Implemented new option in WATO attributes: editable
When set to False the attribute can only be changed during creation
of a new object. When editing an object this attribute is only displayed.
---
ChangeLog | 3 +
web/htdocs/wato.py | 120 +++++++++++++++++++++++++++++++--------------------
2 files changed, 76 insertions(+), 47 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 738e1ca..82fbff7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,9 @@
* Rules now have an optional comment and can be disabled without
deleting them.
* Added new hook "sites-saved"
+ * Implemented new option in WATO attributes: editable
+ When set to False the attribute can only be changed during creation
+ of a new object. When editing an object this attribute is only displayed.
BI:
* Great speed up of rule compilation in large environments
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index a911887..f95fc59 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1728,7 +1728,7 @@ def mode_editfolder(phase, new):
parent = g_folder.get(".parent")
myself = g_folder
- configure_attributes({"folder": attributes}, "folder", parent, myself)
+ configure_attributes(new, {"folder": attributes}, "folder", parent, myself)
forms.end()
html.button("save", _("Save & Finish"), "submit")
@@ -1956,7 +1956,7 @@ def mode_edithost(phase, new, cluster):
html.help(_('Enter the host names of the cluster nodes. These '
'hosts must be present in WATO. '))
- configure_attributes({hostname: host}, "host", parent = g_folder)
+ configure_attributes(new, {hostname: host}, "host", parent = g_folder)
forms.end()
html.image_button("services", _("Save & go to Services"), "submit")
@@ -2212,7 +2212,7 @@ def mode_search(phase):
html.set_focus("host")
# Attributes
- configure_attributes({}, "search", parent = None)
+ configure_attributes(False, {}, "search", parent = None)
# Button
forms.end()
@@ -2613,7 +2613,7 @@ def mode_bulk_edit(phase):
"will keep their individual settings.") + "</p>")
html.begin_form("edithost", None, "POST")
- configure_attributes(hosts, "bulk", parent = g_folder)
+ configure_attributes(False, hosts, "bulk", parent = g_folder)
forms.end()
html.button("_save", _("Save & Finish"))
html.hidden_fields()
@@ -4100,6 +4100,11 @@ class Attribute:
def show_in_folder(self):
return self._show_in_folder
+ # Wether or not this attribute can be edited after creation
+ # of the object
+ def editable(self):
+ return self._editable
+
# Wether it is allowed that a host has no explicit
# value here (inherited or direct value). An mandatory
# has *no* default value.
@@ -4138,7 +4143,7 @@ class Attribute:
# Check whether this attribute needs to be validated at all
# Attributes might be permanently hidden (show_in_form = False)
- # or dynamically hidden by the depends_on_tags feature
+ # or dynamically hidden by the depends_on_tags, editable features
def needs_validation(self):
if not self._show_in_form:
return False
@@ -4551,14 +4556,15 @@ host_attribute = {}
# Declare attributes with this method
def declare_host_attribute(a, show_in_table = True, show_in_folder = True,
- topic = None, show_in_form = True, depends_on_tags = [],depends_on_roles = []):
+ topic = None, show_in_form = True, depends_on_tags = [], depends_on_roles = [], editable = True):
host_attributes.append((a, topic))
host_attribute[a.name()] = a
- a._show_in_table = show_in_table
- a._show_in_folder = show_in_folder
- a._show_in_form = show_in_form
- a._depends_on_tags = depends_on_tags
+ a._show_in_table = show_in_table
+ a._show_in_folder = show_in_folder
+ a._show_in_form = show_in_form
+ a._depends_on_tags = depends_on_tags
a._depends_on_roles = depends_on_roles
+ a._editable = editable
def undeclare_host_attribute(attrname):
@@ -4589,15 +4595,18 @@ def have_folder_attributes():
return True
return False
-# Show HTML form for editing attributes. for_what can be:
-# "host" -> normal host edit dialog
-# "folder" -> properies of folder or file
-# "search" -> search dialog
-# "bulk" -> bulk change
+# Show HTML form for editing attributes.
+#
+# new: Boolean flag if this is a creation step or editing
+# for_what can be:
+# "host" -> normal host edit dialog
+# "folder" -> properies of folder or file
+# "search" -> search dialog
+# "bulk" -> bulk change
# parent: The parent folder of the objects to configure
# myself: For mode "folder" the folder itself or None, if we edit a new folder
# This is needed for handling mandatory attributes.
-def configure_attributes(hosts, for_what, parent, myself=None, without_attributes = []):
+def configure_attributes(new, hosts, for_what, parent, myself=None, without_attributes = []):
# show attributes grouped by topics, in order of their
# appearance. If only one topic exists, do not show topics
# Make sure, that the topics "Basic settings" and host tags
@@ -4741,6 +4750,8 @@ def configure_attributes(hosts, for_what, parent, myself=None, without_attribute
and not has_inherited:
force_entry = True
active = True
+ elif not new and not attr.editable():
+ force_entry = True
elif for_what == "host" and attr.is_mandatory() and not has_inherited:
force_entry = True
active = True
@@ -4765,48 +4776,63 @@ def configure_attributes(hosts, for_what, parent, myself=None, without_attribute
forms.section(attr.title(), checkbox=checkbox_code, id="attr_" + attrname)
html.help(attr.help())
- # Now comes the input fields and the inherited / default values
- # as two DIV elements, one of which is visible at one time.
- # html.write('<td class=content>')
-
- # DIV with the input elements
- html.write('<div id="attr_entry_%s" style="%s">'
- % (attrname, (not active) and "display: none" or ""))
if len(values) == 1:
defvalue = values[0]
else:
defvalue = attr.default_value()
- attr.render_input(defvalue)
- html.write("</div>")
+ if not new and not attr.editable():
+ # In edit mode only display non editable values, don't show the
+ # input fields
+ html.write('<div id="attr_hidden_%s" style="display:none">')
+ attr.render_input(defvalue)
+ html.write('</div>')
+
+ tdclass, content = attr.paint(defvalue, "")
+ if not content:
+ content = _("empty")
+ html.write(content)
+
+ else:
+ # Regular rendering
- # DIV with actual / inherited / default value
- html.write('<div class="inherited" id="attr_default_%s" style="%s">'
- % (attrname, active and "display: none" or ""))
+ # Now comes the input fields and the inherited / default values
+ # as two DIV elements, one of which is visible at one time.
- # in bulk mode we show inheritance only if *all* hosts inherit
- explanation = ""
- if for_what == "bulk":
- if num_haveit == 0:
+ # DIV with the input elements
+ html.write('<div id="attr_entry_%s" style="%s">'
+ % (attrname, (not active) and "display: none" or ""))
+
+ attr.render_input(defvalue)
+ html.write("</div>")
+
+ # DIV with actual / inherited / default value
+ html.write('<div class="inherited" id="attr_default_%s" style="%s">'
+ % (attrname, active and "display: none" or ""))
+
+ # in bulk mode we show inheritance only if *all* hosts inherit
+ explanation = ""
+ if for_what == "bulk":
+ if num_haveit == 0:
+ explanation = " (" + inherited_from + ")"
+ value = inherited_value
+ elif not unique:
+ explanation = _("This value differs between the selected hosts.")
+ else:
+ value = values[0]
+
+ elif for_what in [ "host", "folder" ]:
explanation = " (" + inherited_from + ")"
value = inherited_value
- elif not unique:
- explanation = _("This value differs between the selected hosts.")
- else:
- value = values[0]
- elif for_what in [ "host", "folder" ]:
- explanation = " (" + inherited_from + ")"
- value = inherited_value
+ if for_what != "search" and not (for_what == "bulk" and not unique):
+ tdclass, content = attr.paint(value, "")
+ if not content:
+ content = _("empty")
+ html.write("<b>" + content + "</b>")
- if for_what != "search" and not (for_what == "bulk" and not unique):
- tdclass, content = attr.paint(value, "")
- if not content:
- content = _("empty")
- html.write("<b>" + content + "</b>")
-
- html.write(explanation)
- html.write("</div>")
+ html.write(explanation)
+ html.write("</div>")
if len(topics) > 1:
Module: check_mk
Branch: master
Commit: 75eb2597e9960138610a5937830eae973957328f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=75eb2597e99601…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 20 10:38:55 2012 +0200
jolokia_info, jolokia_metrics: new rewritten checks for jolokia
---
ChangeLog | 2 ++
.../j4p_new => agents}/plugins/mk_jolokia | 0
.../j4p_new/checks => checks}/jolokia_info | 0
.../j4p_new/checks => checks}/jolokia_metrics | 0
4 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b5db83b..0b8928d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,8 @@
* New Checks for Siemens Blades (BX600)
* FIX: megaraid_pdisks: handle case where no enclosure device exists
* mysql_capacity: cleaned up check, levels are in MB now
+ * jolokia_info, jolokia_metrics: new rewritten checks for jolokia (formerly
+ jmx4perl). You need the new plugin mk_jokokia for using them
WATO:
* Added permission to control the "clone host" feature in WATO
diff --git a/doc/treasures/j4p_new/plugins/mk_jolokia b/agents/plugins/mk_jolokia
similarity index 100%
rename from doc/treasures/j4p_new/plugins/mk_jolokia
rename to agents/plugins/mk_jolokia
diff --git a/doc/treasures/j4p_new/checks/jolokia_info b/checks/jolokia_info
similarity index 100%
rename from doc/treasures/j4p_new/checks/jolokia_info
rename to checks/jolokia_info
diff --git a/doc/treasures/j4p_new/checks/jolokia_metrics b/checks/jolokia_metrics
similarity index 100%
rename from doc/treasures/j4p_new/checks/jolokia_metrics
rename to checks/jolokia_metrics
Module: check_mk
Branch: master
Commit: 777a4a6264b3e08c9ddffff3d8bb68794fe80975
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=777a4a6264b3e0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 20 09:46:41 2012 +0200
WATO: allow @ in user names
---
web/htdocs/wato.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 3fe4de2..cd81da8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -7531,8 +7531,8 @@ def mode_edit_user(phase):
id = html.var("userid").strip()
if new and id in users:
raise MKUserError("userid", _("This username is already being used by another user."))
- if not re.match("^[-a-z0-9A-Z_\.]+$", id):
- raise MKUserError("userid", _("The username must consist only of letters, digit and the underscore."))
+ if not re.match("^[-a-z0-9A-Z_\.@]+$", id):
+ raise MKUserError("userid", _("The username must consist only of letters, digits, <tt>@</tt>, <tt>_</tt> or colon."))
if new:
new_user = {}