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
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
January 2017
----- 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
10 participants
302 discussions
Start a n
N
ew thread
Refactored werks.
by Roland Halbig
Module: check_mk Branch: master Commit: 656bed70a2f8fe2abe8dcb7c2ddbbaeb7a3b3daa URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=656bed70a2f8fe…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Tue Jan 17 11:47:03 2017 +0100 Refactored werks. Change-Id: I6818eac1342968b469a718df0038a5ef309c8661 --- web/htdocs/werks.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/web/htdocs/werks.py b/web/htdocs/werks.py index 6176461..6ad4b80 100644 --- a/web/htdocs/werks.py +++ b/web/htdocs/werks.py @@ -134,13 +134,18 @@ def page_werk(): html.context_button(_("Acknowledge"), ack_url, "werk_ack") html.end_context_buttons() - html.write('<table class="data headerleft werks">') + html.open_table(class_=["data", "headerleft", "werks"]) - def werk_table_row(caption, content, css=""): - html.write('<tr><th>%s</th><td class="%s">%s</td></tr>' % (caption, css, content)) + def werk_table_row(caption, content, css=None): + html.open_tr() + html.th(caption) + html.open_td(class_=css) + html.write(content) + html.close_td() + html.close_tr() werk_table_row(_("ID"), render_werk_id(werk, with_link=False)) - werk_table_row(_("Title"), "<b>" + render_werk_title(werk) + "</b>") + werk_table_row(_("Title"), html.render_b(render_werk_title(werk))) werk_table_row(_("Component"), render_werk_component(werk)) werk_table_row(_("Date"), render_werk_date(werk)) werk_table_row(_("Check_MK Version"), werk["version"]) @@ -149,7 +154,7 @@ def page_werk(): werk_table_row(_("Compatibility"), render_werk_compatibility(werk), css="werkcomp werkcomp%s" % werk["compatible"]) werk_table_row(_("Description"), render_werk_description(werk), css="nowiki") - html.write("</table>") + html.close_table() html.footer() @@ -334,11 +339,13 @@ def render_unacknowleged_werks(): html.end_context_buttons() if werks and not html.has_var("show_unack"): - html.write("<div class=warning>") - html.write("%s<br><br>" % _("<b>Warning:</b> There are %d unacknowledged incompatible werks:") % len(werks)) - url = html.makeuri_contextless([("show_unack", "1"), ("wo_compatibility", "3")]) - html.write('<a href="%s">Show unacknowledged incompatible werks</a>' % url) - html.write("</div>") + html.open_div(class_=["warning"]) + html.write_text(_("<b>Warning:</b> There are %d unacknowledged incompatible werks:") % len(werks)) + html.br() + html.br() + html.a(_("Show unacknowledged incompatible werks"), + href=html.makeuri_contextless([("show_unack", "1"), ("wo_compatibility", "3")])) + html.close_div() def render_werks_table(): @@ -383,7 +390,7 @@ def render_werks_table(): if current_group != False: table.end() else: - html.write("<h3>%s</h3>" % _("No matching Werks found.")) + html.h3(_("No matching Werks found.")) def werk_group_value(werk, grouping): if grouping == None: @@ -488,8 +495,8 @@ def render_werk_compatibility(werk): def render_werk_component(werk): if werk["component"] not in werk_components(): - html.write("<li>Invalid component %s in werk %s</li>" % - (werk["component"],render_werk_id(werk, with_link=True))) + html.li(_("Invalid component %s in werk %s")\ + % (werk["component"], render_werk_id(werk, with_link=True))) return werk["component"] else: return werk_components()[werk["component"]]
7 years, 5 months
1
0
0
0
Refactored htdocs/lib.
by Roland Halbig
Module: check_mk Branch: master Commit: 964631e0232647a274a1335bf84d7bbffd76d101 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=964631e0232647…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Tue Jan 17 11:54:36 2017 +0100 Refactored htdocs/lib. Change-Id: I9f827285571228ca74baa2d7b3298d2735b4eac6 --- web/htdocs/lib.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/web/htdocs/lib.py b/web/htdocs/lib.py index bdd0039..a957ffd 100644 --- a/web/htdocs/lib.py +++ b/web/htdocs/lib.py @@ -1013,26 +1013,31 @@ interface_port_type_choices = dict_choices(interface_port_types) # '----------------------------------------------------------------------' def begin_floating_options(div_id, is_open): - html.write('<div class="view_form" id="%s" %s>' - % (div_id, not is_open and 'style="display: none"' or '') ) - html.write("<table border=0 cellspacing=0 cellpadding=0 class=filterform><tr><td>") + html.open_div(id_=div_id, class_=["view_form"], style="display: none" if not is_open else None) + html.open_table(class_=["filterform"], cellpadding="0", cellspacing="0", border="0") + html.open_tr() + html.open_td() def end_floating_options(reset_url=None): - html.write("</td></tr>") - html.write("<tr><td>") + html.close_td() + html.close_tr() + html.open_tr() + html.open_td() html.button("apply", _("Apply"), "submit") if reset_url: html.buttonlink(reset_url, _("Reset to defaults")) - html.write("</td></tr></table>") - html.write("</div>") + html.close_td() + html.close_tr() + html.close_table() + html.close_div() def render_floating_option(name, height, varprefix, valuespec, value): - html.write('<div class="floatfilter %s %s">' % (height, name)) - html.write('<div class=legend>%s</div>' % valuespec.title()) - html.write('<div class=content>') + html.open_div(class_=["floatfilter", height, name]) + html.div(valuespec.title(), class_=["legend"]) + html.open_div(class_=["content"]) valuespec.render_input(varprefix + name, value) - html.write("</div>") - html.write("</div>") + html.close_div() + html.close_div()
7 years, 5 months
1
0
0
0
Fixed missing argument in function call
by Lars Michelsen
Module: check_mk Branch: master Commit: 982634d401cc9d120ec63528b3a02e9666ff32d5 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=982634d401cc9d…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Jan 17 13:31:47 2017 +0100 Fixed missing argument in function call Change-Id: I073907c7e5a4c6abc832d1751f90bea0800ff371 --- web/htdocs/wato.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index 4b8c72d..c6744a9 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -6404,7 +6404,7 @@ def mode_groups(phase, what): if html.var('_delete'): delname = html.var("_delete") - usages = find_usages_of_group(what) + usages = find_usages_of_group(delname, what) if usages: message = "<b>%s</b><br>%s:<ul>" % \
7 years, 5 months
1
0
0
0
Refactored logwatch.
by Roland Halbig
Module: check_mk Branch: master Commit: ef20f1255b0cb0b57406ce473c6feeb3ec28c705 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ef20f1255b0cb0…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Tue Jan 17 11:39:58 2017 +0100 Refactored logwatch. Change-Id: I4d329df2797a0ead9d06cfecbe676f51d92b0fcb --- web/htdocs/logwatch.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/web/htdocs/logwatch.py b/web/htdocs/logwatch.py index a984584..a2ce20a 100644 --- a/web/htdocs/logwatch.py +++ b/web/htdocs/logwatch.py @@ -80,8 +80,7 @@ def show_log_list(): html.end_context_buttons() for site, host_name, logs in all_logs(): - html.write('<h2><a href="%s">%s</a></h2>' % \ - (html.makeuri([('site', site), ('host', host_name)]), host_name)) + html.h2(html.render_a(host_name, href=html.makeuri([('site', site), ('host', host_name)]))) list_logs(site, host_name, logs) html.footer() @@ -110,9 +109,9 @@ def show_host_log_list(site, host_name): ack_button(site, host_name) html.end_context_buttons() - html.write("<table class=data>\n") + html.open_table(class_=["data"]) list_logs(site, host_name, logfiles_of_host(site, host_name)) - html.write("</table>\n") + html.close_table() html.footer() @@ -202,22 +201,25 @@ def show_file(site, host_name, file_name): html.end_context_buttons() - html.write("<div id=logwatch>\n") + html.open_div(id_="logwatch") for log in log_chunks: - html.write('<div class="chunk">\n') - html.write('<table class="section">\n<tr>\n') - html.write('<td class="%s">%s</td>\n' % (form_level(log['level']), form_level(log['level']))) - html.write('<td class="date">%s</td>\n' % (form_datetime(log['datetime']))) - html.write('</tr>\n</table>\n') + html.open_div(class_=["chunk"]) + html.open_table(class_=["section"]) + html.open_tr() + html.td(form_level(log['level']), class_=form_level(log['level'])) + html.td(form_datetime(log['datetime']), class_="date") + html.close_tr() + html.close_table() for line in log['lines']: - html.write('<p class="%s">' % line['class']) + html.open_p(class_=line['class']) html.icon_button(analyse_url(site, host_name, file_name, line['line']), _("Analyze this line"), "analyze") - html.write('%s</p>\n' % (html.attrencode(line['line']).replace(" ", " ").replace("\1", "<br>") )) + html.write(html.attrencode(line['line']).replace(" ", " ").replace("\1", "<br>")) + html.close_p() - html.write('</div>\n') + html.close_div() - html.write("</div>\n") + html.close_div() html.footer() @@ -295,8 +297,8 @@ def do_log_ack(site, host_name, file_name): return if not config.user.may("general.act"): - html.write("<h1 class=error>"+_('Permission denied')+"</h1>\n") - html.write("<div class=error>" + _('You are not allowed to acknowledge %s</div>') % ack_msg) + html.h1(_('Permission denied'), class_=["error"]) + html.div(_('You are not allowed to acknowledge %s') % ack_msg, class_=["error"]) html.footer() return
7 years, 5 months
1
0
0
0
Refactoring table: Cleanup.
by Roland Halbig
Module: check_mk Branch: master Commit: 744a57256467ab3f59e9b9401dc3c31297284de3 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=744a57256467ab…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Tue Jan 17 10:13:58 2017 +0100 Refactoring table: Cleanup. Change-Id: Ic9ab3fdcf909cbe7302cb5b04b651fe2438a0c9b --- web/htdocs/table.py | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/web/htdocs/table.py b/web/htdocs/table.py index f006ac8..c0ce661 100644 --- a/web/htdocs/table.py +++ b/web/htdocs/table.py @@ -130,6 +130,7 @@ def add_cell(title="", text="", css=None, help=None, colspan=None, sortable=True def end(): + global table finish_previous() html.unplug() @@ -142,18 +143,12 @@ def end(): if table["output_format"] == "fetch": return table["headers"], table["rows"] - if table["output_format"] == "csv": - do_csv = True - csv_separator = html.var("csv_separator", ";") - else: - do_csv = False - if not table["rows"] and table["omit_if_empty"]: table = None return - if do_csv: - _write_csv(table, csv_separator) + if table["output_format"] == "csv": + _write_csv(table, csv_separator=html.var("csv_separator", ";")) table = None return @@ -170,13 +165,8 @@ def end(): table = None return - rows = table["rows"] - # Controls whether or not actions are available for a table - rows, actions_enabled, actions_visible, search_term, user_opts = _evaluate_user_opts(table, rows) - - num_rows_unlimited = len(rows) - num_cols = len(table["headers"]) + rows, actions_enabled, actions_visible, search_term, user_opts = _evaluate_user_opts(table) # Apply limit after search / sorting etc. limit = table['limit'] @@ -184,8 +174,9 @@ def end(): rows = rows[:limit] # Render header - _write_table(table, rows, num_cols, actions_enabled, actions_visible, search_term) + _write_table(table, rows, actions_enabled, actions_visible, search_term) + num_rows_unlimited = len(rows) if limit is not None and num_rows_unlimited > limit: html.message(_('This table is limited to show only %d of %d rows. ' 'Click <a href="%s">here</a> to disable the limitation.') % @@ -194,11 +185,13 @@ def end(): if actions_enabled: config.user.save_file("tableoptions", user_opts) table = None + return -def _evaluate_user_opts(table, rows): +def _evaluate_user_opts(table): table_id = table["id"] + rows = table["rows"] search_term = None actions_enabled = (table["searchable"] or table["sortable"]) @@ -207,7 +200,6 @@ def _evaluate_user_opts(table, rows): return rows, False, False, None, None else: - user_opts = config.user.load_file("tableoptions", {}) user_opts.setdefault(table_id, {}) table_opts = user_opts[table_id] @@ -216,7 +208,6 @@ def _evaluate_user_opts(table, rows): actions_visible = user_opts[table_id].get('actions_visible', False) if html.var('_%s_actions' % table_id): actions_visible = html.var('_%s_actions' % table_id) == '1' - user_opts[table_id]['actions_visible'] = actions_visible if html.var('_%s_reset' % table_id): @@ -240,7 +231,7 @@ def _evaluate_user_opts(table, rows): if table["sortable"]: # Now apply eventual sorting settings sort = html.var('_%s_sort' % table_id, table_opts.get('sort')) - if sort != None: + if sort is not None: html.set_var('_%s_sort' % table_id, sort) table_opts['sort'] = sort # persist sort_col, sort_reverse = map(int, sort.split(',', 1)) @@ -249,9 +240,10 @@ def _evaluate_user_opts(table, rows): return rows, actions_enabled, actions_visible, search_term, user_opts -def _write_table(table, rows, num_cols, actions_enabled, actions_visible, search_term): +def _write_table(table, rows, actions_enabled, actions_visible, search_term): table_id = table["id"] + num_cols = len(table["headers"]) html.write('<table class="data oddeven') if "css" in table:
7 years, 5 months
1
0
0
0
Refactored table.
by Roland Halbig
Module: check_mk Branch: master Commit: aa41720016808e680377a93f267f7a22c64783ce URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aa41720016808e…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Tue Jan 17 11:06:07 2017 +0100 Refactored table. Change-Id: Ibb352128e9f5dbaafa2034e82fae206ba39424bf --- web/htdocs/table.py | 87 +++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/web/htdocs/table.py b/web/htdocs/table.py index c0ce661..387cdc2 100644 --- a/web/htdocs/table.py +++ b/web/htdocs/table.py @@ -155,13 +155,15 @@ def end(): #html.guitest_record_output("data_tables", table) if table["title"]: - html.write("<h3>%s</h3>" % table["title"]) + html.open_h3() + html.write(table["title"]) + html.close_h3() if table.get("help"): html.help(table["help"]) if not table["rows"]: - html.write("<div class=info>%s</div>" % table["empty_text"]) + html.div(table["empty_text"], class_="info") table = None return @@ -245,39 +247,37 @@ def _write_table(table, rows, actions_enabled, actions_visible, search_term): table_id = table["id"] num_cols = len(table["headers"]) - html.write('<table class="data oddeven') - if "css" in table: - html.write(" %s" % table["css"]) - html.write('">\n') + html.open_table(class_=["data", "oddeven", table["css"] if "css" in table else None]) # If we have no group headers then paint the headers now if table["rows"] and table["rows"][0][2] != "header": _render_headers(table, actions_enabled, actions_visible) if actions_enabled and actions_visible: - html.write('<tr class="data even0 actions"><td colspan=%d>' % num_cols) + html.open_tr(class_=["data", "even0", "actions"]) + html.open_td(colspan=num_cols) if not html.in_form(): html.begin_form("%s_actions" % table_id) if table["searchable"]: - html.write("<div class=search>") + html.open_div(class_="search") html.text_input("_%s_search" % table_id) html.button("_%s_submit" % table_id, _("Search")) html.button("_%s_reset" % table_id, _("Reset search")) html.set_focus("_%s_search" % table_id) - html.write("</div>\n") + html.close_div() if html.has_var('_%s_sort' % table_id): - html.write("<div class=sort>") + html.open_div(class_=["sort"]) html.button("_%s_reset_sorting" % table_id, _("Reset sorting")) - html.write("</div>\n") + html.close_div() if not html.in_form(): html.begin_form("%s_actions" % table_id) html.hidden_fields() html.end_form() - html.write('</tr>') + html.close_tr() odd = "even" for nr, (row, css, state, fixed) in enumerate(rows): @@ -285,28 +285,31 @@ def _write_table(table, rows, actions_enabled, actions_visible, search_term): if state == "header": # Show the header only, if at least one (non-header) row follows if nr < len(rows) - 1 and rows[nr+1][2] != "header": - html.write(' <tr class="groupheader"><td colspan=%d><br>%s</td></tr>' % (num_cols, row)) + html.open_tr(class_="groupheader") + html.open_td(colspan=num_cols) + html.br() + html.write(row) + html.close_td() + html.close_tr() + odd = "even" _render_headers(table, actions_enabled, actions_visible) continue - odd = odd == "odd" and "even" or "odd" - html.write(' <tr class="data %s%d' % (odd, state)) - if css: - html.write(' %s' % css) - html.write('">\n') + odd = "even" if odd == "odd" else "odd" + html.open_tr(class_=["data", odd, state, css if css else None]) for cell_content, css_classes, colspan in row: - colspan = colspan and (' colspan="%d"' % colspan) or '' - html.write(" <td%s%s>" % (css_classes and (" class='%s'" % css_classes) or "", colspan)) + html.open_td(class_=css_classes if css_classes else None, colspan=colspan if colspan else None) html.write(cell_content) - html.write("</td>\n") - html.write("</tr>\n") + html.close_td() + html.close_tr() - if table["searchable"] and search_term and not rows: - html.write('<tr class="data odd0 no_match"><td colspan=%d>%s</td></tr>' % - (num_cols, _('Found no matching rows. Please try another search term.'))) + if not rows and search_term: + html.open_tr(class_=["data", "odd0", "no_match"]) + html.td(_('Found no matching rows. Please try another search term.'), colspan=num_cols) + html.close_tr() - html.write("</table>\n") + html.close_table() def _write_csv(table, csv_separator): @@ -340,7 +343,7 @@ def _render_headers(table, actions_enabled, actions_visible): table_id = table['id'] - html.write(" <tr>") + html.open_tr() first_col = True for nr, (header, css, help, sortable) in enumerate(table["headers"]): text = header @@ -348,24 +351,22 @@ def _render_headers(table, actions_enabled, actions_visible): if help: header = '<span title="%s">%s</span>' % (html.attrencode(help), header) - if css: - css_def = " class=\"header_%s\"" % css - css_class = " header_%s" % css - else: - css_def = "" - css_class = "" + css_class = "header_%s" % css if css else None if not table["sortable"] or not sortable: - html.write(" <th%s>" % css_def) + html.open_th(class_=css_class) else: reverse = 0 sort = html.var('_%s_sort' % table_id) if sort: sort_col, sort_reverse = map(int, sort.split(',', 1)) if sort_col == nr: - reverse = sort_reverse == 0 and 1 or 0 - html.write(" <th class=\"sort%s\" title=\"%s\" onclick=\"location.href='%s'\">" % - (css_class, _('Sort by %s') % text, html.makeactionuri([('_%s_sort' % table_id, '%d,%d' % (nr, reverse))]))) + reverse = 1 if sort_reverse == 0 else 0 + + action_uri = html.makeactionuri([('_%s_sort' % table_id, '%d,%d' % (nr, reverse))]) + html.open_th(class_=["sort", css_class], + title=_("Sort by %s") % text, + onclick="location.href='%s'" % action_uri) # Add the table action link if first_col: @@ -381,18 +382,20 @@ def _render_headers(table, actions_enabled, actions_visible): state = '1' help = _('Display table actions') img = 'table_actions_off' - html.write("<div class=\"toggle_actions\">") + html.open_div(class_=["toggle_actions"]) html.icon_button(html.makeuri([('_%s_actions' % table_id, state)]), help, img, cssclass = 'toggle_actions') - html.write("<span>%s</span>" % header) - html.write("</div>") + html.open_span() + html.write(header) + html.close_span() + html.close_div() else: html.write(header) else: html.write(header) - html.write("</th>\n") - html.write(" </tr>\n") + html.close_th() + html.close_tr() def _filter_rows(rows, search_term):
7 years, 5 months
1
0
0
0
WebAPI: new functions add/edit/delete host/service/contact groups
by Andreas Boesl
Module: check_mk Branch: master Commit: fa82e4c774d42efce850ac221ff2d6a988e197b6 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fa82e4c774d42e…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Wed Jan 4 16:11:33 2017 +0100 WebAPI: new functions add/edit/delete host/service/contact groups Change-Id: I401fef078ae7001feadca375f38087cd4c50d133 --- web/htdocs/wato.py | 8 ---- web/htdocs/watolib.py | 42 +++++++++---------- web/htdocs/webapi.py | 7 ++-- web/plugins/webapi/webapi.py | 96 +++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 118 insertions(+), 35 deletions(-) diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py index 6366762..4b8c72d 100644 --- a/web/htdocs/wato.py +++ b/web/htdocs/wato.py @@ -8023,14 +8023,6 @@ def mode_timeperiods(phase): -def load_timeperiods(): - return store.load_from_mk_file(wato_root_dir + "timeperiods.mk", "timeperiods", {}) - - -def save_timeperiods(timeperiods): - make_nagios_directory(wato_root_dir) - store.save_to_mk_file(wato_root_dir + "timeperiods.mk", "timeperiods", timeperiods) - class ExceptionName(TextAscii): def __init__(self, **kwargs): diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py index 4a37cef..a0f2dd3 100644 --- a/web/htdocs/watolib.py +++ b/web/htdocs/watolib.py @@ -6910,38 +6910,34 @@ def may_override_read_only_mode(): #. -# .--Groups--------------------------------------------------------------. -# | ____ | -# | / ___|_ __ ___ _ _ _ __ ___ | -# | | | _| '__/ _ \| | | | '_ \/ __| | -# | | |_| | | | (_) | |_| | |_) \__ \ | -# | \____|_| \___/ \__,_| .__/|___/ | -# | |_| | +# .--Timeperiods---------------------------------------------------------. +# | _____ _ _ _ | +# | |_ _(_)_ __ ___ ___ _ __ ___ _ __(_) ___ __| |___ | +# | | | | | '_ ` _ \ / _ \ '_ \ / _ \ '__| |/ _ \ / _` / __| | +# | | | | | | | | | | __/ |_) | __/ | | | (_) | (_| \__ \ | +# | |_| |_|_| |_| |_|\___| .__/ \___|_| |_|\___/ \__,_|___/ | +# | |_| | # +----------------------------------------------------------------------+ - def load_timeperiods(): - filename = wato_root_dir + "timeperiods.mk" - if not os.path.exists(filename): - return {} - try: - vars = { "timeperiods" : {} } - execfile(filename, vars, vars) - return vars["timeperiods"] + return store.load_from_mk_file(wato_root_dir + "timeperiods.mk", "timeperiods", {}) - except Exception, e: - if config.debug: - raise MKGeneralException(_("Cannot read configuration file %s: %s") % - (filename, e)) - return {} def save_timeperiods(timeperiods): make_nagios_directory(wato_root_dir) - out = create_user_file(wato_root_dir + "timeperiods.mk", "w") - out.write(wato_fileheader()) - out.write("timeperiods.update(%s)\n" % pprint.pformat(timeperiods)) + store.save_to_mk_file(wato_root_dir + "timeperiods.mk", "timeperiods", timeperiods) +#. +# .--Groups--------------------------------------------------------------. +# | ____ | +# | / ___|_ __ ___ _ _ _ __ ___ | +# | | | _| '__/ _ \| | | | '_ \/ __| | +# | | |_| | | | (_) | |_| | |_) \__ \ | +# | \____|_| \___/ \__,_| .__/|___/ | +# | |_| | +# +----------------------------------------------------------------------+ + def is_alias_used(my_what, my_name, my_alias): # Host / Service / Contact groups all_groups = userdb.load_group_information() diff --git a/web/htdocs/webapi.py b/web/htdocs/webapi.py index 15d918b..d109c9e 100644 --- a/web/htdocs/webapi.py +++ b/web/htdocs/webapi.py @@ -100,16 +100,17 @@ def page_api(): action_response = api_actions[action]["handler"](request_object) response = { "result_code": 0, "result": action_response } + except MKAuthException, e: + response = { "result_code": 1, "result": _("Authorization Error. Insufficent permissions for '%s'") % e } except MKException, e: - response = { "result_code": 1, "result": "%s" % e } - + response = { "result_code": 1, "result": _("Check_MK exception: %s") % e } except Exception, e: if config.debug: raise log_exception() response = { "result_code" : 1, - "result" : "Unhandled exception: %s" % traceback.format_exc(), + "result" : _("Unhandled exception: %s") % traceback.format_exc(), } if html.output_format == "json": diff --git a/web/plugins/webapi/webapi.py b/web/plugins/webapi/webapi.py index b4884ab..f97ea1b 100644 --- a/web/plugins/webapi/webapi.py +++ b/web/plugins/webapi/webapi.py @@ -32,6 +32,16 @@ def validate_request_keys(request, valid_keys): raise MKUserError(None, _("Invalid key: %s") % key) +#. +# .--Hosts---------------------------------------------------------------. +# | _ _ _ | +# | | | | | ___ ___| |_ ___ | +# | | |_| |/ _ \/ __| __/ __| | +# | | _ | (_) \__ \ |_\__ \ | +# | |_| |_|\___/|___/\__|___/ | +# | | +# +----------------------------------------------------------------------+ + # Check if the given attribute name exists, no type check def validate_general_host_attributes(host_attributes): # inventory_failed and site are no "real" host_attributes (TODO: Clean this up!) @@ -250,7 +260,90 @@ api_actions["delete_host"] = { "locking" : True, } -############### +#. +# .--Groups--------------------------------------------------------------. +# | ____ | +# | / ___|_ __ ___ _ _ _ __ ___ | +# | | | _| '__/ _ \| | | | '_ \/ __| | +# | | |_| | | | (_) | |_| | |_) \__ \ | +# | \____|_| \___/ \__,_| .__/|___/ | +# | |_| | +# +----------------------------------------------------------------------+ + + +def action_get_all_groups(request, group_type): + validate_request_keys(request, []) + return userdb.load_group_information().get(group_type, {}) + + +def action_delete_group(request, group_type): + validate_request_keys(request, ["groupname"]) + groupname = request.get("groupname") + delete_group(groupname, group_type) + + +def get_group_extra_info(request, group_type): + extra_info = {} + extra_info["alias"] = request.get("alias") + if group_type == "contact" and "nagvis_maps" in request: + extra_info["nagvis_maps"] = request["nagvis_maps"] + return extra_info + + +def validate_group_request_keys(request, group_type): + if group_type == "contact": + validate_request_keys(request, ["groupname", "alias", "nagvis_maps"]) + else: + validate_request_keys(request, ["groupname", "alias"]) + + +def action_add_group(request, group_type): + validate_group_request_keys(request, group_type) + add_group(request.get("groupname"), group_type, get_group_extra_info(request, group_type)) + + +def action_edit_group(request, group_type): + validate_group_request_keys(request, group_type) + edit_group(request.get("groupname"), group_type, get_group_extra_info(request, group_type)) + + +def register_group_apis(): + for group_type in [ "contact", "host", "service" ]: + api_actions["get_all_%sgroups" % group_type] = { + # Note: group_type=group_type bypasses pythons late binding behaviour + "handler" : lambda x, group_type=group_type: action_get_all_groups(x, group_type), + "locking" : False, + } + + api_actions["delete_%sgroup" % group_type] = { + # Note: group_type=group_type bypasses pythons late binding behaviour + "handler" : lambda x, group_type=group_type: action_delete_group(x, group_type), + "locking" : True, + } + + api_actions["add_%sgroup" % group_type] = { + # Note: group_type=group_type bypasses pythons late binding behaviour + "handler" : lambda x, group_type=group_type: action_add_group(x, group_type), + "locking" : True, + } + + api_actions["edit_%sgroup" % group_type] = { + # Note: group_type=group_type bypasses pythons late binding behaviour + "handler" : lambda x, group_type=group_type: action_edit_group(x, group_type), + "locking" : True, + } + +register_group_apis() # Otherwise, group_type is known in the global scope.. + +#. +# .--Other---------------------------------------------------------------. +# | ___ _ _ | +# | / _ \| |_| |__ ___ _ __ | +# | | | | | __| '_ \ / _ \ '__| | +# | | |_| | |_| | | | __/ | | +# | \___/ \__|_| |_|\___|_| | +# | | +# +----------------------------------------------------------------------+ def action_discover_services(request): validate_request_keys(request, ["hostname", "mode"]) @@ -339,3 +432,4 @@ api_actions["activate_changes"] = { "locking" : True, } +
7 years, 5 months
1
0
0
0
Refactored code for host/contact/service group manipulation
by Andreas Boesl
Module: check_mk Branch: master Commit: 9de41b52dee21295ba67add78b6e5a3fe54e9e43 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9de41b52dee212…
Author: Andreas Boesl <ab(a)mathias-kettner.de> Date: Wed Jan 4 16:08:32 2017 +0100 Refactored code for host/contact/service group manipulation Change-Id: Iab8725c654bc92ff9a14789ba96dc9f69fd32559 --- web/htdocs/wato.py | 230 ++++++++------------------------------------ web/htdocs/watolib.py | 257 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 297 insertions(+), 190 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=9de41b52de…
7 years, 5 months
1
0
0
0
Fixed encoding issue in availability legend
by Lars Michelsen
Module: check_mk Branch: master Commit: c3d1b07b869710fb1a86391c231628f30f66bf1e URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3d1b07b869710…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Tue Jan 17 11:34:15 2017 +0100 Fixed encoding issue in availability legend Change-Id: I470c452e1d579d39e7dec7b52788e73d464e746f --- web/plugins/views/availability.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py index 262bfe0..a79f0a7 100644 --- a/web/plugins/views/availability.py +++ b/web/plugins/views/availability.py @@ -290,11 +290,11 @@ def render_availability_tables(availability_tables, what, avoptions): html.h3(_("Availability levels")) html.div(_("OK"), class_="state state0") - html.div("≥ %.3f%%" % warn, class_="level") + html.div("> %.3f%%" % warn, class_="level") html.div(_("WARN"), class_="state state1") - html.div("≥ %.3f%%" % crit, class_="level") + html.div("> %.3f%%" % crit, class_="level") html.div(_("CRIT"), class_="state state2") - html.div("< %.3f%%" % crit, class_="level") + html.div("< %.3f%%" % crit, class_="level") html.close_div()
7 years, 5 months
1
0
0
0
EC: Loading rule hits from all connected sites ECs
by Lars Michelsen
Module: check_mk Branch: master Commit: 107bdc26b2707d6c2167108bc2c598776ec64be0 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=107bdc26b2707d…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Mon Jan 16 16:58:38 2017 +0100 EC: Loading rule hits from all connected sites ECs Change-Id: Ib2641a2a16abca2d155dc22fa6f132219e08bc7a --- bin/mkeventd | 16 +++++++++++++++- web/plugins/wato/mkeventd.py | 23 +++++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/bin/mkeventd b/bin/mkeventd index 9c05f79..40a364b 100755 --- a/bin/mkeventd +++ b/bin/mkeventd @@ -135,6 +135,11 @@ history_columns = [ ( "history_addinfo", "" ), ] + event_columns +rule_columns = [ + ( "rule_id", "" ), + ( "rule_hits", 0 ), +] + # Alas, we often have no clue about the actual encoding, so we have to guess: # Initially we assume UTF-8, but fall back to latin-1 if it didn't work. def decode_from_bytes(string_as_bytes): @@ -3209,10 +3214,13 @@ class StatusServer: columns = event_columns elif table == "history": columns = history_columns + elif table == "rules": + columns = rule_columns elif table == "status": columns = g_event_server.status_columns() else: - raise MKClientError("Invalid table %s, we only have 'events', 'history' and 'status'" % table) + raise MKClientError("Invalid table %s, we only have 'events', 'history', " + "'rules' and 'status'" % table) filters = [] only_host = None @@ -3245,6 +3253,8 @@ class StatusServer: headers, list_rows = g_event_status.get_events(only_host) elif table == "history": headers, list_rows = get_event_history(filters, limit) + elif table == "rules": + headers, list_rows = g_event_status.get_rule_stats() else: headers, list_rows = g_event_server.get_status() @@ -3793,6 +3803,10 @@ class EventStatus(): result.append(event_line) return [ e[0] for e in event_columns ], result + + def get_rule_stats(self): + return [ e[0] for e in rule_columns ], sorted(self._rule_stats.items(), key=lambda x: x[0]) + #. # .--Actions-------------------------------------------------------------. # | _ _ _ | diff --git a/web/plugins/wato/mkeventd.py b/web/plugins/wato/mkeventd.py index 02b8b96..027e1c7 100644 --- a/web/plugins/wato/mkeventd.py +++ b/web/plugins/wato/mkeventd.py @@ -24,6 +24,7 @@ # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA. +import sites import mkeventd import zipfile import cStringIO @@ -930,16 +931,18 @@ def load_mkeventd_rules(): # Add information about rule hits: If we are running on OMD then we know # the path to the state retention file of mkeventd and can read the rule # statistics directly from that file. - mkeventd_status = store.load_data_from_file(mkeventd_status_file) - if mkeventd_status != None: - rule_stats = mkeventd_status["rule_stats"] - for rule_pack in vars["rule_packs"]: - pack_hits = 0 - for rule in rule_pack["rules"]: - hits = rule_stats.get(rule["id"], 0) - rule["hits"] = hits - pack_hits += hits - rule_pack["hits"] = pack_hits + rule_stats = {} + for rule_id, count in sites.live().query("GET eventconsolerules\nColumns: rule_id rule_hits\n"): + rule_stats.setdefault(rule_id, 0) + rule_stats[rule_id] += count + + for rule_pack in vars["rule_packs"]: + pack_hits = 0 + for rule in rule_pack["rules"]: + hits = rule_stats.get(rule["id"], 0) + rule["hits"] = hits + pack_hits += hits + rule_pack["hits"] = pack_hits # Migrate old contact_group key (+ add False for notify option) for rule_pack in vars["rule_packs"]:
7 years, 5 months
1
0
0
0
← Newer
1
...
10
11
12
13
14
15
16
...
31
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
24
25
26
27
28
29
30
31
Results per page:
10
25
50
100
200