Module: check_mk
Branch: master
Commit: 54afce4ff26727be287d22f4b69a883f65e29a3e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=54afce4ff26727…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Oct 18 16:58:26 2017 +0200
Profiling can now be enabled per HTTP request
Change-Id: I31cc9738d938e63b95a8b34d31e9a01c7549bd5e
---
web/htdocs/index.py | 36 ++++++++++++++++++------------
web/plugins/wato/check_mk_configuration.py | 19 +++++++++++-----
2 files changed, 35 insertions(+), 20 deletions(-)
diff --git a/web/htdocs/index.py b/web/htdocs/index.py
index a0f29dd..099073d 100644
--- a/web/htdocs/index.py
+++ b/web/htdocs/index.py
@@ -239,24 +239,32 @@ def init_sys_path():
def init_profiling(is_profiling):
- if not is_profiling and config.profile:
- import cProfile
+ if is_profiling:
+ return # Don't start again when already profiling
- # Ubuntu: install python-profiler when using this feature
- profile_file = cmk.paths.var_dir + "/multisite.profile"
+ if config.profile == False:
+ return # Not enabled
- p = cProfile.Profile()
- p.runcall(handler, html.req, html.fields, True)
- p.dump_stats(profile_file)
+ if config.profile == "enable_by_var" and not html.has_var("_profile"):
+ return # Not enabled by HTTP variable
- file(profile_file + ".py", "w").write(
- "#!/usr/bin/env python\n"
- "import pstats\n"
- "stats = pstats.Stats(%r)\n"
- "stats.sort_stats('time').print_stats()\n" % profile_file)
- os.chmod(profile_file + ".py", 0755)
+ import cProfile
- raise FinalizeRequest()
+ # Ubuntu: install python-profiler when using this feature
+ profile_file = cmk.paths.var_dir + "/multisite.profile"
+
+ p = cProfile.Profile()
+ p.runcall(handler, html.req, html.fields, True)
+ p.dump_stats(profile_file)
+
+ file(profile_file + ".py", "w").write(
+ "#!/usr/bin/env python\n"
+ "import pstats\n"
+ "stats = pstats.Stats(%r)\n"
+ "stats.sort_stats('time').print_stats()\n" % profile_file)
+ os.chmod(profile_file + ".py", 0755)
+
+ raise FinalizeRequest()
# Early initialization upon first start of the application by the server
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index e579999..c127b7f 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -110,14 +110,21 @@ register_configvar(group,
register_configvar(group,
"profile",
- Checkbox(
+ DropdownChoice(
title = _("Profile requests"),
- label = _("enable profile mode"),
help = _("It is possible to profile the rendering process of Multisite pages. This "
- "Is done using the Python module cProfile. When enabled two files are placed "
- "into the Multisite var directory named <tt>multisite.profile</tt> and "
- "<tt>multisite.profile.py</tt>. By executing the later file you can get "
- "runtime statistics about the last processed page."),
+ "Is done using the Python module cProfile. When profiling is performed "
+ "two files are created <tt>%s</tt> and <tt>%s</tt>. By executing the later "
+ "file you can get runtime statistics about the last processed page. When "
+ "enabled by request the profiling mode is enabled by providing the HTTP "
+ "variable <tt>_profile</tt>.") %
+ (site_neutral_path(cmk.paths.var_dir + "/multisite.profile"),
+ site_neutral_path(cmk.paths.var_dir + "/multisite.profile.py")),
+ choices = [
+ (False, _("Disable profiling")),
+ ("enable_by_var", _("Enable profiling by request")),
+ (True, _("Enable profiling for all requests")),
+ ],
),
domain = "multisite"
)
Module: check_mk
Branch: master
Commit: 74e85d40ca2402ecf48d3a37a6a79b7194f1db34
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=74e85d40ca2402…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Wed Oct 18 13:23:22 2017 +0200
5345 FIX mssql_backup: fix GUI error and show warn/crit values
Fixes an error visible in the GUI when no parameters are present
for the check. The check now also shows warn and crit values for
a backup type if it is in a warning or critical state.
Change-Id: I251d6a9880943df55037d864d4ab199df29c6229
---
.werks/5345 | 12 ++++++++++++
checks/mssql_backup | 26 +++++++++++++++-----------
2 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/.werks/5345 b/.werks/5345
new file mode 100644
index 0000000..8c00bcd
--- /dev/null
+++ b/.werks/5345
@@ -0,0 +1,12 @@
+Title: mssql_backup: fix GUI error and show warn/crit values
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1508325570
+Class: fix
+
+Fixes an error visible in the GUI when no parameters are present
+for the check. The check now also shows warn and crit values for
+a backup type if it is in a warning or critical state.
diff --git a/checks/mssql_backup b/checks/mssql_backup
index 7331bb5..5a826db 100644
--- a/checks/mssql_backup
+++ b/checks/mssql_backup
@@ -48,16 +48,15 @@
# Might be None to have no thresholds or a tuple of two ints
# (<warn age in seconds>, <crit age in seconds>)
-### mssql_backup_default_levels = None
factory_settings["mssql_backup_default_levels"] = {
- "database": (None, None),
- "database_diff": (None, None),
- "log": (None, None),
- "file_or_filegroup": (None, None),
- "file_diff": (None, None),
- "partial": (None, None),
- "partial_diff": (None, None),
- "unspecific": (None, None)
+ "database": (0, 0),
+ "database_diff": (0, 0),
+ "log": (0, 0),
+ "file_or_filegroup": (0, 0),
+ "file_diff": (0, 0),
+ "partial": (0, 0),
+ "partial_diff": (0, 0),
+ "unspecific": (0, 0)
}
@@ -134,11 +133,11 @@ def check_mssql_backup(item, params, parsed):
age_warn, age_crit = params["database"]
else:
backup_type_var = backup_type_name.strip().replace(" ", "_")
- age_warn, age_crit = params.get(backup_type_var, (None, None))
+ age_warn, age_crit = params[backup_type_var]
state = 0
sec_ago = time.time() - timestamp
- if age_warn is not None and age_crit is not None:
+ if age_warn > 0 and age_crit > 0:
if sec_ago >= age_crit:
state = 2
elif sec_ago >= age_warn:
@@ -151,6 +150,11 @@ def check_mssql_backup(item, params, parsed):
get_age_human_readable(sec_ago)
)
+ if state != 0:
+ infotext += " (warn/crit at %s/%s)" % (
+ get_age_human_readable(age_warn), get_age_human_readable(age_crit)
+ )
+
yield state, infotext, perfdata
if not found_instance: