Module: check_mk
Branch: master
Commit: b1bfe8def4b52aaf1e5ba81c87a99a2b53f2e99f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b1bfe8def4b52a…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Jun 19 12:03:22 2013 +0200
* Assigning a service to a cluster host no longer requires a reinventory
* Setting a check_type or service to ignore no longer requires a reinventory
Note: If the ignore rule is removed the services will reappear
* Config creation: The ignore services rule now also applies to custom, active
and legacy checks
* Fix: Inventory screen: Now shows custom checks
* Inventory screen: Host inventory also displays its clustered services
* Rules: Renamed "Ignored services" to "Disabled services"
Renamed "Ignored checks" to "Disabled checks"
---
ChangeLog | 9 +++++++++
modules/automation.py | 27 ++++++++++++++++++++++-----
modules/check_mk.py | 22 ++++++++++++++++++++--
web/htdocs/wato.py | 6 ++++--
web/plugins/wato/check_mk_configuration.py | 8 ++++----
5 files changed, 59 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index efa5c6b..2ec8c4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,11 @@
* New option -B for just generating the configuration
* Introduced persistent host address lookup cache to prevent issues
loading an unchanged configuration after a single address is not resolvable
anymore
+ * Assigning a service to a cluster host no longer requires a reinventory
+ * Setting a check_type or service to ignore no longer requires a reinventory
+ Note: If the ignore rule is removed the services will reappear
+ * Config creation: The ignore services rule now also applies to custom, active
+ and legacy checks
Checks & Agents:
* esx_hostystem multipath: criticize standby paths only if not equal to active paths
@@ -34,6 +39,10 @@
its far better than nothing.
* logwatch: Logwatch icon no longer uses notes_url
* check_mk-if.pnp: fixed bug with pnp template on esx hosts without perfdata
+ * Fix: Inventory screen: Now shows custom checks
+ * Inventory screen: Host inventory also displays its clustered services
+ * Rules: Renamed "Ignored services" to "Disabled services"
+ Renamed "Ignored checks" to "Disabled checks"
WATO:
* Allow to configure check-/retry_interval in second precision
diff --git a/modules/automation.py b/modules/automation.py
index 7f390f8..f7eb9fa 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -158,11 +158,21 @@ def automation_try_inventory(args):
services.append(entry)
already_added.add((entry[1], entry[6])) # make it unique
+ # Find manual checks for this cluster
+ cluster_checks = get_check_table(hostname)
+ for (ct, item), (params, descr, deps) in cluster_checks.items():
+ if (ct, descr) not in already_added:
+ services.append(("manual", ct, None, item, repr(params),
params, descr, 0, "", None))
+ already_added.add( (ct, descr) ) # make it unique
+
else:
new_services = automation_try_inventory_node(hostname)
for entry in new_services:
- if host_of_clustered_service(hostname, entry[6]) == hostname:
+ host = host_of_clustered_service(hostname, entry[6])
+ if host == hostname:
services.append(entry)
+ else:
+ services.append(("clustered",) + entry[1:])
return services
@@ -241,6 +251,11 @@ def automation_try_inventory_node(hostname):
for cmd, descr, perf in legchecks:
found[('legacy', descr)] = ( 'legacy', 'None' )
+ # Add custom checks and active checks with artificial type 'custom'
+ custchecks = host_extra_conf(hostname, custom_checks)
+ for entry in custchecks:
+ found[('custom', entry['service_description'])] = (
'custom', 'None' )
+
# Similar for 'active_checks', but here we have parameters
for acttype, rules in active_checks.items():
act_info = active_check_info[acttype]
@@ -249,12 +264,11 @@ def automation_try_inventory_node(hostname):
descr = act_info["service_description"](params)
found[(acttype, descr)] = ( 'active', repr(params) )
-
# Collect current status information about all existing checks
table = []
for (ct, item), (state_type, paramstring) in found.items():
params = None
- if state_type not in [ 'legacy', 'active' ]:
+ if state_type not in [ 'legacy', 'active', 'custom' ]:
# apply check_parameters
try:
if type(paramstring) == str:
@@ -316,16 +330,19 @@ def automation_try_inventory_node(hostname):
else:
descr = item
exitcode = None
- output = "WAITING - Legacy check, cannot be done offline"
+ output = "WAITING - %s check, cannot be done offline" %
state_type.title()
perfdata = []
if state_type == "active":
params = eval(paramstring)
- if state_type in [ "legacy", "active" ]:
+ if state_type in [ "legacy", "active", "custom" ]:
checkgroup = None
+ if service_ignored(hostname, None, descr):
+ state_type = "ignored"
else:
checkgroup = check_info[ct]["group"]
+
table.append((state_type, ct, checkgroup, item, paramstring, params, descr,
exitcode, output, perfdata))
if not table and (tcp_error or snmp_error):
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 1dcdc0c..3a61c5c 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1787,6 +1787,14 @@ def create_nagios_servicedefs(outfile, hostname):
# ___) |
# |____/ 3. Services
+
+ def do_omit_service(hostname, description):
+ if service_ignored(hostname, None, description):
+ return True
+ if hostname != host_of_clustered_service(hostname, description):
+ return True
+ return False
+
host_checks = get_check_table(hostname).items()
host_checks.sort() # Create deterministic order
aggregated_services_conf = set([])
@@ -1949,6 +1957,9 @@ define servicedependency {
if len(legchecks) > 0:
outfile.write("\n\n# Legacy checks\n")
for command, description, has_perfdata in legchecks:
+ if do_omit_service(hostname, description):
+ continue
+
if description in used_descriptions:
cn, it = used_descriptions[description]
raise MKGeneralException(
@@ -1995,6 +2006,10 @@ define service {
has_perfdata = act_info.get('has_perfdata', False)
description = act_info["service_description"](params)
+
+ if do_omit_service(hostname, description):
+ continue
+
# compute argument, and quote ! and \ for Nagios
args =
act_info["argument_function"](params).replace("\\",
"\\\\").replace("!", "\\!")
@@ -2040,6 +2055,9 @@ define service {
command_name = entry.get("command_name",
"check-mk-custom")
command_line = entry.get("command_line", "")
+ if do_omit_service(hostname, description):
+ continue
+
if command_line:
plugin_name = command_line.split()[0]
if command_line[0] not in [ '$', '/' ]:
@@ -2598,11 +2616,11 @@ def check_inventory(hostname):
def service_ignored(hostname, checktype, service_description):
- if checktype in ignored_checktypes:
+ if checktype and checktype in ignored_checktypes:
return True
if in_boolean_serviceconf_list(hostname, service_description, ignored_services):
return True
- if checktype_ignored_for_host(hostname, checktype):
+ if checktype and checktype_ignored_for_host(hostname, checktype):
return True
return False
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 565bc8c..2220a87 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2216,11 +2216,13 @@ def show_service_table(host, firsttime):
( _("Available (missing) services"), "new", firsttime ),
( _("Already configured services"), "old", True, ),
( _("Obsolete services (being checked, but should be ignored)"),
"obsolete", True ),
- ( _("Ignored services (configured away by admin)"),
"ignored", False ),
+ ( _("Disabled services (configured away by admin)"),
"ignored", None),
( _("Vanished services (checked, but no longer exist)"),
"vanished", True ),
( _("Active checks"), "active", None ),
( _("Manual services (defined in main.mk)"), "manual", None
),
- ( _("Legacy services (defined in main.mk)"), "legacy", None
)
+ ( _("Legacy services (defined in main.mk)"), "legacy", None
),
+ ( _("Custom checks (defined via rule)"), "custom", None ),
+ ( _("Clustered services (located on cluster host)"),
"clustered", None )
]:
first = True
trclass = "even"
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index df44668..2ae1c3d 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1480,8 +1480,8 @@ register_rule(group,
register_rule(group,
"ignored_services",
- title = _("Ignored services"),
- help = _("Services that are declared as <u>ignored</u> by this rule
set will not be added "
+ title = _("Disabled services"),
+ help = _("Services that are declared as <u>disabled</u> by this rule
set will not be added "
"to a host during inventory (automatic service detection). Services
that already "
"exist will continued to be monitored but be marked as obsolete in the
service "
"list of a host."),
@@ -1490,8 +1490,8 @@ register_rule(group,
register_rule(group,
"ignored_checks",
CheckTypeSelection(
- title = _("Ignored checks"),
- help = _("This ruleset is similar to 'Ignored services', but selects
checks to be ignored "
+ title = _("Disabled checks"),
+ help = _("This ruleset is similar to 'Disabled services', but
selects checks to be disabled "
"by their <b>type</b>. This allows you to disable
certain technical implementations "
"such as filesystem checks via SNMP on hosts that also have the
Check_MK agent "
"installed."),