Module: check_mk
Branch: master
Commit: 5f3c78a64a57de19c97cc96a19bff87f1e4782b8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5f3c78a64a57de…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 22 08:46:50 2013 +0100
custom_checks now support freshness checking
Conflicts:
ChangeLog
---
ChangeLog | 2 ++
modules/check_mk.py | 19 +++++++++++++------
web/plugins/wato/active_checks.py | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 22439c2..016338b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,6 +73,8 @@
* FIX: Alias values of host/service/contact groups need to be set and unique
within the group
* Suggest use default value for filesystem levels that make sense
+ * Valuespec: CascadingDropdown now able to process choice values from functions
+ * Freshness checking for classical passive Nagios checks (custom_checks)
1.2.2b3:
Checks & Agents:
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 74609c9..765e974 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1904,10 +1904,10 @@ define service {
# Legacy checks via custom_checks
- entries = host_extra_conf(hostname, custom_checks)
- if entries:
+ custchecks = host_extra_conf(hostname, custom_checks)
+ if custchecks:
outfile.write("\n\n# Custom checks\n")
- for entry in entries:
+ for entry in custchecks:
# entries are dicts with the following keys:
# "service_description" Service description to use
# "command_line" (optional) Unix command line for executing the check
@@ -1931,6 +1931,13 @@ define service {
break
except:
pass
+
+ if "freshness" in entry:
+ freshness = " check_freshness\t\t1\n" + \
+ " freshness_threshold\t\t%d\n" % (60 * entry["freshness"]["interval"])
+ command_line = "echo %s && exit %d" % (
+ quote_shell_string(entry["freshness"]["output"]), entry["freshness"]["state"])
+
custom_commands_to_define.add(command_name)
@@ -1954,9 +1961,9 @@ define service {
service_description\t\t%s
check_command\t\t\t%s
active_checks_enabled\t\t%d
-%s}
+%s%s}
""" % (template, hostname, description, simulate_command(command),
- command_line and 1 or 0, extraconf))
+ (command_line and not "freshness") and 1 or 0, extraconf, freshness))
# Levels for host check
if is_cluster(hostname):
@@ -1965,7 +1972,7 @@ define service {
ping_command = 'check-mk-ping'
# No check_mk service, no legacy service -> create PING service
- if not have_at_least_one_service and not legchecks and not actchecks:
+ if not have_at_least_one_service and not legchecks and not actchecks and not custchecks:
outfile.write("""
define service {
use\t\t\t\t%s
diff --git a/web/plugins/wato/active_checks.py b/web/plugins/wato/active_checks.py
index e2f39fa..ff5778e 100644
--- a/web/plugins/wato/active_checks.py
+++ b/web/plugins/wato/active_checks.py
@@ -786,6 +786,43 @@ register_rule(group,
totext = _("process performance data"),
)
),
+ ( "freshness",
+ Dictionary(
+ title = _("Check freshness"),
+ help = _("Freshness checking is only useful for passive checks. It makes sure that passive "
+ "check results are submitted on a regular base. If not, the check is being set to "
+ "warning, critical or unknown."),
+ optional_keys = False,
+ elements = [
+ ( "interval",
+ Integer(
+ title = _("Expected update interval"),
+ label = _("Updates are expected at least every"),
+ unit = _("minutes"),
+ minvalue = 1,
+ default_value = 10,
+ )),
+ ( "state",
+ DropdownChoice(
+ title = _("State in case of absent updates"),
+ choices = [
+ ( 1, _("WARN") ),
+ ( 2, _("CRIT") ),
+ ( 3, _("UNKNOWN") ),
+ ],
+ default_value = 3,
+ )),
+ ( "output",
+ TextUnicode(
+ title = _("Plugin output in case of absent abdates"),
+ size = 40,
+ allow_empty = False,
+ default_value = _("Check result did not arrive in time")
+ )),
+ ],
+ )
+ ),
+
],
required_keys = [ "service_description" ],
),
Module: check_mk
Branch: master
Commit: f51b52c116eb6a5a034e88d4e7acc9d3556a8ed8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f51b52c116eb6a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 22 17:08:21 2013 +0100
FIX: megaraid_bbu: deal with broken output ("Adpater")
Conflicts:
ChangeLog
---
ChangeLog | 2 ++
checks/megaraid_bbu | 6 +++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 26c77f0..ff061e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,7 @@
Core:
* FIX: Fix output of cmk -D: datasource programs were missing
* FIX: allow unicode encoded extra_service_conf
+ * FIX: no default PING service if custom checks are defined
* FIX: check_mk_base: fixed rounding error in get_bytes_human_readable
* New configuration variable contactgroup_members
@@ -45,6 +46,7 @@
* FIX: diskstat: fix local variable 'ios_per_sec' referenced before assignment
* FIX: multipath: ignore warning messages in agent due to invalid multipath.conf
* FIX: jolokia_metrics.mem: renamed parameter totalheap to total
+ * FIX: megaraid_bbu: deal with broken output ("Adpater")
* Linux agent: limit netstat to 10 seconds
* ps: Allow %1, %2, .. instead of %s in process_inventory. That allows
reordering of matched groups
diff --git a/checks/megaraid_bbu b/checks/megaraid_bbu
index b6a734c..d000efd 100644
--- a/checks/megaraid_bbu
+++ b/checks/megaraid_bbu
@@ -56,7 +56,7 @@ def megaraid_bbu_parse(info):
data = data.strip()
# Scan each controller into its own dictionary
- if name == "BBU status for Adapter":
+ if name in [ "BBU status for Adapter", "BBU status for Adpater" ]:
current_hba = {}
controllers[data] = current_hba
else:
@@ -80,7 +80,7 @@ def check_megaraid_bbu(item, _no_params, info):
state = 0
# get current charge level
if 'Relative State of Charge' not in controller:
- charge = ", No charge information were reported for this controller"
+ charge = ", No charge information reported for this controller"
else:
charge = ", Charge is %s" % controller['Relative State of Charge']
@@ -96,7 +96,7 @@ def check_megaraid_bbu(item, _no_params, info):
except:
pass
- if controller["Learn Cycle Active"] == "Yes":
+ if controller.get("Learn Cycle Active") == "Yes":
return (0, "OK - no states to check (controller is in learn cycle)" + charge)
# return assembled info
elif broken:
matching all values now
Message-ID: <51274548.2BcBuNZqTNSsCYcn%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 2b2c0da702a8e0a292c4957f804a1671988b48ed
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2b2c0da702a8e0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Feb 22 11:12:13 2013 +0100
Code formating; Fixed SAP value "None" matching all values now
---
agents/plugins/mk_sap | 45 ++++++++++++++++++++++++++++++++++-----------
checks/sap | 6 +++---
2 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/agents/plugins/mk_sap b/agents/plugins/mk_sap
index b436dc0..c762daf 100755
--- a/agents/plugins/mk_sap
+++ b/agents/plugins/mk_sap
@@ -1,5 +1,28 @@
#!/usr/bin/python
# encoding: utf-8
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 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.
#
# This agent plugin has been built to collect information from SAP R/3 systems
# using RFC calls. It needs the python module sapnwrfc (available in Check_MK
@@ -171,27 +194,27 @@ def query(what, params, debug = False):
ret = f.RETURN.value
if ret['TYPE'] == 'E':
sys.stderr.write("ERROR: %s\n" % ret['MESSAGE'].strip())
-
+
return f
def login():
f = query('BAPI_XMI_LOGON', {
- 'EXTCOMPANY': 'Mathias Kettner GmbH',
- 'EXTPRODUCT': 'Check_MK SAP Agent',
- 'INTERFACE': 'XAL',
- 'VERSION': '1.0',
+ 'EXTCOMPANY': 'Mathias Kettner GmbH',
+ 'EXTPRODUCT': 'Check_MK SAP Agent',
+ 'INTERFACE': 'XAL',
+ 'VERSION': '1.0',
})
#print f.RETURN
return f.SESSIONID.value
def logout():
query('BAPI_XMI_LOGOFF', {
- 'INTERFACE': 'XAL',
+ 'INTERFACE': 'XAL',
})
def mon_list():
f = query("BAPI_SYSTEM_MON_GETLIST", {
- 'EXTERNAL_USER_NAME': cfg['user'],
+ 'EXTERNAL_USER_NAME': cfg['user'],
})
l = []
for mon in f.MONITOR_NAMES.value:
@@ -200,7 +223,7 @@ def mon_list():
def ms_list():
f = query("BAPI_SYSTEM_MS_GETLIST", {
- 'EXTERNAL_USER_NAME': cfg['user'],
+ 'EXTERNAL_USER_NAME': cfg['user'],
})
l = []
for ms in f.MONITOR_SETS.value:
@@ -337,7 +360,7 @@ for ms_name, mon_name in mon_list():
path = ms_name + SEPARATOR + mon_name
if not to_be_monitored(path, True):
continue
-
+
tree = mon_tree(ms_name, mon_name)
for node in tree:
if not to_be_monitored(node['PATH']):
@@ -381,7 +404,7 @@ for ms_name, mon_name in mon_list():
dt = parse_dt(last_alert["ALERTDATE"], last_alert["ALERTTIME"])
alert_state, alert_msg = alert_details(last_alert)
last_msg = '%s: %s - %s' % (dt, STATE_VALUE_MAP[alert_state['VALUE']][1], alert_msg)
-
+
status_details = '%d Messages, Last: %s' % (len(alerts), last_msg)
else:
status_details = 'The log is empty'
@@ -394,7 +417,7 @@ for ms_name, mon_name in mon_list():
sid = node["MTSYSID"].strip() or 'Other'
context = node["MTMCNAME"].strip() or 'Other'
path = node["PATH"]
-
+
sap_data.setdefault(sid, [])
sap_data[sid].append("%s\t%d\t%3d\t%s\t%s\t%s\t%s" % (context, state['VALUE'],
state['SEVERITY'], path, perfvalue, uom, status_details))
diff --git a/checks/sap b/checks/sap
index 9a177b9..10d3971 100644
--- a/checks/sap
+++ b/checks/sap
@@ -92,7 +92,9 @@ def inventory_sap_value(info):
return inv
def sap_value_path_matches(path, pattern):
- if pattern[0] != '~' and path == pattern:
+ if pattern is None:
+ return True
+ elif pattern[0] != '~' and path == pattern:
# exact path match
return True
elif pattern[0] == '~':
@@ -105,8 +107,6 @@ def sap_value_path_matches(path, pattern):
matchobject = reg.match(path)
if matchobject:
return True
- elif pattern is None:
- return True
return False
def check_sap_value(item, params, info):
Module: check_mk
Branch: master
Commit: 04e5b290969f20c70d112724a7a2faf065ec6a12
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=04e5b290969f20…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Feb 22 10:56:14 2013 +0100
FIX: jolokia_metrics.mem: renamed parameter totalheap to total
---
ChangeLog | 1 +
checkman/jolokia_metrics.mem | 10 +++++-----
checks/jolokia_metrics | 14 ++++++++++----
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1c72ecb..f8d3065 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,7 @@
* ps: Allow %1, %2, .. instead of %s in process_inventory. That allows
reordering of matched groups
* FIX: check_mk_base: fixed rounding error in get_bytes_human_readable
+ * FIX: jolokia_metrics.mem: renamed parameter totalheap to total
Multisite:
* FIX: Fixed problem with error during localization scanning
diff --git a/checkman/jolokia_metrics.mem b/checkman/jolokia_metrics.mem
index 2a2a5e7..dc1225a 100644
--- a/checkman/jolokia_metrics.mem
+++ b/checkman/jolokia_metrics.mem
@@ -22,7 +22,7 @@ examples:
jolokia_metrics_mem_default_levels = {
"heap" : (2000,1000), # heap warning when 2000MB left, heap crit when 1000 MB left
"nonheap" : (75.0, 95.7), # nonheap warning at 75.0% usage, nonheap crit at 95.7% usage
- "totalheap" : (3000, 2200), # totalheap warning at 3000MB left, totalheap crit at 2200MB left
+ "total" : (3000, 2200), # total warning at 3000MB left, total crit at 2200MB left
}
perfdata:
@@ -45,11 +45,11 @@ parameters (dict): This check requires a dictionary with the following keys.
Integer numbers are interpreted as remaining nonheap memory
Float numbers are interpreted as available nonheap memory usage
- {"totalheap"} - A pair of two values to be used as WARN/CRIT levels
- Integer numbers are interpreted as remaining totalheap memory
- Float numbers are interpreted as available totalheap memory usage
+ {"total"} - A pair of two values to be used as WARN/CRIT levels
+ Integer numbers are interpreted as remaining total memory
+ Float numbers are interpreted as available total memory usage
[configuration]
-jolokia_metrics_mem_default_levels (dict): Default warn/crit levels for heap, nonheap and totalheap
+jolokia_metrics_mem_default_levels (dict): Default warn/crit levels for heap, nonheap and total
diff --git a/checks/jolokia_metrics b/checks/jolokia_metrics
index b9143a5..0163283 100644
--- a/checks/jolokia_metrics
+++ b/checks/jolokia_metrics
@@ -167,7 +167,13 @@ def check_jolokia_metrics_mem(item, params, info):
# convert old parameter version ( warn, crit )
# represented levels of total heap
if type(params) == tuple:
- params = {"totalheap": params}
+ params = {"total": params}
+
+ # rename totalheap to total
+ # this block can be removed in the future (today 22.02.13)
+ if "totalheap" in params:
+ params["total"] = params["totalheap"]
+ del params["totalheap"]
d = parsed[item]
mb = 1024 * 1024.0
@@ -186,13 +192,13 @@ def check_jolokia_metrics_mem(item, params, info):
for (what, value, value_max) in [
("heap", heap, heapmax),
("nonheap", nonheap, nonheapmax),
- ("totalheap", total, totalmax),
+ ("total", total, totalmax),
]:
param_state = 0
level_info = ""
if params.get(what):
if type(params[what][0]) == int:
- if what != "totalheap":
+ if what != "total":
perfdata.append((what, value, value_max - params[what][0], value_max - params[what][1], "", value_max))
if value_max - value <= params[what][1]:
param_state = 2
@@ -201,7 +207,7 @@ def check_jolokia_metrics_mem(item, params, info):
param_state = 1
level_info = "%s(warn at %sMB free)" % (state_sign[1], params[what][0])
else:
- if what != "totalheap":
+ if what != "total":
perfdata.append((what, value, value_max * params[what][0] / 100.0, value_max * params[what][1] / 100.0, "", value_max))
if value >= value_max * params[what][1] / 100.0:
param_state = 2