Module: check_mk
Branch: master
Commit: 2640aa0f1b0d5183fcfb468d41e5b5a80dc9c730
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2640aa0f1b0d51…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Aug 22 13:45:42 2011 +0200
Output missing sections in case of "WARNING - Only __ output of"
---
.bugs/314 | 10 +++++++---
ChangeLog | 1 +
modules/check_mk_base.py | 20 ++++++++++++--------
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/.bugs/314 b/.bugs/314
index 970a8c6..de48a6c 100644
--- a/.bugs/314
+++ b/.bugs/314
@@ -1,10 +1,14 @@
Title: WARNING - Got only 15 out of 18 infos: which?
Component: core
+State: done
+Class: nastiness
+Date: 2011-07-22 10:49:16
Benefit: 1
-State: open
Cost: 2
-Date: 2011-07-22 10:49:16
-Class: nastiness
+Fun: 0
When this error occurs, we should output the list of
missing agent sections (i.e. *which* information is missing).
+
+2011-08-22 13:45:06: changed state open -> done
+Missing section names are now output.
diff --git a/ChangeLog b/ChangeLog
index c6dd74a..e2db174 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
style FUNC(checkname, info) is still supported but deprecated.
* Show datasource program on cmk -D
* Remove .f12 compile helper files from agents directory
+ * Output missing sections in case of "WARNING - Only __ output of __..."
Checks & Agents:
* FIX: hr_mem: take into account cache and buffers
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index a6b2009..23f7dbe 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -689,19 +689,20 @@ def do_check(hostname, ipaddress):
try:
load_counters(hostname)
- agent_version, num_success, num_errors, problems =
do_all_checks_on_host(hostname, ipaddress)
+ agent_version, num_success, error_sections, problems =
do_all_checks_on_host(hostname, ipaddress)
+ num_errors = len(error_sections)
save_counters(hostname)
if problems:
output = "CRIT - %s" % problems
status = 2
elif num_errors > 0 and num_success > 0:
- output = "WARNING - Got only %d out of %d infos" % (num_success,
num_success + num_errors)
+ output = "WARN - Missing agent sections: %s" % ",
".join(error_sections)
status = 1
elif num_errors > 0:
output = "CRIT - Got no information from host"
status = 2
elif agent_min_version and agent_version < agent_min_version:
- output = "WARNING - old plugin version %s (should be at least %s)"
% (agent_version, agent_min_version)
+ output = "WARN - old plugin version %s (should be at least %s)" %
(agent_version, agent_min_version)
status = 1
else:
output = "OK - Agent version %s" % agent_version
@@ -736,7 +737,7 @@ def do_all_checks_on_host(hostname, ipaddress):
global g_hostname
g_hostname = hostname
num_success = 0
- num_errors = 0
+ error_sections = set([])
check_table = get_sorted_check_table(hostname)
problems = []
@@ -754,14 +755,14 @@ def do_all_checks_on_host(hostname, ipaddress):
except MKSNMPError, e:
if str(e):
problems.append(str(e))
- num_errors += 1
+ error_sections.add(infotype)
g_broken_snmp_hosts.add(hostname)
continue
except MKAgentError, e:
if str(e):
problems.append(str(e))
- num_errors += 1
+ error_sections.add(infotype)
g_broken_agent_hosts.add(hostname)
continue
@@ -811,7 +812,7 @@ def do_all_checks_on_host(hostname, ipaddress):
if not dont_submit:
submit_check_result(hostname, description, result, aggrname)
else:
- num_errors += 1
+ error_sections.add(infotype)
submit_aggregated_results(hostname)
if checkresult_file_fd != None:
@@ -828,7 +829,10 @@ def do_all_checks_on_host(hostname, ipaddress):
agent_version = "(unknown)"
except:
agent_version = "(unknown)"
- return agent_version, num_success, num_errors, ", ".join(problems)
+ error_sections = list(error_sections)
+ error_sections.sort()
+ return agent_version, num_success, error_sections, ", ".join(problems)
+
def open_checkresult_file():