Module: check_mk
Branch: master
Commit: 7072d94ae4ee45c4331ae45e436f4ef974eda7f7
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7072d94ae4ee45…
Author: Andreas <ab(a)mathias-kettner.de>
Date: Wed May 30 14:48:51 2018 +0200
5813 FIX mk_oracle.ps1: temporary files are no longer written to c:\windows\system32
Temporary files from this plugin are now generated in the official temp directory.
Its usually specified through the environment variable MK_TEMPDIR, set by the windows agent.
Change-Id: Ib7bb4e4530e0173e9d1f7aef421b4917e06fe72b
---
.werks/5813 | 14 ++++++++++++++
agents/windows/plugins/mk_oracle.ps1 | 16 +++++++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.werks/5813 b/.werks/5813
new file mode 100644
index 0000000..3febba5
--- /dev/null
+++ b/.werks/5813
@@ -0,0 +1,14 @@
+Title: mk_oracle.ps1: temporary files are no longer written to c:\windows\system32
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1527684383
+
+Temporary files from this plugin are now generated in the official temp directory.
+Its usually specified through the environment variable MK_TEMPDIR, set by the windows agent.
+
+
diff --git a/agents/windows/plugins/mk_oracle.ps1 b/agents/windows/plugins/mk_oracle.ps1
index f8ec0a2..64862ca 100644
--- a/agents/windows/plugins/mk_oracle.ps1
+++ b/agents/windows/plugins/mk_oracle.ps1
@@ -37,7 +37,7 @@
# usage
###############################################################################
# copy this file to C:\Program Files (x86)\check_mk\plugins
-# copy the config file to C:\Program Files (x86)\check_mk\
+# copy the config file to C:\Program Files (x86)\check_mk\config
# cd C:\Program Files (x86)\check_mk
# check_mk_agent test
###############################################################################
@@ -146,6 +146,15 @@ if (!$MK_CONFDIR) {
$MK_CONFDIR= "c:\Program Files (x86)\check_mk\config"
}
+# directory for tempfiles
+$MK_TEMPDIR = $env:MK_TEMPDIR
+
+# Fallback if the (old) agent does not provide the MK_TEMPDIR
+if (!$MK_TEMPDIR){
+ $MK_TEMPDIR = "C:\Program Files (x86)\check_mk\temp"
+}
+
+
# Source the optional configuration file for this agent plugin
$CONFIG_FILE="${MK_CONFDIR}\mk_oracle_cfg.ps1"
if (test-path -path "${CONFIG_FILE}" ) {
@@ -238,7 +247,7 @@ exit;
$res=$res.trim()
$res=[int]$res
$res
- }
+ }
# now we set our action on error back to our normal value
$ErrorActionPreference = $NORMAL_ACTION_PREFERENCE
}
@@ -466,7 +475,7 @@ Param(
# The temporary file to store the output of the SQL
# currently default path is used here. change this @TBR?
- $fullpath="$sql_message.$sqlsid.txt"
+ $fullpath= $MK_TEMPDIR + "\" + "$sql_message.$sqlsid.txt"
if ($delayed -gt 0)
{
@@ -1484,3 +1493,4 @@ if ($the_count -gt 0) {
}
debug_echo "got to the end"
+
Module: check_mk
Branch: master
Commit: 2b24271c0772febadc5313b4db4bd1ffc29356dd
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b24271c0772fe…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 30 10:54:03 2018 +0200
Update to #6186
Change-Id: Ideabfe117b26fb0d8937f6b4c7e9c53c17dfb5ee
---
cmk_base/checking.py | 1 +
cmk_base/discovery.py | 60 +++++++++++++++++++++++++++++++--------------------
2 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index 40eac9c..c1c9fb1 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -268,6 +268,7 @@ def execute_check(multi_host_sections, hostname, ipaddress, check_plugin_name, i
dont_submit = False
try:
+ # TODO: There is duplicate code with discovery._execute_discovery(). Find a common place!
try:
section_content = multi_host_sections.get_section_content(hostname,
ipaddress, section_name, for_discovery=False)
diff --git a/cmk_base/discovery.py b/cmk_base/discovery.py
index 8daf98f..8c5fd8f 100644
--- a/cmk_base/discovery.py
+++ b/cmk_base/discovery.py
@@ -872,33 +872,38 @@ def _execute_discovery(multi_host_sections, hostname, ipaddress, check_plugin_na
except KeyError:
raise MKGeneralException("No such check type '%s'" % check_plugin_name)
+ # Now do the actual discovery
try:
- section_content = multi_host_sections.get_section_content(hostname, ipaddress,
- check_plugin_name, for_discovery=True)
- except MKParseFunctionError, e:
- if cmk.debug.enabled():
- x = e.exc_info()
- raise x[0], x[1], x[2] # re-raise the original exception to not destory the trace
+ # TODO: There is duplicate code with checking.execute_check(). Find a common place!
+ try:
+ section_content = multi_host_sections.get_section_content(hostname, ipaddress,
+ check_plugin_name, for_discovery=True)
+ except MKParseFunctionError, e:
+ if cmk.debug.enabled() or on_error == "raise":
+ x = e.exc_info()
+ if x[0] == item_state.MKCounterWrapped:
+ return []
+ else:
+ # re-raise the original exception to not destory the trace. This may raise a MKCounterWrapped
+ # exception which need to lead to a skipped check instead of a crash
+ raise x[0], x[1], x[2]
- if on_error == "warn":
- section_name = checks.section_name_of(check_plugin_name)
- console.warning("Exception while parsing agent section '%s': %s\n" % (section_name, e))
- elif on_error == "raise":
- raise
- return []
+ elif on_error == "warn":
+ section_name = checks.section_name_of(check_plugin_name)
+ console.warning("Exception while parsing agent section '%s': %s\n" % (section_name, e))
- if section_content is None: # No data for this check type
- return []
+ return []
- # In case of SNMP checks but missing agent response, skip this check.
- # Special checks which still need to be called even with empty data
- # may declare this.
- if not section_content and checks.is_snmp_check(check_plugin_name) \
- and not checks.check_info[check_plugin_name]["handle_empty_info"]:
- return []
+ if section_content is None: # No data for this check type
+ return []
+
+ # In case of SNMP checks but missing agent response, skip this check.
+ # Special checks which still need to be called even with empty data
+ # may declare this.
+ if not section_content and checks.is_snmp_check(check_plugin_name) \
+ and not checks.check_info[check_plugin_name]["handle_empty_info"]:
+ return []
- # Now do the actual discovery
- try:
# Check number of arguments of discovery function. Note: This
# check for the legacy API will be removed after 1.2.6.
if len(inspect.getargspec(discovery_function).args) == 2:
@@ -1185,7 +1190,16 @@ def get_check_preview(hostname, use_caches, do_snmp_scan, on_error):
continue # Skip not existing check silently
try:
- section_content = multi_host_sections.get_section_content(hostname, ipaddress, section_name, for_discovery=True)
+ try:
+ section_content = multi_host_sections.get_section_content(hostname, ipaddress, section_name, for_discovery=True)
+ except MKParseFunctionError, e:
+ if cmk.debug.enabled() or on_error == "raise":
+ x = e.exc_info()
+ # re-raise the original exception to not destory the trace. This may raise a MKCounterWrapped
+ # exception which need to lead to a skipped check instead of a crash
+ raise x[0], x[1], x[2]
+ else:
+ raise
except Exception, e:
if cmk.debug.enabled():
raise
Module: check_mk
Branch: master
Commit: 2c14e4a2d3b56206d4a6d01faa18d9472e804ae4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2c14e4a2d3b562…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed May 30 10:15:09 2018 +0200
6186 FIX Fixed crash of Check_MK service on counter wraps in parse functions (e.g. MKCounterWrapped: WMI query timed out)
When a check raises a MKCounterWrapped exception in the parse function, this check result should be ignored.
In all 1.5 releases this lead to a crash with an error message like "MKCounterWrapped (WMI query timed out)"
in case of the WMI checks.
Change-Id: If394764507bbe1056ea59a4be1d9f3e957bc2c48
---
.werks/6186 | 13 +++++++++++++
cmk_base/checking.py | 46 ++++++++++++++++++++++++----------------------
2 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/.werks/6186 b/.werks/6186
new file mode 100644
index 0000000..712f2f8
--- /dev/null
+++ b/.werks/6186
@@ -0,0 +1,13 @@
+Title: Fixed crash of Check_MK service on counter wraps in parse functions (e.g. MKCounterWrapped: WMI query timed out)
+Level: 1
+Component: core
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1527667964
+
+When a check raises a MKCounterWrapped exception in the parse function, this check result should be ignored.
+In all 1.5 releases this lead to a crash with an error message like "MKCounterWrapped (WMI query timed out)"
+in case of the WMI checks.
diff --git a/cmk_base/checking.py b/cmk_base/checking.py
index 9982ee7..40eac9c 100644
--- a/cmk_base/checking.py
+++ b/cmk_base/checking.py
@@ -260,36 +260,38 @@ def execute_check(multi_host_sections, hostname, ipaddress, check_plugin_name, i
section_name = checks.section_name_of(check_plugin_name)
- try:
- section_content = multi_host_sections.get_section_content(hostname,
- ipaddress, section_name, for_discovery=False)
- except MKParseFunctionError, e:
- x = e.exc_info()
- raise x[0], x[1], x[2] # re-raise the original exception to not destory the trace
-
# We need to set this again, because get_section_content has the side effect of setting this with
# item None if there is a parse function. This would break the entire set_item/get_rate logic
# for checks with items that rely on this being handled by the API.
# TODO: Write a regression test for this.
item_state.set_item_state_prefix(check_plugin_name, item)
- # TODO: Move this to a helper function
- if section_content is None: # No data for this check type
- return False
-
- # In case of SNMP checks but missing agent response, skip this check.
- # Special checks which still need to be called even with empty data
- # may declare this.
- if not section_content and checks.is_snmp_check(check_plugin_name) \
- and not checks.check_info[check_plugin_name]["handle_empty_info"]:
- return False
-
- check_function = checks.check_info[check_plugin_name].get("check_function")
- if check_function is None:
- check_function = lambda item, params, section_content: (3, 'UNKNOWN - Check not implemented')
-
dont_submit = False
try:
+ try:
+ section_content = multi_host_sections.get_section_content(hostname,
+ ipaddress, section_name, for_discovery=False)
+ except MKParseFunctionError, e:
+ x = e.exc_info()
+ # re-raise the original exception to not destory the trace. This may raise a MKCounterWrapped
+ # exception which need to lead to a skipped check instead of a crash
+ raise x[0], x[1], x[2]
+
+ # TODO: Move this to a helper function
+ if section_content is None: # No data for this check type
+ return False
+
+ # In case of SNMP checks but missing agent response, skip this check.
+ # Special checks which still need to be called even with empty data
+ # may declare this.
+ if not section_content and checks.is_snmp_check(check_plugin_name) \
+ and not checks.check_info[check_plugin_name]["handle_empty_info"]:
+ return False
+
+ check_function = checks.check_info[check_plugin_name].get("check_function")
+ if check_function is None:
+ check_function = lambda item, params, section_content: (3, 'UNKNOWN - Check not implemented')
+
# Call the actual check function
item_state.reset_wrapped_counters()
Module: check_mk
Branch: master
Commit: 615684631a64cfdec17b33c20140087492e0d7ec
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=615684631a64cf…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Fri May 25 07:59:16 2018 +0200
Handle OS and device info in HW/SW inventory
Change-Id: I4e8c824b7d7df9252230ea67d925ca53b0d4750d
---
agents/special/agent_fritzbox | 6 ++----
inventory/fritz | 46 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/agents/special/agent_fritzbox b/agents/special/agent_fritzbox
index fc26ac0..7e3f0a5 100755
--- a/agents/special/agent_fritzbox
+++ b/agents/special/agent_fritzbox
@@ -197,11 +197,9 @@ try:
if opt_debug:
raise
- sys.stdout.write('<<<check_mk>>>\n')
- sys.stdout.write('Version: %s\n' % g_version)
- sys.stdout.write('AgentOS: %s\n' % g_device)
-
sys.stdout.write('<<<fritz>>>\n')
+ sys.stdout.write('VersionOS %s\n' % g_version)
+ sys.stdout.write('VersionDevice %s\n' % g_device)
for key, value in status.items():
sys.stdout.write('%s %s\n' % (key, value))
diff --git a/inventory/fritz b/inventory/fritz
new file mode 100644
index 0000000..b7bd1b1
--- /dev/null
+++ b/inventory/fritz
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2018 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-
+# ails. 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.
+
+#<<<fritz>>>
+#VersionOS 74.06.05
+#VersionDevice AVM FRITZ!Box Fon WLAN 7270 v3
+#
+
+
+def inv_fritz(info):
+
+ parsed = {line[0]: ' '.join(line[1:])
+ for line in info}
+
+ node_hw = inv_tree('hardware.system.')
+ node_hw['model'] = parsed.get('VersionDevice')
+ node_sw = inv_tree('software.os.')
+ node_sw['version'] = parsed.get('VersionOS')
+
+inv_info['fritz'] = {
+ "inv_function" : inv_fritz,
+}
+