Module: check_mk
Branch: master
Commit: 81d4e6868ff5125ce2730ed5b8ac7c7ecd689668
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=81d4e6868ff512…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 19 17:46:15 2018 +0200
Allow pylint to check the C extensions we need instead of ignoring them
TODO: The rrdtool module is currently not part of the venv. Add it
and remove the "ignored-modules" option.
Change-Id: Ib81b5fd0d5883436ad76345cdf134b727a3cfb4b
---
tests/pylint/pylintrc | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 9f26a30..eb7fea6 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -9,6 +9,7 @@ init-hook=
load-plugins=testlib.pylint_cmk,testlib.pylint_checker_localization
# TODO: Why do we need persistence?
persistent=yes
+extension-pkg-whitelist=rrdtool,_ldap,netifaces,pymssql
[MESSAGES CONTROL]
disable=
@@ -106,12 +107,8 @@ disable=
# Can not check methods / attributes of the rrdtool C module. Skipping related errors
# like the following:
# [E1101(no-member), create_rrd] Module 'rrdtool' has no 'create' member
-# ldap
-# The Python ldap module gets a lot of constants from the C API which can not be found by pylint.
-# This results in a lot of these errors: "Module 'ldap' has no 'OPT_REFERRALS' member".
-# netifaces
-# Can not check methods / attributes of the netifaces C module
-ignored-modules = rrdtool,ldap,netifaces
+# TODO: Add rrdtool to virtualenv and drop this
+ignored-modules = rrdtool
[REPORTS]
output-format=cmk_colorized
Module: check_mk
Branch: master
Commit: 5376d4525e9e9c7c61dd97e34e34ccebc3a7bbdd
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5376d4525e9e9c…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jul 19 14:53:40 2018 +0200
Classify bare-except and broad-except warnings.
Change-Id: Idb648f2122d46dbaa9d103994c524ab1396812a8
---
tests/pylint/pylintrc | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index bceb6de..9f26a30 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -12,8 +12,6 @@ persistent=yes
[MESSAGES CONTROL]
disable=
- bare-except,
- broad-except,
cell-var-from-loop,
consider-iterating-dictionary,
consider-using-enumerate,
@@ -83,6 +81,11 @@ disable=
# duplication (introduce new classes, combine methods, etc.)
attribute-defined-outside-init,
#---------------------------------------------------------------------------
+ # Enabling these warnings would be nice, they are mostly a sign of sloppy
+ # programming practice. In some cases, they can even hide bugs.
+ bare-except,
+ broad-except,
+ #---------------------------------------------------------------------------
# Enabling this would be nice, but not crucial. At the moment, we have quite
# a few violations, so we postpone fixing this. When we do it eventually, we
# probably want to use "include-naming-hint=yes" in the BASIC section.
Module: check_mk
Branch: master
Commit: 28041e802bc8a334abd72ee11f7606c3d6a4e433
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=28041e802bc8a3…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jul 19 08:55:59 2018 +0200
Classify attribute-defined-outside-init warning.
Change-Id: I3e4e7ec80691234b34aecf3d1fe4e36601d6668b
---
tests/pylint/pylintrc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 910612a..3ce8a12 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -12,7 +12,6 @@ persistent=yes
[MESSAGES CONTROL]
disable=
- attribute-defined-outside-init,
bad-continuation,
bad-indentation,
bad-whitespace,
@@ -81,6 +80,12 @@ disable=
# real bugs. Just some work to do...
unused-variable,
#---------------------------------------------------------------------------
+ # Enabling this would be very desirable, it vastly improves readability and
+ # it might even be necessary for tools like mypy. Fixing this involves some
+ # amount of relatively easy work, especially if we want to avoid code
+ # duplication (introduce new classes, combine methods, etc.)
+ attribute-defined-outside-init,
+ #---------------------------------------------------------------------------
# Enabling this would be nice, but not crucial. At the moment, we have quite
# a few violations, so we postpone fixing this. When we do it eventually, we
# probably want to use "include-naming-hint=yes" in the BASIC section.
Module: check_mk
Branch: master
Commit: 5c315174ffa779445c79eb20ccfd14b75b1b810f
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5c315174ffa779…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jul 19 08:42:14 2018 +0200
Classify arguments-differ warning.
Change-Id: I4c45f37ecccfaa3cc894d0932a493e8d01c5b4c5
---
tests/pylint/pylintrc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 769ffa9..910612a 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -12,7 +12,6 @@ persistent=yes
[MESSAGES CONTROL]
disable=
- arguments-differ,
attribute-defined-outside-init,
bad-continuation,
bad-indentation,
@@ -73,6 +72,11 @@ disable=
# through our code and fix a few obscure places.
abstract-method,
#---------------------------------------------------------------------------
+ # We should really enable this, there are real bugs lurking. Even if it
+ # turns out that this is not the case in a few places: Doing things this way
+ # is extremely bad OO practice.
+ arguments-differ,
+ #---------------------------------------------------------------------------
# We should really enable this, there could be some typos hiding which are
# real bugs. Just some work to do...
unused-variable,
Module: check_mk
Branch: master
Commit: 7424414393ac2b496ae75213accc109c80269052
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7424414393ac2b…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Jul 19 17:25:27 2018 +0200
6125 mssql_connections: new check to monitor active connections of a MSSQL database
Change-Id: Iee362225857b4771e7345b4e813b22a7ec652659
---
.werks/6125 | 10 +++++
agents/windows/plugins/mssql.vbs | 16 +++++++
checkman/mssql_connections | 21 +++++++++
checks/mssql_connections | 77 ++++++++++++++++++++++++++++++++
cmk/gui/plugins/wato/check_parameters.py | 25 +++++++++++
5 files changed, 149 insertions(+)
diff --git a/.werks/6125 b/.werks/6125
new file mode 100644
index 0000000..4d46a3b
--- /dev/null
+++ b/.werks/6125
@@ -0,0 +1,10 @@
+Title: mssql_connections: new check to monitor active connections of a MSSQL database
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1532013883
+Class: feature
+
+
diff --git a/agents/windows/plugins/mssql.vbs b/agents/windows/plugins/mssql.vbs
index 3781217..fe7888e 100644
--- a/agents/windows/plugins/mssql.vbs
+++ b/agents/windows/plugins/mssql.vbs
@@ -101,6 +101,7 @@ sections.add "datafiles", "<<<mssql_datafiles:sep(124)>>>"
sections.add "clusters", "<<<mssql_cluster:sep(124)>>>"
' Has been deprecated with 1.4.0i1. Keep this for nicer transition for some versions.
sections.add "versions", "<<<mssql_versions:sep(124)>>>"
+sections.add "connections", "<<<mssql_connections>>>"
For Each section_id In sections.Keys
addOutput(sections(section_id))
@@ -506,6 +507,21 @@ For Each instance_id In instances.Keys: Do ' Continue trick
addOutput(instance_id & "|" & Replace(dbName, " ", "_") & "|" & active_node & "|" & nodes)
Loop While False: Next
+ addOutput(sections("connections"))
+ Dim connection_count, database_name
+
+ RS.Open "SELECT name AS DBName, ISNULL((SELECT COUNT(dbid) AS NumberOfConnections FROM " &_
+ "sys.sysprocesses WHERE dbid > 0 AND name = DB_NAME(dbid) GROUP BY dbid ),0) AS NumberOfConnections " &_
+ "FROM sys.databases", CONN
+
+ Do While Not RS.Eof
+ database_name = RS("DBName")
+ connection_count = RS("NumberOfConnections")
+
+ addOutput(instance_id & " " & Replace(database_name, " ", "_") & " " & connection_count)
+ RS.MoveNext
+ Loop
+
CONN.Close
Loop While False: Next
diff --git a/checkman/mssql_connections b/checkman/mssql_connections
new file mode 100644
index 0000000..08523ea
--- /dev/null
+++ b/checkman/mssql_connections
@@ -0,0 +1,21 @@
+title: MSSQL Connections
+agents: windows
+catalog: app/mssql
+license: GPL
+distribution: check_mk
+description:
+ This check reports number of active connections for a database.
+
+ If the number of active connections exceeds the defined upper
+ levels the check result will be {WARN} or {CRIT}.
+
+ This check needs the Check_MK mssql.vbs plugin installed in
+ the agent. Please refer to the online documentation
+ for how to install that plugin.
+
+item:
+ The MSSQL database identifier.
+
+inventory:
+ One check is created for each database.
+
diff --git a/checks/mssql_connections b/checks/mssql_connections
new file mode 100644
index 0000000..57c7176
--- /dev/null
+++ b/checks/mssql_connections
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2017 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.
+
+
+# Example output:
+# <<<mssql_connections>>>
+# MSSQLSERVER master 16
+# MSSQLSERVER tempdb 1
+
+
+factory_settings["mssql_connections_default_levels"] = {
+ "levels" : (20, 50),
+}
+
+
+def parse_mssql_connections(info):
+ parsed = {}
+ for line in info:
+ try:
+ instance, db_name, connection_count = line
+ connection_count = int(connection_count)
+ parsed.setdefault("%s %s" % (instance, db_name), connection_count)
+ except ValueError:
+ pass
+ return parsed
+
+
+def inventory_mssql_connections(parsed):
+ for item in parsed:
+ yield item, {}
+
+
+def check_mssql_connections(item, params, parsed):
+ # If a database is missing in the agent output there are no
+ # active connections for that database.
+ connection_count = parsed.get(item, 0)
+
+ warn, crit = params['levels']
+ if connection_count >= crit:
+ return 2, 'Connections: %d (warn/crit at %d/%d)' % (connection_count, warn, crit)
+ elif connection_count >= warn:
+ return 1, 'Connections: %d (warn/crit at %d/%d)' % (connection_count, warn, crit)
+ else:
+ return 0, 'Connections: %d' % connection_count
+
+
+check_info['mssql_connections'] = {
+ 'parse_function' : parse_mssql_connections,
+ 'inventory_function' : inventory_mssql_connections,
+ 'check_function' : check_mssql_connections,
+ 'service_description' : 'MSSQL Connections %s',
+ 'group' : 'mssql_connections',
+ 'default_levels_variable' : "mssql_connections_default_levels",
+}
diff --git a/cmk/gui/plugins/wato/check_parameters.py b/cmk/gui/plugins/wato/check_parameters.py
index b8d8a9f..cfcb1d6 100644
--- a/cmk/gui/plugins/wato/check_parameters.py
+++ b/cmk/gui/plugins/wato/check_parameters.py
@@ -3042,6 +3042,31 @@ register_check_parameters(
"dict",
)
+
+register_check_parameters(
+ subgroup_applications,
+ "mssql_connections",
+ _("MSSQL Connections"),
+ Dictionary(
+ elements = [
+ ( "levels",
+ Tuple(
+ title = _("Upper levels for the number of active database connections"),
+ elements = [
+ Integer(title = _("Warning if over"), default_value=20),
+ Integer(title = _("Critical if over"), default_value=50),
+ ]
+ ),)
+ ]
+ ),
+ TextAscii(
+ title = _("Database identifier"),
+ allow_empty = True
+ ),
+ 'dict',
+)
+
+
register_check_parameters(
subgroup_applications,
"varnish_cache",
Module: check_mk
Branch: master
Commit: f3cd64e4cf96e249561c139ee340cc9d0f5b55c6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f3cd64e4cf96e2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 19 16:24:46 2018 +0200
6350 FIX Fixed broken checking of unrelated hosts when using manual checks
When using the Check_MK Raw Edition it could happen that configuring manual
checks for a host broke the check execution of unrelated hosts.
The configuration of the manual check of all hosts was loaded into the context
of such an unrelated host. Because a host only loads the check definitions of
the checks it needs during checking, those manual check configurations were
trying to access unavailable data. This lead to a crash and a "(null)" output
shown for the "Check_MK" service.
Change-Id: I7347801936d7e88309a09efc36756abb7f57a6ef
---
.werks/6350 | 18 ++++++++++++++++++
cmk_base/config.py | 10 +++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/.werks/6350 b/.werks/6350
new file mode 100644
index 0000000..f0c88bb
--- /dev/null
+++ b/.werks/6350
@@ -0,0 +1,18 @@
+Title: Fixed broken checking of unrelated hosts when using manual checks
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1531599198
+
+When using the Check_MK Raw Edition it could happen that configuring manual
+checks for a host broke the check execution of unrelated hosts.
+
+The configuration of the manual check of all hosts was loaded into the context
+of such an unrelated host. Because a host only loads the check definitions of
+the checks it needs during checking, those manual check configurations were
+trying to access unavailable data. This lead to a crash and a "(null)" output
+shown for the "Check_MK" service.
diff --git a/cmk_base/config.py b/cmk_base/config.py
index e63d1c5..6ebdd67 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -317,11 +317,19 @@ def add_wato_static_checks_to_checks():
else:
hostlist = entry[1]
taglist = []
+
+ # Do not process manual checks that are related to not existing or have not
+ # loaded check files
+ try:
+ check_plugin_info = check_info[checktype]
+ except KeyError:
+ continue
+
# Make sure, that for dictionary based checks
# at least those keys defined in the factory
# settings are present in the parameters
if type(params) == dict:
- def_levels_varname = check_info[checktype].get("default_levels_variable")
+ def_levels_varname = check_plugin_info.get("default_levels_variable")
if def_levels_varname:
for key, value in factory_settings.get(def_levels_varname, {}).items():
if key not in params:
Module: check_mk
Branch: master
Commit: 165557b035938a6a76765e9c3eadfa24f46eb94b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=165557b035938a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Jul 19 16:23:42 2018 +0200
6349 FIX Fixed not working "manual checks" in Check_MK Raw Edition
Manual checks, often used for "process checks" were not executed
when using the Check_MK Raw Edition. All configured manual checks
became stale after some time and were never checked.
Change-Id: Ic800ce63678ae2e17dfe4f6cf03d5a62c1abb833
---
.werks/6349 | 13 +++++++++++++
cmk_base/config.py | 7 ++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/.werks/6349 b/.werks/6349
new file mode 100644
index 0000000..3728f68
--- /dev/null
+++ b/.werks/6349
@@ -0,0 +1,13 @@
+Title: Fixed not working "manual checks" in Check_MK Raw Edition
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1531598131
+
+Manual checks, often used for "process checks" were not executed
+when using the Check_MK Raw Edition. All configured manual checks
+became stale after some time and were never checked.
diff --git a/cmk_base/config.py b/cmk_base/config.py
index 3f2884b..e63d1c5 100644
--- a/cmk_base/config.py
+++ b/cmk_base/config.py
@@ -177,7 +177,7 @@ def _perform_post_config_loading_actions():
# In case the checks are not loaded yet it seems the current mode
# is not working with the checks. In this case also don't load the
# static checks into the configuration.
- if all_checks_loaded():
+ if any_check_loaded():
add_wato_static_checks_to_checks()
initialize_check_caches()
set_check_variables_for_checks()
@@ -2201,6 +2201,11 @@ def all_checks_loaded():
return _all_checks_loaded
+def any_check_loaded():
+ """Whether or not some checks have been loaded into the current process"""
+ return bool(_check_contexts)
+
+
# Constructs a new check context dictionary. It contains the whole check API.
def new_check_context(get_check_api_context):
# Add the data structures where the checks register with Check_MK