Module: check_mk
Branch: master
Commit: 87f31155dff73bfcefff5ea91c30b3b1561b907a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=87f31155dff73b…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 25 11:20:02 2013 +0100
Fix several ValueSpec display errors in WATO inventory
---
checks/kernel | 2 +-
web/htdocs/valuespec.py | 13 ++++++++-----
web/htdocs/wato.py | 4 ++--
web/plugins/wato/check_parameters.py | 18 ++++++++++--------
4 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/checks/kernel b/checks/kernel
index 9687be8..297a659 100644
--- a/checks/kernel
+++ b/checks/kernel
@@ -26,7 +26,7 @@
# Inventory creates three checks per default:
inventory_kernel_counters = [ "pgmajfault", "ctxt",
"processes" ]
-kernel_default_levels = (None, None)
+kernel_default_levels = None
kernel_counter_names = {
"ctxt" : "Context Switches",
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 8b805ca..ca91c4c 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -194,7 +194,7 @@ class Integer(ValueSpec):
self._display_format = kwargs.get("display_format", "%d")
self._align = kwargs.get("align", "left")
- if "size" not in kwargs and "maxvalue" in kwargs:
+ if "size" not in kwargs and "maxvalue" in kwargs and
kwargs["maxvalue"] != None:
self._size = 1 + int(math.log10(self._maxvalue)) + \
(type(self._maxvalue) == float and 3 or 0)
@@ -779,6 +779,7 @@ class Float(Integer):
Integer.__init__(self, **kwargs)
self._decimal_separator = kwargs.get("decimal_separator",
".")
self._display_format = kwargs.get("display_format", "%.2f")
+ self._accept_int = kwargs.get("accept_int", False)
def canonical_value(self):
return float(Integer.canonical_value(self))
@@ -794,16 +795,18 @@ class Float(Integer):
_("The text <b><tt>%s</tt></b> is not a valid
floating point number." % html.var(varprefix)))
def validate_datatype(self, value, varprefix):
- if type(value) != float:
- raise MKUserError(varprefix, _("The value %r has type %s, but must be of
type float") % (value, type(value)))
+ if type(value) != float and not \
+ (type(value) == int and self._accept_int):
+ raise MKUserError(varprefix, _("The value %r has type %s, but must be of
type float%s") %
+ (value, type(value), self._accept_int and _(" or int") or
""))
class Percentage(Float):
def __init__(self, **kwargs):
Integer.__init__(self, **kwargs)
- if "min_value" not in kwargs:
+ if "minvalue" not in kwargs:
self._minvalue = 0.0
- if "max_value" not in kwargs:
+ if "maxvalue" not in kwargs:
self._maxvalue = 101.0
if "unit" not in kwargs:
self._unit = "%"
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 08d04d5..aa4f096 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -11136,8 +11136,8 @@ def Levels(**kwargs):
Tuple(
title = _("Fixed Levels"),
elements = [
- Float(unit = unit, title = _("Warning at"), default_value
= default_levels[0]),
- Float(unit = unit, title = _("Critical at"),
default_value = default_levels[1]),
+ Float(unit = unit, title = _("Warning at"), default_value
= default_levels[0], accept_int = True),
+ Float(unit = unit, title = _("Critical at"),
default_value = default_levels[1], accept_int = True),
],
),
PredictiveLevels(
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index c5a3d4f..0a75123 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1368,8 +1368,8 @@ register_check_parameters(
Tuple(
title = _("Percentual levels (in relation to policy
speed)"),
elements = [
- Percentage(title = _("Warning at"),
max_value=1000, label = _("% of port speed")),
- Percentage(title = _("Critical at"),
max_value=1000, label = _("% of port speed")),
+ Percentage(title = _("Warning at"),
maxvalue=1000, label = _("% of port speed")),
+ Percentage(title = _("Critical at"),
maxvalue=1000, label = _("% of port speed")),
]
),
Tuple(
@@ -1402,8 +1402,8 @@ register_check_parameters(
Tuple(
title = _("Percentual levels (in relation to policy
speed)"),
elements = [
- Percentage(title = _("Warning at"),
max_value=1000, label = _("% of port speed")),
- Percentage(title = _("Critical at"),
max_value=1000, label = _("% of port speed")),
+ Percentage(title = _("Warning at"),
maxvalue=1000, label = _("% of port speed")),
+ Percentage(title = _("Critical at"),
maxvalue=1000, label = _("% of port speed")),
]
),
Tuple(
@@ -1430,8 +1430,8 @@ register_check_parameters(
Tuple(
title = _("Specify levels in percentage of total RAM"),
elements = [
- Percentage(title = _("Warning at a usage of"), label =
_("% of RAM"), max_value = None),
- Percentage(title = _("Critical at a usage of"), label =
_("% of RAM"), max_value = None)
+ Percentage(title = _("Warning at a usage of"), label =
_("% of RAM"), maxvalue = None),
+ Percentage(title = _("Critical at a usage of"), label =
_("% of RAM"), maxvalue = None)
]
),
Tuple(
@@ -1466,8 +1466,10 @@ register_check_parameters(
Tuple(
title = _("Specify levels in percentage of total RAM"),
elements = [
- Percentage(title = _("Warning at a memory usage of"),
default_value = 80.0),
- Percentage(title = _("Critical at a memory usage of"),
default_value = 90.0)]),
+ # Disable limit of value to 101%, because levels > 100% make sense
here
+ # (swap+ram is > ram)
+ Percentage(title = _("Warning at a memory usage of"),
default_value = 80.0, maxvalue = None),
+ Percentage(title = _("Critical at a memory usage of"),
default_value = 90.0, maxvalue = None)]),
Tuple(
title = _("Specify levels in absolute usage values"),
elements = [