lists.checkmk.com
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
List overview
Download
Checkmk git commits
February 2012
----- 2024 -----
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
checkmk-commits@lists.checkmk.com
3 participants
223 discussions
Start a n
N
ew thread
Check_MK Git: check_mk: Fixed broken host validation
by lm@mathias-kettner.de
Module: check_mk Branch: master Commit: 11c150c2fcac779fdd3418b9b07eb5ff4c692210 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=11c150c2fcac77…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Feb 28 11:00:17 2012 +0100 Fixed broken host validation --- web/htdocs/wato.py | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index f3d747a..9be661b 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -1223,7 +1223,7 @@ def show_hosts(folder): # Hostname with link to details page (edit host) html.write('<td>') - errors = host_errors.get(hostname,[]) + validate_host(hostname) + errors = host_errors.get(hostname,[]) + validate_host(host, g_folder) if errors: msg = _("Warning: This host has an invalid configuration: ") msg += ", ".join(errors) @@ -1798,7 +1798,7 @@ def mode_edithost(phase, new, cluster): call_hook_hosts_changed(g_folder) reload_hosts(g_folder) - errors = validate_all_hosts([hostname]).get(hostname, []) + validate_host(hostname) + errors = validate_all_hosts([hostname]).get(hostname, []) + validate_host(host, g_folder) if errors: # keep on this page if host does not validate return elif new: @@ -1812,7 +1812,7 @@ def mode_edithost(phase, new, cluster): if new: render_folder_path() else: - errors = validate_all_hosts([hostname]).get(hostname, []) + validate_host(hostname) + errors = validate_all_hosts([hostname]).get(hostname, []) + validate_host(host, g_folder) if errors: html.write("<div class=info>") @@ -4205,6 +4205,7 @@ def effective_attributes(host, folder): chain = [ host ] else: chain = [ ] + while folder: chain.append(folder.get("attributes", {})) folder = folder.get(".parent") @@ -9930,10 +9931,10 @@ def call_hook_roles_saved(roles): # 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. -def validate_host(host): +def validate_host(host, folder): if hook_registered('validate-host'): errors = [] - eff = effective_attributes(host, host[".folder"]) + eff = effective_attributes(host, folder) for hk in g_hooks.get('validate-host', []): try: hk(eff)
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: WATO host tag management: replaced text button with icon button
by lm@mathias-kettner.de
Module: check_mk Branch: master Commit: 282f81baed4cbe2d83e36b93af217d3eceaa929c URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=282f81baed4cbe…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Fri Feb 24 14:21:20 2012 +0100 WATO host tag management: replaced text button with icon button --- web/htdocs/wato.py | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index c8232a4..d185b4c 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -7602,7 +7602,6 @@ def mode_hosttags(phase): "<th>" + _("Type") + "</th>" "<th>" + _("Choices") + "</th>" "<th>" + _("Demonstration") + "</th>" - "<th></th>" "</tr>") odd = "even" for nr, (tag_id, title, choices) in enumerate(hosttags): @@ -7621,6 +7620,7 @@ def mode_hosttags(phase): else: html.icon_button(html.makeactionuri([("_move", str(nr))]), _("Move this tag group one position down"), "down") + html.icon_button(edit_url, _("Edit this tag group"), "edit") html.icon_button(delete_url, _("Delete this tag group"), "delete") html.write("</td>") html.write("<td>%s</td>" % tag_id) @@ -7632,9 +7632,6 @@ def mode_hosttags(phase): host_attribute["tag_%s" % tag_id].render_input(None) html.end_form() html.write("</td>") - html.write("<td class=buttons>") - html.buttonlink(edit_url, _("Edit")) - html.write("</td>") html.write("</tr>") html.write("</table>")
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: Tag management: Replaced Edit button with icon button
by lm@mathias-kettner.de
Module: check_mk Branch: master Commit: 4224104fa5a80c774f6936e62f69ec3a671f50a6 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4224104fa5a80c…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Feb 28 10:21:11 2012 +0100 Tag management: Replaced Edit button with icon button --- web/htdocs/wato.py | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index db4f0f2..f3d747a 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -7658,7 +7658,6 @@ def mode_hosttags(phase): "<th>" + _("Type") + "</th>" "<th>" + _("Choices") + "</th>" "<th>" + _("Demonstration") + "</th>" - "<th></th>" "</tr>") odd = "even" for nr, (tag_id, title, choices) in enumerate(hosttags): @@ -7677,6 +7676,7 @@ def mode_hosttags(phase): else: html.icon_button(html.makeactionuri([("_move", str(nr))]), _("Move this tag group one position down"), "down") + html.icon_button(edit_url, _("Edit this tag group"), "edit") html.icon_button(delete_url, _("Delete this tag group"), "delete") html.write("</td>") html.write("<td>%s</td>" % tag_id) @@ -7688,9 +7688,6 @@ def mode_hosttags(phase): host_attribute["tag_%s" % tag_id].render_input(None) html.end_form() html.write("</td>") - html.write("<td class=buttons>") - html.buttonlink(edit_url, _("Edit")) - html.write("</td>") html.write("</tr>") html.write("</table>")
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: Merge branch 'master' of ssh://git.mathias-kettner. de/var/www/80/git.mathias-kettner.de/check_mk
by lm@mathias-kettner.de
Module: check_mk Branch: master Commit: 4ac7300c643bb2e0e075ae8db8275071c224cd40 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4ac7300c643bb2…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Feb 28 10:18:24 2012 +0100 Merge branch 'master' of ssh://git.mathias-kettner.de/var/www/80/git.mathias-kettner.de/check_mk Conflicts: web/htdocs/wato.py ---
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: Fix styling bug in valuespec ListOf
by git@mathias-kettner.de
Module: check_mk Branch: master Commit: c5e9b01da3d70e6c43b9aba05dcf2d7787bf9c0a URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c5e9b01da3d70e…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Sun Feb 26 14:30:12 2012 +0100 Fix styling bug in valuespec ListOf --- web/htdocs/js/checkmk.js | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js index 3ad837b..20abfaf 100644 --- a/web/htdocs/js/checkmk.js +++ b/web/htdocs/js/checkmk.js @@ -1457,7 +1457,7 @@ function valuespec_listof_add(varprefix, magic) { htmlcode = replace_all(htmlcode, magic, strcount); var oTable = document.getElementById(varprefix + "_table"); if (count == 0) { // first: no <tbody> present! - oTable.innerHTML = "<tbody><tr><td>" + htmlcode + "</td></tr></tbody>"; + oTable.innerHTML = "<tbody><tr>" + htmlcode + "</tr></tbody>"; } else { var oTbody = oTable.childNodes[0];
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: WATO: create basic sample configuration
by git@mathias-kettner.de
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----------------------------------------------------------. # | _ _ _ ___ _ ____ ___ | # | | | | | ___ ___ | | _____ ( _ ) / \ | _ \_ _| |
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: Updated bug entries #0668
by git@mathias-kettner.de
Module: check_mk Branch: master Commit: 27e47b5b8dde019ca27c27ad585cace03799ac5b URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=27e47b5b8dde01…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Sun Feb 26 11:19:11 2012 +0100 Updated bug entries #0668 --- .bugs/668 | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/.bugs/668 b/.bugs/668 new file mode 100644 index 0000000..7527616 --- /dev/null +++ b/.bugs/668 @@ -0,0 +1,10 @@ +Title: Reschedule does not work anymore +Component: multisite +State: open +Date: 2012-02-26 11:18:29 +Targetversion: 1.2.0 +Class: bug + +When clicking on the rotating arrows only the error +message ERROR cannot reschedule check: time out +appears (after ~ 1 sec.)
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: WATO: finished auxiliary tags
by git@mathias-kettner.de
Module: check_mk Branch: master Commit: ff0831b130ee70fb0a89d850e8dabb49d3f126ac URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ff0831b130ee70…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Sun Feb 26 11:16:46 2012 +0100 WATO: finished auxiliary tags --- ChangeLog | 2 + web/htdocs/config.py | 9 +++- web/htdocs/valuespec.py | 2 +- web/htdocs/wato.py | 158 +++++++++++++++++++++++++++++++---------------- 4 files changed, 115 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index dcd5eef..32cc746 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,8 @@ * FIX: honor permissions on hosts also on bulk inventory * Only create contacts in Nagios if they are member of at least one contact group. + * It is now possible to configure auxiliary tags via WATO + (formerly also called secondary tags) Checks & Agents: * hpux_if: fix missing default parameter errors diff --git a/web/htdocs/config.py b/web/htdocs/config.py index 095b101..5701af6 100644 --- a/web/htdocs/config.py +++ b/web/htdocs/config.py @@ -92,7 +92,11 @@ def load_config(): global auth_type auth_type = 'basic' - # Reset values that can be appended to + # Reset values that can be appended to. Otherwise + # those lists will get longer for each web page called while + # using the same Python interpreter (i.e. Apache process). + # Remember: the module config.py is only loaded once per process + # and is being reused in later sessions. global aggregations aggregations = [] @@ -102,6 +106,9 @@ def load_config(): global wato_host_tags wato_host_tags = [] + global wato_aux_tags + wato_aux_tags = [] + include("multisite.mk") # Load also recursively all files below multisite.d diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py index 5639453..15ffa89 100644 --- a/web/htdocs/valuespec.py +++ b/web/htdocs/valuespec.py @@ -1510,7 +1510,7 @@ class Foldable(ValueSpec): html.begin_foldable_container("valuespec_foldable", varprefix, self._open, self._valuespec.title(), False) if self._valuespec.help(): - html.write("<i class=help>%s</i><br>" % self._valuespec.help()) + html.write("<i class=help>%s</i><br><br>" % self._valuespec.help()) self._valuespec.render_input(varprefix, value) html.end_foldable_container() diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index 8c8a91c..b78e235 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -8064,7 +8064,7 @@ def save_hosttags(hosttags, auxtags): make_nagios_directory(multisite_dir) out = create_user_file(multisite_dir + "hosttags.mk", "w") out.write("# Written by WATO\n# encoding: utf-8\n\n") - out.write("wato_host_tags += \\\n%s\n" % pprint.pformat(hosttags)) + out.write("wato_host_tags += \\\n%s\n\n" % pprint.pformat(hosttags)) out.write("wato_aux_tags += \\\n%s\n" % pprint.pformat(auxtags)) # Handle renaming and deletion of host tags: find affected @@ -8880,6 +8880,9 @@ def tag_alias(tag): for t in tags: if t[0] == tag: return t[1] + for id, alias in config.wato_aux_tags: + if id == tag: + return alias def render_conditions(ruleset, tagspecs, host_list, item_list, varname, folder): html.write("<ul class=conditions>") @@ -8968,16 +8971,7 @@ def ruleeditor_hover_code(varname, rulenr, mode, boolval, folder=None): def get_rule_conditions(ruleset): - # Tag list - tag_list = [] - for entry in config.wato_host_tags: - id, title, tags = entry[:3] - mode = html.var("tag_" + id) - tagvalue = html.var("tagvalue_" + id) - if mode == "is": - tag_list.append(tagvalue) - elif mode == "isnot": - tag_list.append("!" + tagvalue) + tag_list = get_tag_conditions() # Host list if not html.get_checkbox("explicit_hosts"): @@ -9127,49 +9121,7 @@ def mode_edit_rule(phase): html.write("</i></td>") html.write("<td class=content>") - if len(config.wato_host_tags) == 0: - html.write(_("You have not configured any <a href=\"wato.py?mode=hosttags\">host tags</a>.")) - else: - html.write("<table>") - for entry in config.wato_host_tags: - id, title, tags = entry[:3] - html.write("<tr><td>%s: </td>" % title) - default_tag = None - ignore = True - for t in tag_specs: - if t[0] == '!': - n = True - t = t[1:] - else: - n = False - if t in [ x[0] for x in tags ]: - default_tag = t - ignore = False - negate = n - if ignore: - deflt = "ignore" - elif negate: - deflt = "isnot" - else: - deflt = "is" - - html.write("<td>") - html.select("tag_" + id, [ - ("ignore", _("ignore")), - ("is", _("is")), - ("isnot", _("isnot"))], deflt, - onchange="valuespec_toggle_dropdownn(this, 'tag_sel_%s');" % id) - html.write("</td><td>") - if html.form_submitted(): - div_is_open = html.var("tag_" + id) != "ignore" - else: - div_is_open = deflt != "ignore" - html.write('<div id="tag_sel_%s" style="white-space: nowrap; %s">' % ( - id, not div_is_open and "display: none;" or "")) - html.select("tagvalue_" + id, [t[0:2] for t in tags if t[0] != None], deflt=default_tag) - html.write("</div>") - html.write("</td></tr>") - html.write("</table>") + render_condition_editor(tag_specs) html.write("</td></tr>") @@ -9288,6 +9240,104 @@ def mode_edit_rule(phase): html.hidden_fields() html.end_form() +# Render HTML input fields for editing a tag based condition +def render_condition_editor(tag_specs): + if len(config.wato_aux_tags) + len(config.wato_host_tags) == 0: + html.write(_("You have not configured any <a href=\"wato.py?mode=hosttags\">host tags</a>.")) + return + + # Determine current (default) setting of tag by looking + # into tag_specs (e.g. [ "snmp", "!tcp", "test" ] ) + def current_tag_setting(choices): + default_tag = None + ignore = True + for t in tag_specs: + if t[0] == '!': + n = True + t = t[1:] + else: + n = False + if t in [ x[0] for x in choices ]: + default_tag = t + ignore = False + negate = n + if ignore: + deflt = "ignore" + elif negate: + deflt = "isnot" + else: + deflt = "is" + return default_tag, deflt + + # Show dropdown with "is/isnot/ignore" and beginning + # of div that is switched visible by is/isnot + def tag_condition_dropdown(tagtype, deflt, id): + html.write("<td>") + html.select(tagtype + "_" + id, [ + ("ignore", _("ignore")), + ("is", _("is")), + ("isnot", _("isnot"))], deflt, + onchange="valuespec_toggle_dropdownn(this, 'tag_sel_%s');" % id) + html.write("</td><td>") + if html.form_submitted(): + div_is_open = html.var(tagtype + "_" + id) != "ignore" + else: + div_is_open = deflt != "ignore" + html.write('<div id="tag_sel_%s" style="white-space: nowrap; %s">' % ( + id, not div_is_open and "display: none;" or "")) + + # Show main tags + html.write("<table>") + if len(config.wato_host_tags): + for entry in config.wato_host_tags: + id, title, choices = entry[:3] + html.write("<tr><td>%s: </td>" % title) + default_tag, deflt = current_tag_setting(choices) + tag_condition_dropdown("tag", deflt, id) + html.select("tagvalue_" + id, + [t[0:2] for t in choices if t[0] != None], deflt=default_tag) + html.write("</div>") + html.write("</td></tr>") + + # And auxiliary tags + if len(config.wato_aux_tags): + for id, title in config.wato_aux_tags: + html.write("<tr><td>%s: </td>" % title) + default_tag, deflt = current_tag_setting([(id, title)]) + tag_condition_dropdown("auxtag", deflt, id) + html.write(" " + _("set")) + html.write("</div>") + html.write("</td></tr>") + + + html.write("</table>") + + +# Retrieve current tag condition settings from HTML variables +def get_tag_conditions(): + # Main tags + tag_list = [] + for entry in config.wato_host_tags: + id, title, tags = entry[:3] + mode = html.var("tag_" + id) + tagvalue = html.var("tagvalue_" + id) + if mode == "is": + tag_list.append(tagvalue) + elif mode == "isnot": + tag_list.append("!" + tagvalue) + + # Auxiliary tags + for id, title in config.wato_aux_tags: + mode = html.var("auxtag_" + id) + if mode == "is": + tag_list.append(id) + elif mode == "isnot": + tag_list.append("!" + id) + + html.debug_vars() + html.debug(tag_list) + return tag_list + def save_rulesets(folder, rulesets): make_nagios_directory(root_dir)
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: New valuespec Foldable()
by git@mathias-kettner.de
Module: check_mk Branch: master Commit: 94eff13540ecccaa4e40a20947b9d38ef80ef9cb URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=94eff13540eccc…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Sat Feb 25 21:02:18 2012 +0100 New valuespec Foldable() --- web/htdocs/check_mk.css | 14 ++++++++ web/htdocs/js/checkmk.js | 10 +++-- web/htdocs/valuespec.py | 83 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 88 insertions(+), 19 deletions(-) diff --git a/web/htdocs/check_mk.css b/web/htdocs/check_mk.css index 7c4e8f7..fc3215e 100644 --- a/web/htdocs/check_mk.css +++ b/web/htdocs/check_mk.css @@ -297,6 +297,10 @@ table.valuespec_tuple td.tuple_left { padding-bottom: 10px; } +table.valuespec_tuple span.title { + font-size: 8pt; +} + table.vs_date { border-spacing: 0px; } @@ -311,3 +315,13 @@ table.vs_date th { font-size: 7pt; padding: 0px; } + +table.valuespec_listof td.vlof_buttons { + margin-right: 5px; +} +table.valuespec_listof td.vlof_content { + border: 1px solid white; + box-shadow: 1px 1px 2px #808080; + background-image: url("images/form_background.png"); + background-repeat: repeat; +} diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js index e91ad11..3ad837b 100644 --- a/web/htdocs/js/checkmk.js +++ b/web/htdocs/js/checkmk.js @@ -1452,7 +1452,7 @@ function valuespec_listof_add(varprefix, magic) { var count = parseInt(oCountInput.value); var strcount = "" + (count + 1); oCountInput.value = strcount; - var oPrototype = document.getElementById(varprefix + "_prototype"); + var oPrototype = document.getElementById(varprefix + "_prototype").childNodes[0].childNodes[0]; // TR var htmlcode = oPrototype.innerHTML; htmlcode = replace_all(htmlcode, magic, strcount); var oTable = document.getElementById(varprefix + "_table"); @@ -1462,7 +1462,7 @@ function valuespec_listof_add(varprefix, magic) { else { var oTbody = oTable.childNodes[0]; var oTr = document.createElement("tr") - oTr.innerHTML = "<td>" + htmlcode + "</td>"; + oTr.innerHTML = htmlcode; oTbody.appendChild(oTr); } } @@ -1471,6 +1471,8 @@ function valuespec_listof_add(varprefix, magic) { // remove the according table row and add an invisible // input element with the name varprefix + "_deleted_%nr" function valuespec_listof_delete(oA, varprefix, nr) { - var oTd = oA.parentNode; - oTd.innerHTML = '<input type=hidden name="_' + varprefix + '_deleted_' + nr + '" value=1>' + var oTr = oA.parentNode.parentNode; // TR + var oTdContent = oTr.childNodes[1]; + oTdContent.innerHTML = '<input type=hidden name="_' + varprefix + '_deleted_' + nr + '" value=1>' + oTr.style.display = "none"; } diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py index b6c54cb..5639453 100644 --- a/web/htdocs/valuespec.py +++ b/web/htdocs/valuespec.py @@ -514,19 +514,21 @@ class ListOf(ValueSpec): (varprefix, len(value), varprefix)) # Render reference element for cloning - html.write('<div style="display:none" id="%s_prototype">' % varprefix) + html.write('<table style="display:none" id="%s_prototype">' % varprefix) + html.write('<tr><td class=vlof_buttons>') self.del_button(varprefix, self._magic) - html.write(" ") + html.write('</td><td class=vlof_content>') self._valuespec.render_input( varprefix + "_" + self._magic, self._valuespec.canonical_value()) - html.write('</div>') + html.write('</td></tr></table>') - html.write('<table id="%s_table">' % varprefix) + # Actual table of currently existing entries + html.write('<table class="valuespec_listof" id="%s_table">' % varprefix) for nr, v in enumerate(value): - html.write('<tr><td>') + html.write('<tr><td class=vlof_buttons>') self.del_button(varprefix, nr+1) - html.write(" ") + html.write("</td><td class=vlof_content>") self._valuespec.render_input(varprefix + "_%d" % (nr+1), v) html.write("</td></tr>") html.write("</table>") @@ -1277,8 +1279,9 @@ class Tuple(ValueSpec): return tuple([x.canonical_value() for x in self._elements]) def render_input(self, varprefix, value): - if self._vertical: - html.write('<table class="valuespec_tuple">') + html.write('<table class="valuespec_tuple">') + if not self._vertical: + html.write("<tr>") for no, (element, val) in enumerate(zip(self._elements, value)): vp = varprefix + "_" + str(no) if element.help(): @@ -1288,17 +1291,27 @@ class Tuple(ValueSpec): if self._vertical: html.write("<tr>") if self._show_titles: - title = element.title()[0].upper() + element.title()[1:] - html.write("<td class=tuple_left>%s:%s</td>" % (title, help)) + elem_title = element.title() + if elem_title: + title = element.title()[0].upper() + element.title()[1:] + else: + title = "" + if self._vertical: + html.write("<td class=tuple_left>%s:%s</td>" % (title, help)) + else: + html.write("<td class=tuple_td><span class=title>%s" % title) + if help: + html.write("<br><i>%s</i>" % help) + html.write("</span><br>") if self._vertical: html.write("<td class=tuple_right>") element.render_input(vp, val) + html.write("</td>") if self._vertical: - html.write("</td></tr>") - else: - html.write(" ") - if self._vertical: - html.write("</table>") + html.write("</tr>") + if not self._vertical: + html.write("</tr>") + html.write("</table>") def set_focus(self, varprefix): self._elements[0].set_focus(varprefix + "_0") @@ -1484,3 +1497,43 @@ class AutoTimestamp(FixedValue): def value_to_text(self, value): return time.strftime("%F %T", time.localtime(value)) + +# Fully transparant VS encapsulating a vs in a foldable +# container. +class Foldable(ValueSpec): + def __init__(self, valuespec, **kwargs): + ValueSpec.__init__(self, **kwargs) + self._valuespec = valuespec + self._open = kwargs.get("open", False) + + def render_input(self, varprefix, value): + html.begin_foldable_container("valuespec_foldable", varprefix, self._open, + self._valuespec.title(), False) + if self._valuespec.help(): + html.write("<i class=help>%s</i><br>" % self._valuespec.help()) + self._valuespec.render_input(varprefix, value) + html.end_foldable_container() + + def set_focus(self, varprefix): + self._valuespec.set_focus(varprefix) + + def canonical_value(self): + return self._valuespec.canonical_value() + + def default_value(self): + return self._valuespec.default_value() + + def value_to_text(self, value): + return self._valuespec.value_to_text(value) + + def from_html_vars(self, varprefix): + return self._valuespec.from_html_vars(varprefix) + + def validate_datatype(self, value, varprefix): + self._valuespec.validate_datatype(value, varprefix) + + def validate_value(self, value, varprefix): + self._valuespec.validate_value(value, varprefix) + + +
12 years, 8 months
1
0
0
0
Check_MK Git: check_mk: Improve editable auxiliary tags
by git@mathias-kettner.de
Module: check_mk Branch: master Commit: e0b6f03d23ccb7ab3ddb08e3fb71c215b5ecf2ba URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e0b6f03d23ccb7…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Sat Feb 25 21:02:39 2012 +0100 Improve editable auxiliary tags --- web/htdocs/wato.py | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index 140e8b8..8c8a91c 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -7850,20 +7850,27 @@ def mode_edit_hosttag(phase): Tuple( elements = [ TextAscii( + title = _("Tag ID"), size=10, regex="^[-a-z0-9A-Z_]*$", none_is_empty = True, regex_error = _("Invalid tag ID. Only the characters a-z, A-Z, " "0-9, _ and - are allowed.")), TextUnicode( + title = _("Description"), allow_empty = False, size=20), - ListChoice( - choices = auxtags), + Foldable( + MultiSelect( + title = _("Auxiliary tags"), + help = _("These tags will implicitely added to a host if the " + "user selects this entry in the tag group. Select multiple " + "entries with the <b>Ctrl</b> key."), + choices = auxtags)), ], - show_titles = False, + show_titles = True, orientation = "horizontal"), add_label = _("Add tag choice"),
12 years, 8 months
1
0
0
0
← Newer
1
2
3
4
...
23
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Results per page:
10
25
50
100
200