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
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
December 2016
----- 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
10 participants
391 discussions
Start a n
N
ew thread
Autotest: enriched constants.
by Roland Halbig
Module: check_mk Branch: master Commit: f93127de957be957928b7d64884a6b7756e3ea49 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f93127de957be9…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Thu Dec 15 14:07:10 2016 +0100 Autotest: enriched constants. Change-Id: I0526517a6b85131412e21dfad00f345ec9dd07a9 --- tests/web/auto_build_test.py | 58 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tests/web/auto_build_test.py b/tests/web/auto_build_test.py index d236741..ac99e4e 100644 --- a/tests/web/auto_build_test.py +++ b/tests/web/auto_build_test.py @@ -30,6 +30,64 @@ from bs4 import BeautifulSoup as bs # internal imports from classes import HTMLOrigTester, HTMLCheck_MKTester from tools import compare_html, gentest, compare_and_empty + +_ = lambda x: x + +title = "title" +key = "key" +name = "name" +vp = "vp" +varprefix = "varprefix" +prefix = "prefix" +css = "css" +cls = "cls" +disp = "disp" +sel = "selected" +div_id = "div1" + +_vertical = "vertical" +_delete_style = "filter" +_label = "label" +_empty_text = "empty text" +_no_elements_text = _empty_text +_columns = 5 +_size = 10 + +select_func = "selector" +unselect_func = "unselector" +active_category = "active_category" +category_name = "active_category" +category_alias = "active_alias" + +div_is_open = True +visible = True +oneline = True + +mod = 2 +nr = 1 +indent = 10 +display_off = "none" +display_on = "row" + +classes = ["cls1", "cls2"]$ +#onclick = "onclick_code('<lol>');"$ +onclick = "onclick_code('lol');"$ +title = "Title"$ +thclass = "th"$ +tdclass = "th"$ +content = "<tag> content </tag>"$ +tdattrs= "class='tdclass'"$ +is_open = True$ +option = "option"$ +icon = "icon"$ +value = "Testvalue"$ +view = {"name": "viewname"}$ +choices = ["c1", "c2"]$ +hidden = True$ +id = "id"$ +e = "error"$ +query = "Hallo \n Welt!"$ + ''' function_start = lambda x: '''
7 years, 9 months
1
0
0
0
Autorefactor: repaired bracket count.
by Roland Halbig
Module: check_mk Branch: master Commit: 50fe58790a3483c3d470d4c004cd3bfe57ee31ff URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=50fe58790a3483…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Thu Dec 15 13:45:15 2016 +0100 Autorefactor: repaired bracket count. Change-Id: I2cd274aed4c7e0cca7106df22f9c4a2fe58eabc6 --- tests/web/auto_refactor.py | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/tests/web/auto_refactor.py b/tests/web/auto_refactor.py index 7660e65..895ff96 100644 --- a/tests/web/auto_refactor.py +++ b/tests/web/auto_refactor.py @@ -125,13 +125,13 @@ def test_replace_inputs(): # this function does a big chunk of the refactoring for me def replace_tags(html, indent = 0): - # I want to refactor only lines with html.write if not html.lstrip(' ').startswith('html.write('): return html # unbalanced paranthesis indicates sth that goes across line border - if html.count('(') != html.count(')'): + no_comments = '\n'.join(re.sub('#.*', '', line) for line in html.split('\n')) + if no_comments.count('(') != no_comments.count(')'): return html html, rest = split_html(html) @@ -192,27 +192,29 @@ def replace_tags(html, indent = 0): return orig_html + "\n(new)" + html + "\n" + rest -import re -html = sys.argv[1] -if html.endswith('.py'): - whole_text = '' - with open(html, 'r') as rfile: - whole_text = "".join(line for line in rfile) - parts = whole_text.split("html.write(") - with open("refactored_file.py", "w") as wfile: - part = parts.pop(0) - wfile.write(part) - indent = 0 - while indent < len(part) and part[len(part) - 1 - indent] == ' ': - indent += 1 - for part in parts: - part = "html.write(" + part - wfile.write(replace_tags(part, indent)) + +if __name__ == "__main__": + + html = sys.argv[1] + if html.endswith('.py'): + whole_text = '' + with open(html, 'r') as rfile: + whole_text = "".join(line for line in rfile) + parts = whole_text.split("html.write(") + with open("refactored_file.py", "w") as wfile: + part = parts.pop(0) + wfile.write(part) indent = 0 while indent < len(part) and part[len(part) - 1 - indent] == ' ': indent += 1 -elif html == "test": - test_replace_inputs() -else: - print replace_tags(html) + for part in parts: + part = "html.write(" + part + wfile.write(replace_tags(part, indent)) + indent = 0 + while indent < len(part) and part[len(part) - 1 - indent] == ' ': + indent += 1 + elif html == "test": + test_replace_inputs() + else: + print replace_tags(html)
7 years, 9 months
1
0
0
0
4118 check_bi_aggr: changed check and WATO rule to support Kerberos auth
by Marcel Schulte
Module: check_mk Branch: master Commit: db258dbde1a7f8d43c42d4a0c9ca9807018c7aa2 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=db258dbde1a7f8…
Author: Marcel Schulte <ms(a)mathias-kettner.de> Date: Thu Dec 15 13:35:32 2016 +0100 4118 check_bi_aggr: changed check and WATO rule to support Kerberos auth Changed active check "check_bi_aggr" and the related WATO rule to support Kerberos authentication. For this to work Python modules "requests" and "requests_kerberos" are needed. These should be shipped with prepackaged CRE and CEE versions since werk #7612. Change-Id: Ib38fed9414cdae8f2770ea22defb13144efc7d58 --- .werks/4118 | 11 +++++++ ChangeLog | 1 + doc/treasures/active_checks/check_bi_aggr | 55 ++++++++++++++++++++----------- web/plugins/wato/active_checks.py | 1 + 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/.werks/4118 b/.werks/4118 new file mode 100644 index 0000000..44ef8f7 --- /dev/null +++ b/.werks/4118 @@ -0,0 +1,11 @@ +Title: check_bi_aggr: changed check and WATO rule to support Kerberos auth +Level: 1 +Component: checks +Compatible: compat +Version: 1.4.0i3 +Date: 1481804930 +Class: feature + +Changed active check "check_bi_aggr" and the related WATO rule to support Kerberos authentication. + +For this to work Python modules "requests" and "requests_kerberos" are needed. These should be shipped with prepackaged CRE and CEE versions since werk #7612. diff --git a/ChangeLog b/ChangeLog index 963671d..7dccb84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ * 4109 websphere_mq_instance, websphere_mq_instance.manager: new checks for Websphere MQ * 4110 netscaler_vserver: now lower levels for health are configurable * 4098 ups_cps_battery, ups_cps_battery.temp, ups_cps_inphase, ups_cps_outphase: Several checks to monitor CPS UPS devices + * 4118 check_bi_aggr: changed check and WATO rule to support Kerberos auth... * 3987 FIX: Check_MK Agent Access: Windows agent reported incorrect only from value * 3952 FIX: diskstat: fixed bug if multipath devices having an alias... * 3939 FIX: f5_bigip_conns: readded performance data and graphs... diff --git a/doc/treasures/active_checks/check_bi_aggr b/doc/treasures/active_checks/check_bi_aggr index d1c82a2..30e9ad5 100755 --- a/doc/treasures/active_checks/check_bi_aggr +++ b/doc/treasures/active_checks/check_bi_aggr @@ -24,13 +24,16 @@ # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301 USA. -import sys, getopt, urllib2, traceback +import sys, getopt, requests, traceback import os import time -# tell urllib2 not to honour "http(s)_proxy" env variables -urllib2.getproxies = lambda: {} +# tell requests not to honour "http(s)_proxy" env variables +proxies = { + 'http': None, + 'https': None, +} def usage(): sys.stderr.write(""" @@ -47,8 +50,8 @@ OPTIONS: -u USER User-ID of an automation user which is permitted to see all contents of the aggregation -s SECRET Automation secret of the user - -m AUTH_MODE Authentication mode, either "cookie", "basic" or "digest", - defaults to "cookie" + -m AUTH_MODE Authentication mode, either "cookie", "basic", "digest" + or "kerberos", defaults to "cookie" -t TIMEOUT HTTP connect timeout in seconds (Default: 60) -r track downtimes. This requires the hostname to be set. -n HOSTNAME The hostname for which this check is run. @@ -134,36 +137,50 @@ if track_downtime and not hostname: def init_auth(): + auth = None if username and password: - passwdmngr = urllib2.HTTPPasswordMgrWithDefaultRealm() - passwdmngr.add_password(None, base_url, username, password) - if auth_mode == 'digest': - authhandler = urllib2.HTTPDigestAuthHandler(passwdmngr) + if auth_mode == 'kerberos': + from requests_kerberos import HTTPKerberosAuth + + from subprocess import Popen, PIPE, check_call + kinit = Popen(["kinit", username], stdin=PIPE, stdout=PIPE, stderr=PIPE) + output, errors = kinit.communicate("%s\n" % password) + kinit.wait() + if kinit.returncode or errors: + sys.stderr.write("Error getting Kerberos Ticket:\n") + sys.stderr.write("stdout: %s\nstderr: %s\nrc: %s" % (output, errors, kinit.returncode)) + sys.exit(1) + + auth = HTTPKerberosAuth(principal=username) + elif auth_mode == 'digest': + auth = requests.auth.HTTPDigestAuth(username, password) else: - authhandler = urllib2.HTTPBasicAuthHandler(passwdmngr) - opener = urllib2.build_opener(authhandler) - urllib2.install_opener(opener) + auth = requests.auth.HTTPBasicAuth(username, password) + return auth url = "%s/check_mk/view.py" \ "?view_name=aggr_single_api" \ "&aggr_name=%s&output_format=python" % \ - (base_url.rstrip('/'), urllib2.quote(aggr_name)) + (base_url.rstrip('/'), aggr_name) -if auth_mode in ['basic', 'digest']: - init_auth() +auth = None +if auth_mode in ['basic', 'digest', 'kerberos']: + auth = init_auth() else: url += "&_username=%s&_secret=%s" % \ - (urllib2.quote(username), urllib2.quote(password)) + (username, password) if debug: sys.stderr.write('URL: %s\n' % url) try: - json = urllib2.urlopen(url, timeout = timeout).read() -except urllib2.socket.timeout: + r = requests.get(url, timeout=timeout, auth=auth, proxies=proxies) + r.raise_for_status() + json = r.text +except requests.Timeout: sys.stdout.write('ERROR: Socket timeout while opening URL: %s\n' % (url)) sys.exit(3) -except urllib2.URLError, e: +except requests.URLRequired, e: sys.stdout.write("UNKNOWN: %s\n" % e) sys.exit(3) except Exception, e: diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py index 894ff91..f71f205 100644 --- a/web/plugins/wato/active_checks.py +++ b/web/plugins/wato/active_checks.py @@ -1572,6 +1572,7 @@ register_rule(group, ('cookie', _('Form (Cookie) based')), ('basic', _('HTTP Basic')), ('digest', _('HTTP Digest')), + ('kerberos', _('Kerberos')), ], )), ("timeout", Integer(
7 years, 9 months
1
0
0
0
Fetched livestatus from downstream.
by Sven Panne
Module: check_mk Branch: master Commit: 3470524b5c6cd7202744381571c7d1d344f02cdb URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3470524b5c6cd7…
Author: Sven Panne <sp(a)mathias-kettner.de> Date: Thu Dec 15 11:33:13 2016 +0100 Fetched livestatus from downstream. Change-Id: I6b62d7e97ee9aa8d16f01c1ddf6122e8b13b7ecd --- livestatus/src/Column.h | 3 -- livestatus/src/CustomVarsDictColumn.h | 2 +- livestatus/src/DynamicColumn.h | 5 +-- .../src/DynamicEventConsoleReplicationColumn.cc | 8 ++--- .../src/DynamicEventConsoleReplicationColumn.h | 5 +-- livestatus/src/DynamicLogwatchFileColumn.cc | 13 ++++--- livestatus/src/DynamicLogwatchFileColumn.h | 5 +-- livestatus/src/HostFileColumn.cc | 6 ++-- livestatus/src/HostFileColumn.h | 5 +-- livestatus/src/NullColumn.h | 1 - livestatus/src/Query.cc | 42 ++++++++++------------ livestatus/src/Query.h | 15 ++++---- livestatus/src/Table.cc | 11 +++--- livestatus/src/Table.h | 9 ++--- livestatus/src/TableColumns.cc | 8 +++-- livestatus/src/TableEventConsole.cc | 2 +- livestatus/src/TableEventConsoleEvents.cc | 5 +-- livestatus/src/TableEventConsoleHistory.cc | 5 +-- livestatus/src/TableHosts.cc | 4 +-- livestatus/src/TableLog.cc | 5 +-- livestatus/src/TableLog.h | 3 +- livestatus/src/TableStateHistory.cc | 5 +-- livestatus/src/TableStateHistory.h | 3 +- 23 files changed, 89 insertions(+), 81 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=3470524b5c…
7 years, 9 months
1
0
0
0
Autorefactor: got auto_refactor.py von rh-refactoring-valuespec
by Roland Halbig
Module: check_mk Branch: master Commit: e084d75d3d95590d3dbdad0e8077c69bb68bf3b3 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e084d75d3d9559…
Author: Roland Halbig <rh(a)mathias-kettner.de> Date: Thu Dec 15 12:59:10 2016 +0100 Autorefactor: got auto_refactor.py von rh-refactoring-valuespec Change-Id: I8263eb9c5594dc959afc81bde4b2f8174aec18a3 Autorefactor: Added try catch block to return statement. Change-Id: Ia710e58108614c8aa34737c4dfa140b6ec68b702 --- tests/web/auto_refactor.py | 155 +++++++++++++++++++++++++++++++-------------- 1 file changed, 106 insertions(+), 49 deletions(-) diff --git a/tests/web/auto_refactor.py b/tests/web/auto_refactor.py index f5b0063..7660e65 100644 --- a/tests/web/auto_refactor.py +++ b/tests/web/auto_refactor.py @@ -4,17 +4,59 @@ from bs4 import BeautifulSoup as bs from bs4 import NavigableString +def append_to_html(html, indent, addendum): + return "%s\n%s%s" %(html, ' ' * indent, "%s" % addendum) + + +def split_html(text): + index = 1 + while index < len(text) and text[index - 1] != "(": + index += 1 + open_braces = 1 + while index < len(text) and open_braces > 0: + if text[index] == "(": + open_braces += 1 + elif text[index] == ")": + open_braces -= 1 + index += 1 + while index < len(text) and text[index] != "\n": + index += 1 + return text[:index], text[index:] + + +def stripper(x): + x = re.sub(r' %\s+\(.*', '', x) + index = len(x) - 1 + while index >= 0 and x[index] in ['n', ' ', ')', '"', '\'']: + if x[index] == 'n' and index > 0 and x[index - 1] == '\\': + index -= 1 + index -= 1 + return x[:index+1] + + +def preprocess_tag(tag_str): + index = 1 + while index + 1< len(tag_str): + if tag_str[index - 1] == '=' and tag_str[index] not in ['\"', '\'']: + next_index = index + 1 + while next_index < len(tag_str) and re.match(r'\w', tag_str[next_index]) is not None: + next_index += 1 + tag_str = tag_str[:index] + '\"' + tag_str[index:(next_index)] + '\"' + tag_str[next_index:] + index = next_index + 1 + else: + index += 1 + return tag_str + + def eval_tag(tag_str, next_one, next_inbetween): + skip_next = False children = list(bs(tag_str, 'html5lib').body.children) if tag_str[1] == '/': addendum = "html.close_%s()" % re.sub("<|[/]|>", '' , tag_str) -# elif '%' + 's' in tag_str: -# addendum = '' - elif children and not isinstance(children[0], NavigableString): tag_name = '' attrs = '' @@ -33,7 +75,7 @@ def eval_tag(tag_str, next_one, next_inbetween): attrs += "%s=\"%s\"" % (key, val) # See if we can close the tag right away - if next_one and next_one[1] == '/' and next_one == ("</%s>" % tag_name): + if next_one and next_one == ("</%s>" % tag_name): addendum = "html.%s(%s%s)" % (tag_name, next_inbetween, ", " + attrs if attrs else '') skip_next = True elif tag_name in ['br', 'hr', 'img']: @@ -42,45 +84,48 @@ def eval_tag(tag_str, next_one, next_inbetween): addendum = "html.open_%s(%s)" % (tag_name, attrs) else: tag_name = tag_str.lstrip(' ').lstrip('<').split(' ')[0].rstrip("/").rstrip(">") - attrs = tag_str.lstrip(' ').lstrip('<').rstrip(' ').rstrip('>').lstrip(tag_name) + attrs = tag_str.lstrip(' ').lstrip('<').rstrip(' ').rstrip('>').lstrip(tag_name).lstrip(' ') + attrs = re.sub(r'class=', "class_=", attrs) + attrs = re.sub(r'id=', "id_=", attrs) + attrs = re.sub(r'type=', "type_=", attrs) + attrs = re.sub(r'for=', "for_=", attrs) addendum = "html.open_%s(%s)" % (tag_name, attrs) return addendum, skip_next -def append_to_html(html, indent, addendum): - return "%s\n%s%s" %(html, ' ' * indent, "%s" % addendum) - - -def split_html(text): - index = 1 - while index < len(text) and text[index - 1] != "(": - index += 1 - open_braces = 1 - while index < len(text) and open_braces > 0: - if text[index] == "(": - open_braces += 1 - elif text[index] == ")": - open_braces -= 1 - index += 1 - while index < len(text) and text[index] != "\n": - index += 1 - return text[:index], text[index:] - +def replace_inputs(text, inputs): + for index, input in enumerate(inputs): + text = re.sub("%" + "s", '[[[%s]]]' % index, text, 1) + return text + + +def insert_inputs(text, inputs): + if not inputs: + return text + replacements = [] + text_index = 0 + for counter, input in enumerate(inputs): + if "_(" in input and input.count("(") > input.count(")"): + input += ")" + if "[[[%s]]]" % counter in text: + index = text.index("[[[%s]]]" % counter) + if text[:(index+1)].count('\"') + text[:(index+1)].count('\'') % 2 == 0: + text = re.sub(r"[[]{3}%s[]]{3}" % counter, input, text, 1) + else: + text = re.sub(r"[[]{3}%s[]]{3}" % counter, '%' + 's' + '\" % ' + input + "\"", text, 1) + return text -def stripper(x): - x = re.sub(r' %\s+\(.*', '', x) - index = len(x) - 1 - while index >= 0 and x[index] in ['n', ' ', ')', '"', '\'']: - if x[index] == 'n' and index > 0 and x[index - 1] == '\\': - index -= 1 - index -= 1 - return x[:index+1] +def test_replace_inputs(): + text = "<tag class=\"ein %s\" id=%s>%s</tag>" + inputs = ["test", "id", "Hallo Welt!"] + print replace_inputs(text, inputs) # this function does a big chunk of the refactoring for me def replace_tags(html, indent = 0): + # I want to refactor only lines with html.write if not html.lstrip(' ').startswith('html.write('): return html @@ -93,24 +138,24 @@ def replace_tags(html, indent = 0): orig_html = html # strip all comments - html = re.sub(r'#.*', '', html) - - if len(html.split(" % ")) == 2: - html, string_input = html.split(" % ") - string_input = string_input.lstrip("(").rstrip("$").rstrip("\n").rstrip(' ').rstrip(")") - for input in string_input.split(","): - if ("%" + "s") in html: - html = re.sub("%" + "s", input, html, 1) + inputs = [] + if " % " in html or ' %\n' in html: + if " % " in html: + html, string_input = html.split(" % ") + else: + html, string_input = html.split(" %\n") + string_input = string_input.lstrip(' ').lstrip("(").rstrip("$").rstrip("\n").rstrip(' ').rstrip(")") + inputs = string_input.split(",") + html = replace_inputs(html, inputs) + ")" tags = re.findall(r'<[^<]*>', html) - if len(tags) == 0: - return orig_html + rest - inbetween = re.split(r'<[^<]*>', re.sub(r'\s*html\.write\([\'|"]?', '', html, 1)) inbetween = map(stripper, inbetween) - html = orig_html + "\n(new)" + if len(tags) == 0: + return orig_html + rest + html = '' if inbetween[0].strip(' ') not in ['', '\n']: html = append_to_html(html, indent, "html.write(%s)" % inbetween[0]) @@ -118,24 +163,34 @@ def replace_tags(html, indent = 0): counter = 0 skip_next = False while counter < len(tags): - tag_str = tags[counter] + tag_str = preprocess_tag(tags[counter]) next_one = tags[counter + 1] if counter + 1 < len(tags) else None addendum, skip_next = eval_tag(tag_str, next_one, inbetween[counter + 1]) - if not skip_next and addendum.strip(' '): - html = append_to_html(html, indent, addendum) + html = append_to_html(html, indent, addendum) counter += 1 if not skip_next and inbetween[counter].strip(' ') not in ['', '\n']: html = append_to_html(html, indent, "html.write(%s)" % inbetween[counter]) + elif skip_next and addendum.strip(' '): + counter += 1 + + html = insert_inputs(html, inputs) + for index, input in enumerate(inputs): + if "[[[%s]]]" % index in html: + html = re.sub("[[[%s]]]" % index, input, html) + try: - return html + "\n(/new)" + rest + return orig_html + "\n(new)" + html + "\n" + rest except: + print "orig_html:\n", orig_html + print "__________________________________________" print "html:\n", html print "__________________________________________" print "rest:\n", rest - return html + "\n(/new)" + rest + return orig_html + "\n(new)" + html + "\n" + rest + import re html = sys.argv[1] @@ -156,6 +211,8 @@ if html.endswith('.py'): indent = 0 while indent < len(part) and part[len(part) - 1 - indent] == ' ': indent += 1 +elif html == "test": + test_replace_inputs() else: print replace_tags(html)
7 years, 9 months
1
0
0
0
EC: Use livestatus.LocalConnection() when fetching timeperiods
by Mathias Kettner
Module: check_mk Branch: master Commit: 8d945e1c3b9747cae7b615b4d5607f764eec8f86 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8d945e1c3b9747…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Thu Dec 15 12:09:21 2016 +0100 EC: Use livestatus.LocalConnection() when fetching timeperiods This was the last place where a manual barebone livestatus access was eliminated. All accesses are done with the livestatus module now. Change-Id: Ia4cefbb1ccf2af0434ad80d0642469caa89775e5 --- bin/mkeventd | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/bin/mkeventd b/bin/mkeventd index db30bb2..b23b713 100755 --- a/bin/mkeventd +++ b/bin/mkeventd @@ -31,8 +31,6 @@ # creating objects. Or at least update the documentation. It is not clear # which fields are mandatory for the events. -# TODO: Refactor livestatus to use the livestatus module - import socket, os, time, sys, getopt, signal, thread, pprint, re, \ select, subprocess, stat, string import traceback @@ -521,31 +519,6 @@ def initialize_snmp_credentials(): securityEngineId=snmp_v2c.OctetString(hexValue=engine_id) ) -#. -# .--Livestatus----------------------------------------------------------. -# | _ _ _ _ | -# | | | (_)_ _____ ___| |_ __ _| |_ _ _ ___ | -# | | | | \ \ / / _ \/ __| __/ _` | __| | | / __| | -# | | |___| |\ V / __/\__ \ || (_| | |_| |_| \__ \ | -# | |_____|_| \_/ \___||___/\__\__,_|\__|\__,_|___/ | -# | | -# +----------------------------------------------------------------------+ -# | Livestatus connection | -# '----------------------------------------------------------------------' - -def livestatus_query(query): - try: - livesock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - livesock.connect(g_livestatus_socket) - livesock.sendall(query) - livesock.shutdown(socket.SHUT_WR) - return livesock.recv(10000000) - except Exception: - # TODO: This exception handler is (maybe) to generic - log("Unable to contact monitoring core") - if opt_debug: - raise - #. # .--Timeperiods---------------------------------------------------------. @@ -568,13 +541,11 @@ def update_timeperiods(): if g_timeperiods != None and int(time.time()) / 60 == g_last_timeperiod_update: return # only update once a minute - log("Updating timeperiod information") try: - answer = livestatus_query("GET timeperiods\nColumns: name alias in\n") - table = [ line.split(';') for line in answer.split('\n')[:-1] ] + table = livestatus.LocalConnection().query("GET timeperiods\nColumns: name alias in") new_timeperiods = {} for tpname, alias, isin in table: - new_timeperiods[tpname] = (alias, isin == '1' and True or False) + new_timeperiods[tpname] = (alias, bool(isin)) g_timeperiods = new_timeperiods g_last_timeperiod_update = int(time.time()) / 60 except Exception, e:
7 years, 9 months
1
0
0
0
EC: Use livestatus.LocalConnection() when fetching host contacts
by Mathias Kettner
Module: check_mk Branch: master Commit: eebee66c5ae36f3f30fa340dcf2649b18935f38d URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eebee66c5ae36f…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Thu Dec 15 12:02:45 2016 +0100 EC: Use livestatus.LocalConnection() when fetching host contacts Change-Id: I2940711a2cb105526d114a680f90ba3759c4946d --- bin/mkeventd | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/bin/mkeventd b/bin/mkeventd index 2cc26d1..db30bb2 100755 --- a/bin/mkeventd +++ b/bin/mkeventd @@ -4066,28 +4066,23 @@ def fetch_contacts_of_group_from_livestatus(group_name): # None, None -> Host could not be found # [], [] -> Host found but has no contacts/contactgroups -def fetch_contacts_and_groups_of_host_from_livestatus(host): +def fetch_contacts_and_groups_of_host_from_livestatus(host_name): # TODO: Matching von Hostnamen muss identisch sein zu dem im CMC try: - answer = livestatus_query("GET hosts\nFilter: host_name = %s\n" - "Columns: contacts contact_groups\nOutputFormat: python\n" % host) - if not answer: - return None, None - - data = eval(answer) - if not data: - return None, None - - contacts, groups = data[0] + contacts, groups = livestatus.LocalConnection().query_row( + "GET hosts\nFilter: host_name = %s\nColumns: contacts contact_groups" % host_name) if "check-mk-notify" in contacts: # Remove artifical contact used for rule based notifications contacts.remove("check-mk-notify") return contacts, groups - except: # TODO: Make this more specific + except livestatus.MKLivestatusNotFoundError, e: + return None, None # Host not found + + except Exception, e: + log("Cannot determine contacts and contact groups of host %s: %s" % (host_name, e)) if opt_debug: raise - - return None, None + return None, None def substitute_event_tags(text, event):
7 years, 9 months
1
0
0
0
EC: Use livestatus.LocalConnection() when fetching contact groups
by Mathias Kettner
Module: check_mk Branch: master Commit: 8c1ba1e88988f7c5fd63f36a73b346af99697e1f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8c1ba1e88988f7…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Thu Dec 15 11:55:28 2016 +0100 EC: Use livestatus.LocalConnection() when fetching contact groups Change-Id: I7bf22656cc7b3ffb116d7eef4c6f294cd9d94444 --- bin/mkeventd | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/mkeventd b/bin/mkeventd index 3fff2e2..2cc26d1 100755 --- a/bin/mkeventd +++ b/bin/mkeventd @@ -3994,7 +3994,7 @@ def add_rbn_contact_information(context, host, contact_groups, contact_groups_no if group_contacts == None: group_contacts = set([]) - group_contacts.update(fetch_contacts_of_group_from_livestatus(group_name)) + group_contacts.update(contacts) if group_contacts != None: group_contacts = list(group_contacts) @@ -4050,14 +4050,14 @@ def core_has_notifications_disabled(event): def fetch_contacts_of_group_from_livestatus(group_name): try: - answer = livestatus_query("GET contactgroups\nFilter: name = %s\n" - "Columns: members\nOutputFormat: python\n" % group_name) - if answer: - contacts = eval(answer)[0][0] - if "check-mk-notify" in contacts: # Remove artifical contact used for rule based notifications - contacts.remove("check-mk-notify") - return contacts - except: # TODO: Make this more specific + contacts = livestatus.LocalConnection().query_value( + "GET contactgroups\nFilter: name = %s\nColumns: members" % group_name) + if "check-mk-notify" in contacts: # Remove artifical contact used for rule based notifications + contacts.remove("check-mk-notify") + return contacts + + except Exception, e: + log("Cannot determine contacts of group %s: %s" % (group_name, e)) if opt_debug: raise
7 years, 9 months
1
0
0
0
EC: Use livestatus.LocalConnection() instead of livestatus_query for notifications check
by Mathias Kettner
Module: check_mk Branch: master Commit: f116d03d3f5eee5e6d308461dba024e734b0b96b URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f116d03d3f5eee…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Thu Dec 15 11:49:12 2016 +0100 EC: Use livestatus.LocalConnection() instead of livestatus_query for notifications check Change-Id: Ic7bd4703b80289020e566185bf031a54471a2320 --- bin/mkeventd | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/bin/mkeventd b/bin/mkeventd index cbc04fb..3fff2e2 100755 --- a/bin/mkeventd +++ b/bin/mkeventd @@ -39,6 +39,7 @@ import traceback from cmk.regex import regex, is_regex import cmk.defines as defines import cmk.daemon +import livestatus try: import simplejson as json @@ -4037,15 +4038,12 @@ def add_rbn_contact_information(context, host, contact_groups, contact_groups_no def core_has_notifications_disabled(event): try: - answer = livestatus_query("GET status\nColumns: enable_notifications\nOutputFormat: python\n") - if answer: - notifications_enabled = eval(answer) - if not notifications_enabled[0][0]: - log("Notifications are currently disabled. Skipped notification for event %d" % event["id"]) - return True - except: - # On any error, assume that notifications are enabled - pass + notifications_enabled = livestatus.LocalConnection().query_value("GET status\nColumns: enable_notifications") + if not notifications_enabled: + log("Notifications are currently disabled. Skipped notification for event %d" % event["id"]) + return True + except Exception, e: + log("Cannot determine wether notifcations are enabled in core: %s. Assuming YES." % e) return False
7 years, 9 months
1
0
0
0
EC notifications: use "Event Console" as application, not "Unset"
by Mathias Kettner
Module: check_mk Branch: master Commit: 47c7c43a652e37af9449e8e17b28e51a91dd2325 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=47c7c43a652e37…
Author: Mathias Kettner <mk(a)mathias-kettner.de> Date: Thu Dec 15 11:44:44 2016 +0100 EC notifications: use "Event Console" as application, not "Unset" Change-Id: I3320d65612af70d464605dd19eae374978ae10d1 --- bin/mkeventd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mkeventd b/bin/mkeventd index 58f8147..cbc04fb 100755 --- a/bin/mkeventd +++ b/bin/mkeventd @@ -3931,7 +3931,7 @@ def do_notify(event, username=None, is_cancelling=False): "SERVICEACKCOMMENT": "", "SERVICEATTEMPT": "1", "SERVICECHECKCOMMAND": event["rule_id"] == None and "ec-internal" or "ec-rule-" + event["rule_id"], - "SERVICEDESC": event["application"] or "Unset", + "SERVICEDESC": event["application"] or "Event Console", "SERVICENOTIFICATIONNUMBER": "1", "SERVICEOUTPUT": event["text"], "SERVICEPERFDATA": "",
7 years, 9 months
1
0
0
0
← Newer
1
...
18
19
20
21
22
23
24
...
40
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
32
33
34
35
36
37
38
39
40
Results per page:
10
25
50
100
200