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
November 2018
----- 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
15 participants
465 discussions
Start a n
N
ew thread
Add more python modules to import integration test
by Lars Michelsen
Module: check_mk Branch: master Commit: 7e05cb93e5a3eac6844c6e354e7c0eadc3344ba3 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7e05cb93e5a3ea…
Author: Lars Michelsen <lm(a)mathias-kettner.de> Date: Fri Nov 23 15:28:32 2018 +0100 Add more python modules to import integration test Change-Id: I6f963c3724c0dd8d0f8836e59ef982ddd1d4c5b8 --- tests/integration/omd/test_python.py | 66 ++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 22 deletions(-) diff --git a/tests/integration/omd/test_python.py b/tests/integration/omd/test_python.py index e3c016f..40b834e 100644 --- a/tests/integration/omd/test_python.py +++ b/tests/integration/omd/test_python.py @@ -2,30 +2,28 @@ # encoding: utf-8 import os -import sys import subprocess +import pytest + def test_01_python_interpreter_exists(site): assert os.path.exists(site.root + "/bin/python") def test_02_python_interpreter_path(site): - p = site.execute(["which", "python"], - stdout=subprocess.PIPE) + p = site.execute(["which", "python"], stdout=subprocess.PIPE) path = p.stdout.read().strip() assert path == "/omd/sites/%s/bin/python" % site.id def test_03_python_interpreter_version(site): - p = site.execute(["python", "-V"], - stderr=subprocess.PIPE) + p = site.execute(["python", "-V"], stderr=subprocess.PIPE) version = p.stderr.read() assert version.startswith("Python 2.7.15") def test_03_python_path(site): - p = site.execute(["python", "-c", "import sys ; print(sys.path)"], - stdout=subprocess.PIPE) + p = site.execute(["python", "-c", "import sys ; print(sys.path)"], stdout=subprocess.PIPE) sys_path = eval(p.stdout.read()) assert sys_path[0] == "" assert site.root + "/local/lib/python" in sys_path @@ -42,28 +40,52 @@ def test_01_pip_exists(site): def test_02_pip_path(site): - p = site.execute(["which", "pip"], - stdout=subprocess.PIPE) + p = site.execute(["which", "pip"], stdout=subprocess.PIPE) path = p.stdout.read().strip() assert path == "/omd/sites/%s/bin/pip" % site.id def test_03_pip_interpreter_version(site): - p = site.execute(["pip", "-V"], - stdout=subprocess.PIPE) + p = site.execute(["pip", "-V"], stdout=subprocess.PIPE) version = p.stdout.read() assert version.startswith("pip 18.1") -def test_python_modules(site): - test_modules = [ - "netsnmp", - "pysphere", - "ldap", - "cryptography", - ] - +# TODO: Improve this test to automatically adapt the expected modules from our Pipfile +(a)pytest.mark.parametrize("module_name", [ + "netsnmp", + "pysphere", + "ldap", + "OpenSSL", + "cryptography", + "pysmi", + "pysnmp", + "pymssql", + "ldap", + "MySQLdb", + "psycopg2", + "dicttoxml", + "enum", + "PIL", + "reportlab", + "PyPDF2", + "psutil", + "ipaddress", + "netifaces", + "requests", + "paramiko", + "pyghmi", + "typing", + "pathlib2", + "dateutil", + "snap7", + "rrdtool", + "azure.mgmt.monitor", + "werkzeug", + "boto3", + "kubernetes", +]) +def test_python_modules(site, module_name): import importlib - for test_module_name in test_modules: - module = importlib.import_module(test_module_name) - assert module.__file__.startswith(site.root) + module = importlib.import_module(module_name) + assert module.__file__.startswith(site.root)
5 years, 10 months
1
0
0
0
k8s_resources: use capacity for inventory
by Tom Baerwinkel
Module: check_mk Branch: master Commit: 88f8e34909b9785504750663b29ef1d43f708b66 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=88f8e34909b978…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de> Date: Wed Nov 21 16:54:13 2018 +0100 k8s_resources: use capacity for inventory The checks k8s_resources.pods, k8s_resources.memory and k8s_resources.cpu now discover services if a capacity is given. Change-Id: Id6a1f36416137103b66c1eca4c7c235faaf5f31c --- checks/k8s_resources | 10 ++++---- .../datasets/k8s_resources_regression.py | 27 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/checks/k8s_resources b/checks/k8s_resources index 01f2f1f..826e24e 100644 --- a/checks/k8s_resources +++ b/checks/k8s_resources @@ -36,7 +36,7 @@ check_info['k8s_resources'] = { def inventory_k8s_pod_resources(parsed): - if parsed.get('allocations', {}).get('pods'): + if parsed.get('capacity', {}).get('pods'): return [(None, {})] @@ -56,7 +56,7 @@ check_info['k8s_resources.pods'] = { def inventory_k8s_cpu_resources(parsed): - if parsed.get('requests', {}).get('cpu'): + if parsed.get('capacity', {}).get('cpu'): return [(None, {})] @@ -65,7 +65,7 @@ def check_k8s_cpu_resources(_no_item, _no_params, parsed): yield 0, 'Request: %.3f' % request limit = parsed.get('limits', {}).get('cpu') - if limit is not None: + if limit: yield 0, 'Limit: %.3f' % limit capacity = parsed.get('capacity', {}).get('cpu', 0.0) @@ -80,7 +80,7 @@ check_info['k8s_resources.cpu'] = { def inventory_k8s_mem_resources(parsed): - if parsed.get('requests', {}).get('memory'): + if parsed.get('capacity', {}).get('memory'): return [(None, {})] @@ -89,7 +89,7 @@ def check_k8s_mem_resources(_no_item, _no_params, parsed): yield 0, 'Request: %s' % get_bytes_human_readable(request) limit = parsed.get('limits', {}).get('memory') - if limit is not None: + if limit: yield 0, 'Limit: %s' % get_bytes_human_readable(limit) capacity = parsed.get('capacity', {}).get('memory', 0.0) diff --git a/tests/unit/checks/generictests/datasets/k8s_resources_regression.py b/tests/unit/checks/generictests/datasets/k8s_resources_regression.py new file mode 100644 index 0000000..be6f4e6 --- /dev/null +++ b/tests/unit/checks/generictests/datasets/k8s_resources_regression.py @@ -0,0 +1,27 @@ +checkname = 'k8s_resources' + +info = [[ + u'{"capacity": {"pods": 110, "cpu": 1.0, "memory": 609845248.0}, "requests": {"cpu": 0.2, "memory": 0.0}, "limits": {"cpu": 0.5, "memory": 0.0}, "allocations": {}}' +]] + +discovery = { + 'cpu': [(None, {})], + 'memory': [(None, {})], + 'pods': [(None, {})], +} + +checks = { + 'cpu': [(None, 'default', [ + (0, 'Request: 0.200', []), + (0, 'Limit: 0.500', []), + (0, 'Capacity: 1.000', []), + ])], + 'memory': [(None, 'default', [ + (0, 'Request: 0.00 B', []), + (0, 'Capacity: 581.59 MB', []), + ])], + 'pods': [(None, 'default', [ + (0, 'Pods: 0', []), + (0, 'Capacity: 110', []), + ])], +}
5 years, 10 months
1
0
0
0
various minor azure fixes
by Moritz Kiemer
Module: check_mk Branch: master Commit: 301a242b39793625e3b0ec19f8318f7e0f7f8a34 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=301a242b397936…
Author: Moritz Kiemer <mo(a)mathias-kettner.de> Date: Fri Nov 23 14:53:25 2018 +0100 various minor azure fixes Change-Id: I12bbef3e35d75a047f077f7117286d458c20aa3a --- agents/special/agent_azure | 9 ++++----- checks/azure_agent_info | 38 ++++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/agents/special/agent_azure b/agents/special/agent_azure index b0ea323..25bcf03 100755 --- a/agents/special/agent_azure +++ b/agents/special/agent_azure @@ -142,11 +142,10 @@ def parse_arguments(argv): parser.add_argument( "--dump-config", action="store_true", help='''Dump parsed configuration and exit''') parser.add_argument( - "--pjoin-timeout", + "--timeout", default=10, type=int, - help='''Timeout for process joining in seconds - (default 10)''') + help='''Timeout for individual processes in seconds (default 10)''') parser.add_argument( "--piggyback-vms", default="", @@ -664,9 +663,9 @@ def main(argv=None): write_groups(resources) - args = ((resource, client, config) for resource in resources) + func_args = ((resource, client, config) for resource in resources) map_ = map if args.sequential else AsyncMapper(args.timeout, args.debug) - for sections in map_(process_resource, args): + for sections in map_(process_resource, func_args): for section in sections: section.write() diff --git a/checks/azure_agent_info b/checks/azure_agent_info index ff0ce2a..dc948d5 100644 --- a/checks/azure_agent_info +++ b/checks/azure_agent_info @@ -33,27 +33,41 @@ factory_settings['azure_agent_info_levels'] = { } +def _update_remaining_reads(parsed, value): + try: + value = int(value) + except ValueError: + pass + + current = parsed.get('remaining-reads', '_some_string') + if isinstance(current, str): + parsed['remaining-reads'] = value + return + parsed['remaining-reads'] = min(current, value) + + def parse_azure_agent_info(info): parsed = {} for row in info: - k, v = row[0], json.loads(_AZURE_AGENT_SEPARATOR.join(row[1:])) - - if k == 'remaining-reads': - try: - v = int(v) - v = min(int(parsed.get(k, 'fail')), v) - except ValueError: - pass - parsed[k] = v + key = row[0] + value = _AZURE_AGENT_SEPARATOR.join(row[1:]) + + if key == 'remaining-reads': + _update_remaining_reads(parsed, value) continue - elif k == 'issue': + try: + value = json.loads(value) + except ValueError: + pass + + if key == 'issue': issues = parsed.setdefault('issues', {}) - issues.setdefault(v['type'], []).append(v) + issues.setdefault(value['type'], []).append(value) continue - parsed.setdefault(k, []).append(v) + parsed.setdefault(key, []).append(value) return parsed
5 years, 10 months
1
0
0
0
Moved last snapin wiki to dedicated module and removed shipped.py
by Kenneth Okoh
Module: check_mk Branch: master Commit: 1157921552cfd36bab8c4d8330ad886fe0de2e9a URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1157921552cfd3…
Author: Kenneth Okoh <ko(a)mathias-kettner.de> Date: Thu Nov 22 16:24:10 2018 +0100 Moved last snapin wiki to dedicated module and removed shipped.py Change-Id: I75f6f908519c47b526b50568aa2812661d0d828f --- cmk/gui/plugins/sidebar/shipped.py | 194 ------------------------------------- cmk/gui/plugins/sidebar/wiki.py | 179 ++++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 194 deletions(-) Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=1157921552…
5 years, 10 months
1
0
0
0
Refactored wiki snapin to new snapin API
by Kenneth Okoh
Module: check_mk Branch: master Commit: 7edb80277e1350750e6cf96d0b17761cb7aae373 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7edb80277e1350…
Author: Kenneth Okoh <ko(a)mathias-kettner.de> Date: Thu Nov 22 16:27:25 2018 +0100 Refactored wiki snapin to new snapin API Change-Id: I8ea63338f620fe678c7cb5ee355703ce4d643b78 --- cmk/gui/plugins/sidebar/wiki.py | 264 +++++++++++++++++++++------------------- 1 file changed, 137 insertions(+), 127 deletions(-) diff --git a/cmk/gui/plugins/sidebar/wiki.py b/cmk/gui/plugins/sidebar/wiki.py index 2f71204..1863dd2 100644 --- a/cmk/gui/plugins/sidebar/wiki.py +++ b/cmk/gui/plugins/sidebar/wiki.py @@ -41,139 +41,149 @@ import cmk.gui.config as config from cmk.gui.i18n import _ from cmk.gui.globals import html from cmk.gui.plugins.sidebar import ( - sidebar_snapins, + SidebarSnapin, + snapin_registry, bulletlink, simplelink, ) -def render_wiki(): - filename = cmk.paths.omd_root + '/var/dokuwiki/data/pages/sidebar.txt' - html.javascript(""" - function wiki_search() - { - var oInput = document.getElementById('wiki_search_field'); - top.frames["main"].location.href = - "/%s/wiki/doku.php?do=search&id=" + escape(oInput.value); - } - """ % config.omd_site()) - - html.open_form(id_="wiki_search", onsubmit="wiki_search();") - html.input(id_="wiki_search_field", type_="text", name="wikisearch") - html.icon_button("#", _("Search"), "wikisearch", onclick="wiki_search();") - html.close_form() - html.div('', id_="wiki_side_clear") - - start_ul = True - ul_started = False - try: - title = None - for line in file(filename).readlines(): - line = line.strip() - if line == "": - if ul_started == True: - html.end_foldable_container() - start_ul = True - ul_started = False - elif line.endswith(":"): - title = line[:-1] - elif line == "----": - pass - # html.br() - - elif line.startswith("*"): - if start_ul == True: - if title: - html.begin_foldable_container("wikisnapin", title, True, title, indent=True) +(a)snapin_registry.register +class Wiki(SidebarSnapin): + @staticmethod + def type_name(): + return "wiki" + + @classmethod + def title(cls): + return _("Wiki") + + @classmethod + def description(cls): + return _("Shows the Wiki Navigation of the OMD Site") + + def show(self): + filename = cmk.paths.omd_root + '/var/dokuwiki/data/pages/sidebar.txt' + html.javascript(""" + function wiki_search() + { + var oInput = document.getElementById('wiki_search_field'); + top.frames["main"].location.href = + "/%s/wiki/doku.php?do=search&id=" + escape(oInput.value); + } + """ % config.omd_site()) + + html.open_form(id_="wiki_search", onsubmit="wiki_search();") + html.input(id_="wiki_search_field", type_="text", name="wikisearch") + html.icon_button("#", _("Search"), "wikisearch", onclick="wiki_search();") + html.close_form() + html.div('', id_="wiki_side_clear") + + start_ul = True + ul_started = False + try: + title = None + for line in file(filename).readlines(): + line = line.strip() + if line == "": + if ul_started == True: + html.end_foldable_container() + start_ul = True + ul_started = False + elif line.endswith(":"): + title = line[:-1] + elif line == "----": + pass + # html.br() + + elif line.startswith("*"): + if start_ul == True: + if title: + html.begin_foldable_container( + "wikisnapin", title, True, title, indent=True) + else: + html.open_ul() + start_ul = False + ul_started = True + + erg = re.findall(r'\[\[(.*)\]\]', line) + if len(erg) == 0: + continue + erg = erg[0].split('|') + if len(erg) > 1: + link = erg[0] + name = erg[1] else: - html.open_ul() - start_ul = False - ul_started = True - - erg = re.findall(r'\[\[(.*)\]\]', line) - if len(erg) == 0: - continue - erg = erg[0].split('|') - if len(erg) > 1: - link = erg[0] - name = erg[1] - else: - link = erg[0] - name = erg[0] + link = erg[0] + name = erg[0] - if link.startswith("http://") or link.startswith("https://"): - simplelink(name, link, "_blank") - else: - erg = name.split(':') - if len(erg) > 0: - name = erg[-1] + if link.startswith("http://") or link.startswith("https://"): + simplelink(name, link, "_blank") else: - name = erg[0] - bulletlink(name, "/%s/wiki/doku.php?id=%s" % (config.omd_site(), link)) - - else: - html.write_text(line) - - if ul_started == True: - html.close_ul() - except IOError: - sidebar = html.render_a( - "sidebar", - href="/%s/wiki/doku.php?id=%s" % (config.omd_site(), _("sidebar")), - target="main") - html.write_html("<p>To get a navigation menu, you have to create a %s in your wiki first.</p>"\ - % sidebar) - - -sidebar_snapins["wiki"] = { - "title": _("Wiki"), - "description": _("Shows the Wiki Navigation of the OMD Site"), - "render": render_wiki, - "allowed": ["admin", "user", "guest"], - "styles": """ - #snapin_container_wiki div.content { - font-weight: bold; - color: white; - } - - #snapin_container_wiki div.content p { - font-weight: normal; - } - - #wiki_navigation { - text-align: left; - } - - #wiki_search { - width: 232px; - padding: 0; - } - - #wiki_side_clear { - clear: both; - } - - #wiki_search img.iconbutton { - width: 33px; - height: 26px; - margin-top: -25px; - left: 196px; - float: left; - position: relative; - z-index:100; - } - - #wiki_search input { - margin: 0; - padding: 0px 5px; - font-size: 8pt; - width: 194px; - height: 25px; - background-image: url("images/quicksearch_field_bg.png"); - background-repeat: no-repeat; - -moz-border-radius: 0px; - border-style: none; - float: left; - } - """ + erg = name.split(':') + if len(erg) > 0: + name = erg[-1] + else: + name = erg[0] + bulletlink(name, "/%s/wiki/doku.php?id=%s" % (config.omd_site(), link)) + + else: + html.write_text(line) + + if ul_started == True: + html.close_ul() + except IOError: + sidebar = html.render_a( + "sidebar", + href="/%s/wiki/doku.php?id=%s" % (config.omd_site(), _("sidebar")), + target="main") + html.write_html("<p>To get a navigation menu, you have to create a %s in your wiki first.</p>"\ + % sidebar) + + def styles(self): + return """ +#snapin_container_wiki div.content { + font-weight: bold; + color: white; +} + +#snapin_container_wiki div.content p { + font-weight: normal; +} + +#wiki_navigation { + text-align: left; +} + +#wiki_search { + width: 232px; + padding: 0; +} + +#wiki_side_clear { + clear: both; +} + +#wiki_search img.iconbutton { + width: 33px; + height: 26px; + margin-top: -25px; + left: 196px; + float: left; + position: relative; + z-index:100; +} + +#wiki_search input { + margin: 0; + padding: 0px 5px; + font-size: 8pt; + width: 194px; + height: 25px; + background-image: url("images/quicksearch_field_bg.png"); + background-repeat: no-repeat; + -moz-border-radius: 0px; + border-style: none; + float: left; } +"""
5 years, 10 months
1
0
0
0
Refactored custom link snapin to new snapin API and updated links
by Kenneth Okoh
Module: check_mk Branch: master Commit: 50dff3ddde6af1c83f8ff5d833bd4f4cb163445f URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=50dff3ddde6af1…
Author: Kenneth Okoh <ko(a)mathias-kettner.de> Date: Thu Nov 22 16:17:12 2018 +0100 Refactored custom link snapin to new snapin API and updated links Change-Id: Iaaaa4ca9bed919a0d98a8886755cfe1712931c74 --- cmk/gui/plugins/config/base.py | 19 +++--- cmk/gui/plugins/sidebar/custom_links.py | 107 ++++++++++++++++++-------------- 2 files changed, 69 insertions(+), 57 deletions(-) diff --git a/cmk/gui/plugins/config/base.py b/cmk/gui/plugins/config/base.py index 1dd884a..46a160b 100644 --- a/cmk/gui/plugins/config/base.py +++ b/cmk/gui/plugins/config/base.py @@ -152,7 +152,6 @@ custom_links = {} # Links for everyone custom_links['guest'] = [ - ("Classical Nagios GUI", "../nagios/", "icon_home.png"), ("Addons", True, [ ("NagVis", "../nagvis/", "icon_nagvis.png"), ]), @@ -161,19 +160,19 @@ custom_links['guest'] = [ # The members of the role 'user' get the same links as the guests # but some in addition custom_links['user'] = custom_links['guest'] + [("Open Source Components", False, [ - ("Check_MK", "
http://mathias-kettner.com/check_mk.html
", None, "_blank"), - ("Nagios", "
http://www.nagios.org/
", None, "_blank"), - ("PNP4Nagios", "
http://pnp4nagios.org/
", None, "_blank"), - ("NagVis", "
http://nagvis.org/
", None, "_blank"), - ("RRDTool", "
http://oss.oetiker.ch/rrdtool/
", None, "_blank"), + ("Check_MK", "
https://mathias-kettner.com
", None, "_blank"), + ("Nagios", "
https://www.nagios.org/
", None, "_blank"), + ("PNP4Nagios", "
https://pnp4nagios.org/
", None, "_blank"), + ("NagVis", "
https://nagvis.org/
", None, "_blank"), + ("RRDTool", "
https://oss.oetiker.ch/rrdtool/
", None, "_blank"), ])] # The admins yet get further links custom_links['admin'] = custom_links['user'] + [("Support", False, [ - ("Mathias Kettner", "
http://mathias-kettner.com/
"), - ("Check_MK Mailinglists", "
http://mathias-kettner.com/check_mk_lists.html
"), - ("Check_MK Exchange", "
http://exchange.check-mk.org/
", None, "_blank"), - ("Monitoring Portal (German)", "
http://monitoring-portal.org
", None, "_blank"), + ("Mathias Kettner", "
https://mathias-kettner.com/
"), + ("Check_MK Mailinglists", "
https://mathias-kettner.com/community.php
"), + ("Check_MK Exchange", "
https://mathias-kettner.com/check_mk-exchange.php
", None, "_blank"), + ("Monitoring Portal (German)", "
https://monitoring-portal.org
", None, "_blank"), ])] # __ __ _ diff --git a/cmk/gui/plugins/sidebar/custom_links.py b/cmk/gui/plugins/sidebar/custom_links.py index 49dfb7c..45edab4 100644 --- a/cmk/gui/plugins/sidebar/custom_links.py +++ b/cmk/gui/plugins/sidebar/custom_links.py @@ -29,62 +29,76 @@ import cmk.gui.config as config from cmk.gui.htmllib import HTML from cmk.gui.i18n import _ from cmk.gui.globals import html -from cmk.gui.plugins.sidebar import sidebar_snapins, simplelink +from cmk.gui.plugins.sidebar import ( + SidebarSnapin, + snapin_registry, + simplelink, +) -def render_custom_links(): - links = config.custom_links.get(config.user.baserole_id) - if not links: - html.write_text((_( - "Please edit <tt>%s</tt> in order to configure which links are shown in this snapin.") % - (cmk.paths.default_config_dir + "/multisite.mk")) + "\n") - return +(a)snapin_registry.register +class CustomLinks(SidebarSnapin): + @staticmethod + def type_name(): + return "custom_links" - def render_list(ids, links): - n = 0 - for entry in links: - n += 1 - try: - if isinstance(entry[1], type(True)): - idss = ids + [str(n)] - id_ = '/'.join(idss) - html.begin_foldable_container( - "customlinks", id_, isopen=entry[1], title=entry[0]) - render_list(idss, entry[2]) - html.end_foldable_container() - elif isinstance(entry[1], str): - frame = entry[3] if len(entry) > 3 else "main" + @classmethod + def title(cls): + return _("Custom Links") - if len(entry) > 2 and entry[2]: - icon_file = entry[2] + @classmethod + def description(cls): + return _("This snapin contains custom links which can be " + "configured via the configuration variable " + "<tt>custom_links</tt> in <tt>multisite.mk</tt>") - # Old configs used files named "link_<name>.gif". Those .gif files have - # been removed from Check_MK. Replacing such images with the default icon - if icon_file.endswith(".gif"): - icon_file = "icon_link.png" - else: - icon_file = "icon_link.png" + def show(self): + links = config.custom_links.get(config.user.baserole_id) + if not links: + html.write_text((_( + "Please edit <tt>%s</tt> in order to configure which links are shown in this snapin." + ) % (cmk.paths.default_config_dir + "/multisite.mk")) + "\n") + return - linktext = HTML(html.render_icon("images/%s" % icon_file) + " " + entry[0]) + def render_list(ids, links): + n = 0 + for entry in links: + n += 1 + try: + if isinstance(entry[1], type(True)): + idss = ids + [str(n)] + id_ = '/'.join(idss) + html.begin_foldable_container( + "customlinks", id_, isopen=entry[1], title=entry[0]) + render_list(idss, entry[2]) + html.end_foldable_container() + elif isinstance(entry[1], str): + frame = entry[3] if len(entry) > 3 else "main" - simplelink(linktext, entry[1], frame) - else: - html.write_text( - _("Second part of tuple must be list or string, not %s\n") % str(entry[1])) - except Exception as e: - html.write_text(_("invalid entry %s: %s<br>\n") % (entry, e)) + if len(entry) > 2 and entry[2]: + icon_file = entry[2] - render_list([], links) + # Old configs used files named "link_<name>.gif". Those .gif files have + # been removed from Check_MK. Replacing such images with the default icon + if icon_file.endswith(".gif"): + icon_file = "icon_link.png" + else: + icon_file = "icon_link.png" + linktext = HTML(html.render_icon("images/%s" % icon_file) + " " + entry[0]) -sidebar_snapins["custom_links"] = { - "title": _("Custom Links"), - "description": _("This snapin contains custom links which can be " - "configured via the configuration variable " - "<tt>custom_links</tt> in <tt>multisite.mk</tt>"), - "render": render_custom_links, - "allowed": ["user", "admin", "guest"], - "styles": """ + simplelink(linktext, entry[1], frame) + else: + html.write_text( + _("Second part of tuple must be list or string, not %s\n") % str( + entry[1])) + except Exception as e: + html.write_text(_("invalid entry %s: %s<br>\n") % (entry, e)) + + render_list([], links) + + def styles(self): + return """ #snapin_custom_links div.sublist { padding-left: 10px; } @@ -96,4 +110,3 @@ sidebar_snapins["custom_links"] = { height: 16px; } """ -}
5 years, 10 months
1
0
0
0
Moved performance snapin to dedicated module
by Kenneth Okoh
Module: check_mk Branch: master Commit: 96721f7677e913bbde7a19f497b56a3c0504204a URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=96721f7677e913…
Author: Kenneth Okoh <ko(a)mathias-kettner.de> Date: Thu Nov 22 15:23:20 2018 +0100 Moved performance snapin to dedicated module Change-Id: Iac0280ea4dbb87eb90c6b7bab6f8bafd26d4b8ef --- cmk/gui/plugins/sidebar/performance.py | 112 +++++++++++++++++++++++++++++++++ cmk/gui/plugins/sidebar/shipped.py | 89 -------------------------- 2 files changed, 112 insertions(+), 89 deletions(-) diff --git a/cmk/gui/plugins/sidebar/performance.py b/cmk/gui/plugins/sidebar/performance.py new file mode 100644 index 0000000..bed037c --- /dev/null +++ b/cmk/gui/plugins/sidebar/performance.py @@ -0,0 +1,112 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at
http://mathias-kettner.de/check_mk
. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +import cmk.gui.config as config +import cmk.gui.sites as sites +from cmk.gui.i18n import _ +from cmk.gui.globals import html + +from cmk.gui.plugins.sidebar import ( + sidebar_snapins, + snapin_width, + snapin_site_choice, +) + + +def render_performance(): + only_sites = snapin_site_choice("performance", config.site_choices()) + + def write_line(left, right): + html.open_tr() + html.td(left, class_="left") + html.td(html.render_strong(right), class_="right") + html.close_tr() + + html.open_table(class_=["content_center", "performance"]) + + try: + sites.live().set_only_sites(only_sites) + data = sites.live().query("GET status\nColumns: service_checks_rate host_checks_rate " + "external_commands_rate connections_rate forks_rate " + "log_messages_rate cached_log_messages\n") + finally: + sites.live().set_only_sites(None) + + for what, col, format_str in \ + [("Service checks", 0, "%.2f/s"), + ("Host checks", 1, "%.2f/s"), + ("External commands", 2, "%.2f/s"), + ("Livestatus-conn.", 3, "%.2f/s"), + ("Process creations", 4, "%.2f/s"), + ("New log messages", 5, "%.2f/s"), + ("Cached log messages", 6, "%d")]: + write_line(what + ":", format_str % sum(row[col] for row in data)) + + if only_sites is None and len(config.allsites()) == 1: + try: + data = sites.live().query("GET status\nColumns: external_command_buffer_slots " + "external_command_buffer_max\n") + finally: + sites.live().set_only_sites(None) + size = sum([row[0] for row in data]) + maxx = sum([row[1] for row in data]) + write_line(_('Com. buf. max/total'), "%d / %d" % (maxx, size)) + + html.close_table() + + +sidebar_snapins["performance"] = { + "title": _("Server Performance"), + "description": _("Live monitor of the overall performance of all monitoring servers"), + "refresh": True, + "render": render_performance, + "allowed": ["admin",], + "styles": """ +#snapin_performance select { + margin-bottom: 2px; + width: 100%%; +} +table.performance { + width: %dpx; + border-radius: 2px; + background-color: rgba(0, 0, 0, 0.1); + border-style: solid; + border-color: rgba(0, 0, 0, 0.3) rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.3); + border-width: 1.5px; +} +table.performance td { + padding: 0px 2px; + font-size: 8pt; +} +table.performance td.right { + text-align: right; + padding: 0px; + padding-right: 1px; + white-space: nowrap; +} + +""" % (snapin_width - 2) +} diff --git a/cmk/gui/plugins/sidebar/shipped.py b/cmk/gui/plugins/sidebar/shipped.py index 9ca4b02..a675fe5 100644 --- a/cmk/gui/plugins/sidebar/shipped.py +++ b/cmk/gui/plugins/sidebar/shipped.py @@ -34,7 +34,6 @@ import re import cmk.paths import cmk.gui.config as config -import cmk.gui.sites as sites from cmk.gui.htmllib import HTML from cmk.gui.i18n import _ from cmk.gui.globals import html @@ -42,98 +41,10 @@ from cmk.gui.globals import html from cmk.gui.plugins.sidebar import ( sidebar_snapins, bulletlink, - snapin_width, - snapin_site_choice, simplelink, ) #. -# .--Performance---------------------------------------------------------. -# | ____ __ | -# | | _ \ ___ _ __ / _| ___ _ __ _ __ ___ __ _ _ __ ___ ___ | -# | | |_) / _ \ '__| |_ / _ \| '__| '_ ` _ \ / _` | '_ \ / __/ _ \ | -# | | __/ __/ | | _| (_) | | | | | | | | (_| | | | | (_| __/ | -# | |_| \___|_| |_| \___/|_| |_| |_| |_|\__,_|_| |_|\___\___| | -# | | -# '----------------------------------------------------------------------' - - -def render_performance(): - only_sites = snapin_site_choice("performance", config.site_choices()) - - def write_line(left, right): - html.open_tr() - html.td(left, class_="left") - html.td(html.render_strong(right), class_="right") - html.close_tr() - - html.open_table(class_=["content_center", "performance"]) - - try: - sites.live().set_only_sites(only_sites) - data = sites.live().query("GET status\nColumns: service_checks_rate host_checks_rate " - "external_commands_rate connections_rate forks_rate " - "log_messages_rate cached_log_messages\n") - finally: - sites.live().set_only_sites(None) - - for what, col, format_str in \ - [("Service checks", 0, "%.2f/s"), - ("Host checks", 1, "%.2f/s"), - ("External commands", 2, "%.2f/s"), - ("Livestatus-conn.", 3, "%.2f/s"), - ("Process creations", 4, "%.2f/s"), - ("New log messages", 5, "%.2f/s"), - ("Cached log messages", 6, "%d")]: - write_line(what + ":", format_str % sum(row[col] for row in data)) - - if only_sites is None and len(config.allsites()) == 1: - try: - data = sites.live().query("GET status\nColumns: external_command_buffer_slots " - "external_command_buffer_max\n") - finally: - sites.live().set_only_sites(None) - size = sum([row[0] for row in data]) - maxx = sum([row[1] for row in data]) - write_line(_('Com. buf. max/total'), "%d / %d" % (maxx, size)) - - html.close_table() - - -sidebar_snapins["performance"] = { - "title": _("Server Performance"), - "description": _("Live monitor of the overall performance of all monitoring servers"), - "refresh": True, - "render": render_performance, - "allowed": ["admin",], - "styles": """ -#snapin_performance select { - margin-bottom: 2px; - width: 100%%; -} -table.performance { - width: %dpx; - border-radius: 2px; - background-color: rgba(0, 0, 0, 0.1); - border-style: solid; - border-color: rgba(0, 0, 0, 0.3) rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.3); - border-width: 1.5px; -} -table.performance td { - padding: 0px 2px; - font-size: 8pt; -} -table.performance td.right { - text-align: right; - padding: 0px; - padding-right: 1px; - white-space: nowrap; -} - -""" % (snapin_width - 2) -} - -#. # .--Custom Links--------------------------------------------------------. # | ____ _ _ _ _ | # | / ___| _ ___| |_ ___ _ __ ___ | | (_)_ __ | | _____ |
5 years, 10 months
1
0
0
0
Refactored dashboards snapin to new snapin API
by Kenneth Okoh
Module: check_mk Branch: master Commit: 593cd90bbdd5896247223c1256ff87e63199504d URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=593cd90bbdd589…
Author: Kenneth Okoh <ko(a)mathias-kettner.de> Date: Thu Nov 22 15:19:33 2018 +0100 Refactored dashboards snapin to new snapin API Change-Id: Iaf525761884eda56bf8d0c63a2971001e95945d8 --- cmk/gui/plugins/sidebar/dashboards.py | 90 +++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/cmk/gui/plugins/sidebar/dashboards.py b/cmk/gui/plugins/sidebar/dashboards.py index b403cbf..a43d4eb 100644 --- a/cmk/gui/plugins/sidebar/dashboards.py +++ b/cmk/gui/plugins/sidebar/dashboards.py @@ -29,58 +29,66 @@ import cmk.gui.dashboard as dashboard from cmk.gui.globals import html from cmk.gui.i18n import _ from cmk.gui.plugins.sidebar import ( - sidebar_snapins, + SidebarSnapin, + snapin_registry, visuals_by_topic, bulletlink, footnotelinks, ) -def render_dashboards(): - dashboard.load_dashboards() +(a)snapin_registry.register +class Dashboards(SidebarSnapin): + @staticmethod + def type_name(): + return "dashboards" - def render_topic(topic, s, foldable=True): - first = True - for t, title, name, _is_view in s: - if t == topic: - if first: - if foldable: - html.begin_foldable_container( - "dashboards", topic, False, topic, indent=True) - else: - html.open_ul() - first = False - bulletlink( - title, 'dashboard.py?name=%s' % name, onclick="return wato_views_clicked(this)") + @classmethod + def title(cls): + return _("Dashboards") - if not first: # at least one item rendered - if foldable: - html.end_foldable_container() - else: - html.open_ul() + @classmethod + def description(cls): + return _("Links to all dashboards") - by_topic = visuals_by_topic( - dashboard.permitted_dashboards().items(), default_order=[_('Overview')]) - topics = [topic for topic, _entry in by_topic] + def show(self): + dashboard.load_dashboards() - if len(topics) < 2: - render_topic(by_topic[0][0], by_topic[0][1], foldable=False) + def render_topic(topic, s, foldable=True): + first = True + for t, title, name, _is_view in s: + if t == topic: + if first: + if foldable: + html.begin_foldable_container( + "dashboards", topic, False, topic, indent=True) + else: + html.open_ul() + first = False + bulletlink( + title, + 'dashboard.py?name=%s' % name, + onclick="return wato_views_clicked(this)") - else: - for topic, s in by_topic: - render_topic(topic, s) + if not first: # at least one item rendered + if foldable: + html.end_foldable_container() + else: + html.open_ul() - links = [] - if config.user.may("general.edit_dashboards"): - if config.debug: - links.append((_("Export"), "export_dashboards.py")) - links.append((_("Edit"), "edit_dashboards.py")) - footnotelinks(links) + by_topic = visuals_by_topic( + dashboard.permitted_dashboards().items(), default_order=[_('Overview')]) + topics = [topic for topic, _entry in by_topic] + if len(topics) < 2: + render_topic(by_topic[0][0], by_topic[0][1], foldable=False) + else: + for topic, s in by_topic: + render_topic(topic, s) -sidebar_snapins["dashboards"] = { - "title": _("Dashboards"), - "description": _("Links to all dashboards"), - "render": render_dashboards, - "allowed": ["user", "admin", "guest"], -} + links = [] + if config.user.may("general.edit_dashboards"): + if config.debug: + links.append((_("Export"), "export_dashboards.py")) + links.append((_("Edit"), "edit_dashboards.py")) + footnotelinks(links)
5 years, 10 months
1
0
0
0
Moved custom links snapin to dedicated module
by Kenneth Okoh
Module: check_mk Branch: master Commit: 1e5430702dba26b6702fd017713d93a306abee82 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1e5430702dba26…
Author: Kenneth Okoh <ko(a)mathias-kettner.de> Date: Thu Nov 22 15:37:56 2018 +0100 Moved custom links snapin to dedicated module Change-Id: I38c7a1e84786bbc5f65ea125e7ece352a0d9a23e --- cmk/gui/plugins/sidebar/custom_links.py | 99 +++++++++++++++++++++++++++++++++ cmk/gui/plugins/sidebar/shipped.py | 81 --------------------------- 2 files changed, 99 insertions(+), 81 deletions(-) diff --git a/cmk/gui/plugins/sidebar/custom_links.py b/cmk/gui/plugins/sidebar/custom_links.py new file mode 100644 index 0000000..49dfb7c --- /dev/null +++ b/cmk/gui/plugins/sidebar/custom_links.py @@ -0,0 +1,99 @@ +#!/usr/bin/python +# -*- encoding: utf-8; py-indent-offset: 4 -*- +# +------------------------------------------------------------------+ +# | ____ _ _ __ __ _ __ | +# | / ___| |__ ___ ___| | __ | \/ | |/ / | +# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / | +# | | |___| | | | __/ (__| < | | | | . \ | +# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ | +# | | +# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de | +# +------------------------------------------------------------------+ +# +# This file is part of Check_MK. +# The official homepage is at
http://mathias-kettner.de/check_mk
. +# +# check_mk is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation in version 2. check_mk is distributed +# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with- +# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU General Public License for more de- +# tails. You should have received a copy of the GNU General Public +# License along with GNU Make; see the file COPYING. If not, write +# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, +# Boston, MA 02110-1301 USA. + +import cmk.paths +import cmk.gui.config as config +from cmk.gui.htmllib import HTML +from cmk.gui.i18n import _ +from cmk.gui.globals import html +from cmk.gui.plugins.sidebar import sidebar_snapins, simplelink + + +def render_custom_links(): + links = config.custom_links.get(config.user.baserole_id) + if not links: + html.write_text((_( + "Please edit <tt>%s</tt> in order to configure which links are shown in this snapin.") % + (cmk.paths.default_config_dir + "/multisite.mk")) + "\n") + return + + def render_list(ids, links): + n = 0 + for entry in links: + n += 1 + try: + if isinstance(entry[1], type(True)): + idss = ids + [str(n)] + id_ = '/'.join(idss) + html.begin_foldable_container( + "customlinks", id_, isopen=entry[1], title=entry[0]) + render_list(idss, entry[2]) + html.end_foldable_container() + elif isinstance(entry[1], str): + frame = entry[3] if len(entry) > 3 else "main" + + if len(entry) > 2 and entry[2]: + icon_file = entry[2] + + # Old configs used files named "link_<name>.gif". Those .gif files have + # been removed from Check_MK. Replacing such images with the default icon + if icon_file.endswith(".gif"): + icon_file = "icon_link.png" + else: + icon_file = "icon_link.png" + + linktext = HTML(html.render_icon("images/%s" % icon_file) + " " + entry[0]) + + simplelink(linktext, entry[1], frame) + else: + html.write_text( + _("Second part of tuple must be list or string, not %s\n") % str(entry[1])) + except Exception as e: + html.write_text(_("invalid entry %s: %s<br>\n") % (entry, e)) + + render_list([], links) + + +sidebar_snapins["custom_links"] = { + "title": _("Custom Links"), + "description": _("This snapin contains custom links which can be " + "configured via the configuration variable " + "<tt>custom_links</tt> in <tt>multisite.mk</tt>"), + "render": render_custom_links, + "allowed": ["user", "admin", "guest"], + "styles": """ +#snapin_custom_links div.sublist { + padding-left: 10px; +} +#snapin_custom_links img { + margin-right: 5px; +} +#snapin_custom_links img.icon { + width: 16px; + height: 16px; +} +""" +} diff --git a/cmk/gui/plugins/sidebar/shipped.py b/cmk/gui/plugins/sidebar/shipped.py index a675fe5..7a66ea0 100644 --- a/cmk/gui/plugins/sidebar/shipped.py +++ b/cmk/gui/plugins/sidebar/shipped.py @@ -30,14 +30,10 @@ # from sidebar.py to the snapin objects that need these pages. import re - import cmk.paths - import cmk.gui.config as config -from cmk.gui.htmllib import HTML from cmk.gui.i18n import _ from cmk.gui.globals import html - from cmk.gui.plugins.sidebar import ( sidebar_snapins, bulletlink, @@ -45,83 +41,6 @@ from cmk.gui.plugins.sidebar import ( ) #. -# .--Custom Links--------------------------------------------------------. -# | ____ _ _ _ _ | -# | / ___| _ ___| |_ ___ _ __ ___ | | (_)_ __ | | _____ | -# | | | | | | / __| __/ _ \| '_ ` _ \ | | | | '_ \| |/ / __| | -# | | |__| |_| \__ \ || (_) | | | | | | | |___| | | | | <\__ \ | -# | \____\__,_|___/\__\___/|_| |_| |_| |_____|_|_| |_|_|\_\___/ | -# | | -# '----------------------------------------------------------------------' - - -def render_custom_links(): - links = config.custom_links.get(config.user.baserole_id) - if not links: - html.write_text((_( - "Please edit <tt>%s</tt> in order to configure which links are shown in this snapin.") % - (cmk.paths.default_config_dir + "/multisite.mk")) + "\n") - return - - def render_list(ids, links): - n = 0 - for entry in links: - n += 1 - try: - if isinstance(entry[1], type(True)): - idss = ids + [str(n)] - id_ = '/'.join(idss) - html.begin_foldable_container( - "customlinks", id_, isopen=entry[1], title=entry[0]) - render_list(idss, entry[2]) - html.end_foldable_container() - elif isinstance(entry[1], str): - frame = entry[3] if len(entry) > 3 else "main" - - if len(entry) > 2 and entry[2]: - icon_file = entry[2] - - # Old configs used files named "link_<name>.gif". Those .gif files have - # been removed from Check_MK. Replacing such images with the default icon - if icon_file.endswith(".gif"): - icon_file = "icon_link.png" - else: - icon_file = "icon_link.png" - - linktext = HTML(html.render_icon("images/%s" % icon_file) + " " + entry[0]) - - simplelink(linktext, entry[1], frame) - else: - html.write_text( - _("Second part of tuple must be list or string, not %s\n") % str(entry[1])) - except Exception as e: - html.write_text(_("invalid entry %s: %s<br>\n") % (entry, e)) - - render_list([], links) - - -sidebar_snapins["custom_links"] = { - "title": _("Custom Links"), - "description": _("This snapin contains custom links which can be " - "configured via the configuration variable " - "<tt>custom_links</tt> in <tt>multisite.mk</tt>"), - "render": render_custom_links, - "allowed": ["user", "admin", "guest"], - "styles": """ -#snapin_custom_links div.sublist { - padding-left: 10px; -} -#snapin_custom_links img { - margin-right: 5px; -} -#snapin_custom_links img.icon { - width: 16px; - height: 16px; -} -""" -} - -#. # .--Dokuwiki------------------------------------------------------------. # | ____ _ _ _ _ | # | | _ \ ___ | | ___ ___ _(_) | _(_) |
5 years, 10 months
1
0
0
0
Refactored performance snapin to new snapin API
by Kenneth Okoh
Module: check_mk Branch: master Commit: 5f813cfa30cfeacca84b1b0d1980cd571c473405 URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5f813cfa30cfea…
Author: Kenneth Okoh <ko(a)mathias-kettner.de> Date: Thu Nov 22 15:31:08 2018 +0100 Refactored performance snapin to new snapin API Change-Id: I2314e1cdf7c6f6276ea2475aee6e615aa6d7321f --- cmk/gui/plugins/sidebar/performance.py | 100 +++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/cmk/gui/plugins/sidebar/performance.py b/cmk/gui/plugins/sidebar/performance.py index bed037c..98e4097 100644 --- a/cmk/gui/plugins/sidebar/performance.py +++ b/cmk/gui/plugins/sidebar/performance.py @@ -28,63 +28,81 @@ import cmk.gui.config as config import cmk.gui.sites as sites from cmk.gui.i18n import _ from cmk.gui.globals import html - from cmk.gui.plugins.sidebar import ( - sidebar_snapins, + SidebarSnapin, + snapin_registry, snapin_width, snapin_site_choice, ) -def render_performance(): - only_sites = snapin_site_choice("performance", config.site_choices()) +(a)snapin_registry.register +class Performance(SidebarSnapin): + @staticmethod + def type_name(): + return "performance" + + @classmethod + def title(cls): + return _("Server Performance") - def write_line(left, right): - html.open_tr() - html.td(left, class_="left") - html.td(html.render_strong(right), class_="right") - html.close_tr() + @classmethod + def description(cls): + return _("Live monitor of the overall performance of all monitoring servers") - html.open_table(class_=["content_center", "performance"]) + def show(self): + only_sites = snapin_site_choice("performance", config.site_choices()) - try: - sites.live().set_only_sites(only_sites) - data = sites.live().query("GET status\nColumns: service_checks_rate host_checks_rate " - "external_commands_rate connections_rate forks_rate " - "log_messages_rate cached_log_messages\n") - finally: - sites.live().set_only_sites(None) + def write_line(left, right): + html.open_tr() + html.td(left, class_="left") + html.td(html.render_strong(right), class_="right") + html.close_tr() - for what, col, format_str in \ - [("Service checks", 0, "%.2f/s"), - ("Host checks", 1, "%.2f/s"), - ("External commands", 2, "%.2f/s"), - ("Livestatus-conn.", 3, "%.2f/s"), - ("Process creations", 4, "%.2f/s"), - ("New log messages", 5, "%.2f/s"), - ("Cached log messages", 6, "%d")]: - write_line(what + ":", format_str % sum(row[col] for row in data)) + html.open_table(class_=["content_center", "performance"]) - if only_sites is None and len(config.allsites()) == 1: try: - data = sites.live().query("GET status\nColumns: external_command_buffer_slots " - "external_command_buffer_max\n") + sites.live().set_only_sites(only_sites) + data = sites.live().query("GET status\nColumns: service_checks_rate host_checks_rate " + "external_commands_rate connections_rate forks_rate " + "log_messages_rate cached_log_messages\n") finally: sites.live().set_only_sites(None) - size = sum([row[0] for row in data]) - maxx = sum([row[1] for row in data]) - write_line(_('Com. buf. max/total'), "%d / %d" % (maxx, size)) - html.close_table() + for what, col, format_str in \ + [("Service checks", 0, "%.2f/s"), + ("Host checks", 1, "%.2f/s"), + ("External commands", 2, "%.2f/s"), + ("Livestatus-conn.", 3, "%.2f/s"), + ("Process creations", 4, "%.2f/s"), + ("New log messages", 5, "%.2f/s"), + ("Cached log messages", 6, "%d")]: + write_line(what + ":", format_str % sum(row[col] for row in data)) + + if only_sites is None and len(config.allsites()) == 1: + try: + data = sites.live().query("GET status\nColumns: external_command_buffer_slots " + "external_command_buffer_max\n") + finally: + sites.live().set_only_sites(None) + size = sum([row[0] for row in data]) + maxx = sum([row[1] for row in data]) + write_line(_('Com. buf. max/total'), "%d / %d" % (maxx, size)) + + html.close_table() + @classmethod + def refresh_on_restart(cls): + return True -sidebar_snapins["performance"] = { - "title": _("Server Performance"), - "description": _("Live monitor of the overall performance of all monitoring servers"), - "refresh": True, - "render": render_performance, - "allowed": ["admin",], - "styles": """ + @classmethod + def allowed_roles(cls): + return [ + "admin", + ] + + def styles(self): + return """ #snapin_performance select { margin-bottom: 2px; width: 100%%; @@ -107,6 +125,4 @@ table.performance td.right { padding-right: 1px; white-space: nowrap; } - """ % (snapin_width - 2) -}
5 years, 10 months
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
47
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
41
42
43
44
45
46
47
Results per page:
10
25
50
100
200