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" ],
),