Module: check_mk
Branch: master
Commit: 5a47fafb9f512aa386a1beb42bf669d686b26743
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5a47fafb9f512a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Dec 11 22:01:11 2018 +0100
Minor cleanup: Compute cache file age only once
Change-Id: I31941b7e21528d90ac99ba8c57b20b8d10db8eed
---
cmk_base/data_sources/abstract.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/cmk_base/data_sources/abstract.py b/cmk_base/data_sources/abstract.py
index d181e69..61becc9 100644
--- a/cmk_base/data_sources/abstract.py
+++ b/cmk_base/data_sources/abstract.py
@@ -207,10 +207,10 @@ class DataSource(object):
return
may_use_outdated = config.simulation_mode or self._use_outdated_cache_file
- if not may_use_outdated and cmk_base.utils.cachefile_age(
- cachefile) > self._max_cachefile_age:
+ cachefile_age = cmk_base.utils.cachefile_age(cachefile)
+ if not may_use_outdated and cachefile_age > self._max_cachefile_age:
self._logger.debug("Not using cache (Too old. Age is %d sec, allowed is %s sec)" %
- (cmk_base.utils.cachefile_age(cachefile), self._max_cachefile_age))
+ (cachefile_age, self._max_cachefile_age))
return
# TODO: Use some generic store file read function to generalize error handling,
Module: check_mk
Branch: master
Commit: 2938f1a31378c8064afb586bf033846dcdbf9b18
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2938f1a31378c8…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Dec 12 08:55:34 2018 +0100
Unbreak proxy settings.
Change-Id: Ieeea864356e7e7f3bc2fa26d6efb3d3299dc9bae
---
cmk/gui/plugins/wato/utils/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmk/gui/plugins/wato/utils/__init__.py b/cmk/gui/plugins/wato/utils/__init__.py
index d98c320..8a30fba 100644
--- a/cmk/gui/plugins/wato/utils/__init__.py
+++ b/cmk/gui/plugins/wato/utils/__init__.py
@@ -595,7 +595,7 @@ def HTTPProxyReference():
"""Use this valuespec in case you want the user to configure a HTTP proxy
The configured value is is used for preparing requests to work in a proxied environment."""
- def _global_proxy_choices(self):
+ def _global_proxy_choices():
settings = watolib.ConfigDomainCore().load()
return [(p["ident"], p["title"]) for p in settings.get("http_proxies", {}).values()]
Module: check_mk
Branch: master
Commit: 7dafc031e04ab4525bdde53305dc3e45a392fbef
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7dafc031e04ab4…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 12 08:20:52 2018 +0100
6929 FIX Distributed WATO login: Protect against some config failures
When building up a distributed Check_MK with distributed WATO, there
are two situations which could end up in problematic situations which
are handled now in a better way:
<ul>
<li>Connecting a central Check_MK Managed Services based site to a CEE
or CRE based site resulted in a broken slave site. When trying to login
a CME site into a CEE site, an error message now prevents the login.</li>
<li>We have added a checkbox to the login dialog to confirm that one
really wants to overwrite the configuration of the remote site with the
central sites configuration.</li>
</ul>
This changes the protocol of the login automation call, but is fully
compatibile with previous versions. We may add additional checks in
the future based on the involved Check_MK editions and versions. The
sites now exchange their versions.
CMK-1370
Change-Id: I2d12dffa4da1fe2c510ac737acbad29127877fec
---
.werks/6929 | 22 ++++++++++++++++++++++
cmk/gui/wato/pages/automation.py | 14 +++++++++++++-
cmk/gui/wato/pages/sites.py | 27 ++++++++++++++++++++++++---
3 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/.werks/6929 b/.werks/6929
new file mode 100644
index 0000000..b1651eb
--- /dev/null
+++ b/.werks/6929
@@ -0,0 +1,22 @@
+Title: Distributed WATO login: Protect against some config failures
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1544597077
+
+When building up a distributed Check_MK with distributed WATO, there
+are two situations which could end up in problematic situations which
+are handled now in a better way:
+
+<ul>
+<li>Connecting a central Check_MK Managed Services based site to a CEE
+or CRE based site resulted in a broken slave site. When trying to login
+a CME site into a CEE site, an error message now prevents the login.</li>
+<li>We have added a checkbox to the login dialog to confirm that one
+really wants to overwrite the configuration of the remote site with the
+central sites configuration.</li>
+</ul>
diff --git a/cmk/gui/wato/pages/automation.py b/cmk/gui/wato/pages/automation.py
index d458d03..7e1f7b0 100644
--- a/cmk/gui/wato/pages/automation.py
+++ b/cmk/gui/wato/pages/automation.py
@@ -28,6 +28,7 @@ automation functions on slaves,"""
import traceback
+import cmk
import cmk.gui.config as config
import cmk.gui.watolib as watolib
import cmk.gui.userdb as userdb
@@ -53,7 +54,18 @@ class ModeAutomationLogin(WatoWebApiMode):
raise MKAuthException(_("This account has no permission for automation."))
html.set_output_format("python")
- html.write_html(repr(watolib.get_login_secret(True)))
+
+ if not html.has_var("_version"):
+ # Be compatible to calls from sites using versions before 1.5.0p10.
+ # Deprecate with 1.7 by throwing an exception in this situation.
+ response = watolib.get_login_secret(create_on_demand=True)
+ else:
+ response = {
+ "version": cmk.__version__,
+ "edition_short": cmk.edition_short(),
+ "login_secret": watolib.get_login_secret(create_on_demand=True),
+ }
+ html.write_html(repr(response))
register_page_handler("automation_login", lambda: ModeAutomationLogin().page())
diff --git a/cmk/gui/wato/pages/sites.py b/cmk/gui/wato/pages/sites.py
index 9f9e3a6..593ee48 100644
--- a/cmk/gui/wato/pages/sites.py
+++ b/cmk/gui/wato/pages/sites.py
@@ -28,6 +28,7 @@
import re
import traceback
+import cmk
import cmk.gui.config as config
import cmk.gui.watolib as watolib
import cmk.gui.userdb as userdb
@@ -560,7 +561,24 @@ class ModeDistributedMonitoring(ModeSites):
name = html.var("_name", "").strip()
passwd = html.var("_passwd", "").strip()
try:
- secret = watolib.do_site_login(login_id, name, passwd)
+ if not html.get_checkbox("_confirm"):
+ raise MKUserError(
+ "_confirm",
+ _("You need to confirm that you want to "
+ "overwrite the remote site configuration."))
+
+ response = watolib.do_site_login(login_id, name, passwd)
+
+ if isinstance(response, dict):
+ if cmk.is_managed_edition() and response["edition_short"] != "cme":
+ raise MKUserError(
+ None,
+ _("The Check_MK Managed Services Edition can only "
+ "be connected with other sites using the CME."))
+ secret = response["login_secret"]
+ else:
+ secret = response
+
site["secret"] = secret
self._site_mgmt.save_sites(configured_sites)
message = _("Successfully logged into remote site %s.") % html.render_tt(
@@ -597,11 +615,14 @@ class ModeDistributedMonitoring(ModeSites):
html.begin_form("login", method="POST")
forms.header(_('Login credentials'))
- forms.section(_('Administrator name:'))
+ forms.section(_('Administrator name'))
html.text_input("_name")
html.set_focus("_name")
- forms.section(_('Administrator password:'))
+ forms.section(_('Administrator password'))
html.password_input("_passwd")
+ forms.section(_('Confirm overwrite'))
+ html.checkbox(
+ "_confirm", False, label=_("Confirm overwrite of the remote site configuration"))
forms.end()
html.button("_do_login", _("Login"))
html.button("_abort", _("Abort"))
Module: check_mk
Branch: master
Commit: fe8f8538337573f5d6f5d1b6732be81666f75573
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fe8f8538337573…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 3 20:33:01 2018 +0100
6920 HTTP proxies can now be configured globally
To enable components to connect to external resources in proxied networks
more easily it is now possible to configure several HTTP proxies using the
global setting "HTTP proxies".
Imagine a scenario where your monitoring server is located in your
company internal network and you need to make a connection to a external
HTTP server in the internet while you can only connect to this server
using a proxy server. In the past the most spread option is to either
open the firewall to make the direct connection from the monitoring
server possible or to set the HTTP(S)_PROXY environment variables for
such a call and hope that the program you use for the connection
supports these envrionment variables.
Now it is possible to configure the proxies using the GUI in a central
place and refer to these settings from different parts of your
configuration.
These proxies will be usable by e.g. special agents, notification
scripts and active checks, which need to use a proxy for their work.
As example the pushover notification script has been migrated to support
the global proxy settings.
Note to notification script developers: You have to name the
notification proxy element of the Dictionary parameters valuespec
"proxy_url" to make it work as expected with globally configured
proxies.
Note to special agent and active check developers: There is a new
function available get_http_proxy(http_proxy). Pass the
"http_proxy" value a user configured using the HTTPProxyReference
valuespec to this function an you will get back the proxy URL as string
or None in case no proxy should be set via command line (see "pydoc
cmk_base.check_api.get_http_proxy_for_cmdline" for further information).
CMK-1407
Change-Id: If74ce019b163259366e067dd17ed76e0b54e726a
---
.werks/6920 | 42 ++++++++++++++
cmk/gui/plugins/wato/__init__.py | 2 +
cmk/gui/plugins/wato/check_mk_configuration.py | 66 +++++++++++++++++++++
cmk/gui/plugins/wato/notifications.py | 20 ++++---
cmk/gui/plugins/wato/utils/__init__.py | 49 ++++++++++++++++
cmk/gui/valuespec.py | 59 ++++++++++++-------
cmk_base/check_api.py | 11 ++++
cmk_base/config.py | 30 +++++++++-
cmk_base/default_config/base.py | 1 +
cmk_base/events.py | 17 +++++-
cmk_base/notify.py | 2 +-
tests/unit/cmk/gui/test_watolib.py | 1 +
tests/unit/cmk_base/test_check_api.py | 7 +++
tests/unit/cmk_base/test_config.py | 79 ++++++++++++++++++++------
14 files changed, 336 insertions(+), 50 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=fe8f853833…
Module: check_mk
Branch: master
Commit: 1f21c73a246a9a875ad6105f0d91f1c3661ea159
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1f21c73a246a9a…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Tue Dec 11 13:06:48 2018 +0100
agent_azure: remove option to configure metrics
The previous approach turned out to be way to unreliable,
as the Azure API keeps lying to us.
Hard code the metrics to fetch.
Change-Id: I860f1474364fc4de33036161c1f334f043509120
---
agents/special/agent_azure | 164 +++++++++-------------------
checks/agent_azure_args | 13 +--
cmk/gui/plugins/wato/datasource_programs.py | 27 -----
3 files changed, 57 insertions(+), 147 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=1f21c73a24…
Module: check_mk
Branch: master
Commit: 2e8a2cd95df0b227ca32139e80d345be2666d7ac
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2e8a2cd95df0b2…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Dec 11 14:35:37 2018 +0100
Suppress a few bogus warnings.
Change-Id: Ie6f28b395542db77ddab11e01d434e8c2d89813c
---
.clang-tidy | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/.clang-tidy b/.clang-tidy
index 7925f01..1496b8b 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -13,6 +13,7 @@
# * cppcoreguidelines-pro-type-static-cast-downcast ("do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead")
# * fuchsia-default-arguments ("calling a function that uses a default argument is disallowed")
# * fuchsia-overloaded-operator ("cannot overload 'operatorFOO'")
+# * fuchsia-statically-constructed-objects ("static objects are disallowed; if possible, use a constexpr constructor instead")
# * google-runtime-references ("non-const reference parameter 'foo', make it const or use a pointer")
# * hicpp-no-assembler ("do not use inline assembler in safety-critical code") triggered by ntohs/htons
# * llvm-include-order ("#includes are not sorted properly")
@@ -42,7 +43,10 @@
# * hicpp-special-member-functions
# * modernize-use-default-member-init
#
-Checks: '*,-android-cloexec-fopen,-android-cloexec-open,-cert-env33-c,-cert-err34-c,-cert-err58-cpp,-clang-analyzer-alpha*,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,-fuchsia-default-arguments,-fuchsia-overloaded-operator,-google-runtime-int,-google-runtime-references,-hicpp-member-init,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-signed-bitwise,-hicpp-vararg,-llvm-header-guard,-llvm-include-order,-modernize-use-bool-literals,-clang-analyzer-optin.performance.Padding,-cppcoreguidelines-special-member-functions,-hicpp-special-member-functions,-modernize-use-default-member-init'
+# * bug in toolchain/clang-tidy:
+# * clang-analyzer-cplusplus.NewDeleteLeaks ("Potential leak of memory pointed to by field '_M_head_impl'") See https://bugs.llvm.org/show_bug.cgi?id=38176 ("clang-analyzer-cplusplus.NewDeleteLeaks false positive in C++17 mode only")
+#
+Checks: '*,-android-cloexec-fopen,-android-cloexec-open,-cert-env33-c,-cert-err34-c,-cert-err58-cpp,-clang-analyzer-alpha*,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,-fuchsia-default-arguments,-fuchsia-overloaded-operator,-fuchsia-statically-constructed-objects,-google-runtime-int,-google-runtime-references,-hicpp-member-init,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-signed-bitwise,-hicpp-vararg,-llvm-header-guard,-llvm-include-order,-modernize-use-bool-literals,-clang-analyzer-optin.performance.Padding,-cppcoreguidelines-special-member-functions,-hicpp-special-member-functions,-modernize-use-default-member-init,-clang-analyzer-cplusplus.NewDeleteLeaks'
CheckOptions:
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '1'
Module: check_mk
Branch: master
Commit: 7747642b684e7a4c49d5a552f43aaa38fdb96b66
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7747642b684e7a…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Dec 10 12:43:57 2018 +0100
OutputFunnel.plug_level is redundant.
Change-Id: If675f95fde1f72f394f15cb894898f0df9f18186
---
cmk/gui/htmllib.py | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/cmk/gui/htmllib.py b/cmk/gui/htmllib.py
index 9e4758f..c2c8a89 100644
--- a/cmk/gui/htmllib.py
+++ b/cmk/gui/htmllib.py
@@ -371,7 +371,6 @@ class OutputFunnel(object):
def __init__(self):
super(OutputFunnel, self).__init__()
- self.plug_level = -1
self.plug_text = []
# Accepts str and unicode objects only!
@@ -388,7 +387,7 @@ class OutputFunnel(object):
_('Type Error: html.write accepts str and unicode input objects only!'))
if self._is_plugged():
- self.plug_text[self.plug_level].append(text)
+ self.plug_text[-1].append(text)
else:
# encode when really writing out the data. Not when writing plugged,
# because the plugged code will be handled somehow by our code. We
@@ -415,18 +414,17 @@ class OutputFunnel(object):
# Put in a plug which stops the text stream and redirects it to a sink.
def plug(self):
self.plug_text.append([])
- self.plug_level += 1
def _is_plugged(self):
- return self.plug_level > -1
+ return bool(self.plug_text)
# Get the sink content in order to do something with it.
def drain(self):
if not self._is_plugged():
return ''
- text = "".join(self.plug_text[self.plug_level])
- self.plug_text[self.plug_level] = []
+ text = "".join(self.plug_text.pop())
+ self.plug_text.append([])
return text
def unplug(self):
@@ -434,7 +432,6 @@ class OutputFunnel(object):
return
text = "".join(self.plug_text.pop())
- self.plug_level -= 1
self.write(text)
def unplug_all(self):