Module: check_mk
Branch: master
Commit: aec6de545b626a119d6fd3d42712a6b08f0ce7a3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aec6de545b626a…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Aug 11 13:47:08 2015 +0200
Add SNMP-Info to crash reports of SNMP based checks
---
modules/check_mk_base.py | 20 +++++++++++++++-----
web/htdocs/crash_reporting.py | 8 +++++---
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 710152e..5c9c09b 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1444,14 +1444,17 @@ def do_all_checks_on_host(hostname, ipaddress, only_check_types =
None):
# This is put into a directory per service. The content is then
# put into a tarball, base64 encoded and put into the long output
# of the check :-)
-def create_crash_dump(hostname, check_name, item, params, description, info):
+def create_crash_dump(hostname, check_type, item, params, description, info):
text = "check failed - please submit a crash report!"
try:
crash_dir = var_dir + "/crashed_checks/" + hostname + "/" +
description.replace("/", "\\")
prepare_crash_dump_directory(crash_dir)
- create_crash_dump_info_file(crash_dir, hostname, check_name, item, params,
description, info, text)
- write_crash_dump_agent_output(crash_dir, hostname)
+ create_crash_dump_info_file(crash_dir, hostname, check_type, item, params,
description, info, text)
+ if check_uses_snmp(check_type):
+ write_crash_dump_snmp_info(crash_dir, hostname, check_type)
+ else:
+ write_crash_dump_agent_output(crash_dir, hostname)
text += "\n" + "Crash dump:\n" + pack_crash_dump(crash_dir) +
"\n"
except:
@@ -1472,7 +1475,7 @@ def prepare_crash_dump_directory(crash_dir):
pass
-def create_crash_dump_info_file(crash_dir, hostname, check_name, item, params,
description, info, text):
+def create_crash_dump_info_file(crash_dir, hostname, check_type, item, params,
description, info, text):
exc_type, exc_value, exc_traceback = sys.exc_info()
crash_info = {
@@ -1487,9 +1490,10 @@ def create_crash_dump_info_file(crash_dir, hostname, check_name,
item, params, d
"check_output" : text,
"host" : hostname,
"description" : description,
- "check_type" : check_name,
+ "check_type" : check_type,
"item" : item,
"params" : params,
+ "uses_snmp" : check_uses_snmp(check_type),
},
}
@@ -1524,6 +1528,12 @@ def get_os_info():
return "UNKNOWN"
+def write_crash_dump_snmp_info(crash_dir, hostname, check_type):
+ cachefile = tcp_cache_dir + "/" + hostname + "." +
check_type.split(".")[0]
+ if os.path.exists(cachefile):
+ file(crash_dir + "/snmp_info",
"w").write(file(cachefile).read())
+
+
def write_crash_dump_agent_output(crash_dir, hostname):
cachefile = tcp_cache_dir + "/" + hostname
if os.path.exists(cachefile):
diff --git a/web/htdocs/crash_reporting.py b/web/htdocs/crash_reporting.py
index dd3ac6a..6f6ee71 100644
--- a/web/htdocs/crash_reporting.py
+++ b/web/htdocs/crash_reporting.py
@@ -286,11 +286,13 @@ def show_crashed_check_details(info):
html.write("<td>%s</td></tr>" %
html.attrencode(details["host"]))
html.write("<tr class=\"data odd0\"><td
class=\"left\">%s</td>" % _("Check Type"))
html.write("<td>%s</td></tr>" %
html.attrencode(details["check_type"]))
- html.write("<tr class=\"data even0\"><td
class=\"left\">%s</td>" % _("Check Item"))
+ html.write("<tr class=\"data even0\"><td
class=\"left\">%s</td>" % _("Uses SNMP"))
+ html.write("<td><pre>%s</pre></td></tr>" %
(details["uses_snmp"] and _("Yes") or _("No")))
+ html.write("<tr class=\"data odd0\"><td
class=\"left\">%s</td>" % _("Check Item"))
html.write("<td>%s</td></tr>" %
html.attrencode(details["item"]))
- html.write("<tr class=\"data odd0\"><td
class=\"left\">%s</td>" % _("Description"))
+ html.write("<tr class=\"data even0\"><td
class=\"left\">%s</td>" % _("Description"))
html.write("<td>%s</td></tr>" %
html.attrencode(details["description"]))
- html.write("<tr class=\"data even0\"><td
class=\"left\">%s</td>" % _("Parameters"))
+ html.write("<tr class=\"data odd0\"><td
class=\"left\">%s</td>" % _("Parameters"))
html.write("<td><pre>%s</pre></td></tr>" %
html.attrencode(format_params(details["params"])))
html.write("</table>")