Module: check_mk
Branch: master
Commit: e8cda2c3695b92a3d4fd4a7aa01f9fe73c0ccece
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e8cda2c3695b92…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri Dec 16 17:41:16 2011 +0100
ADD Wato: New varspec for age
---
web/htdocs/wato.py | 37 ++++++++++++++++++++++++++++++++++
web/plugins/wato/check_parameters.py | 31 ++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8c50e3b..d86b6ac 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -4263,8 +4263,45 @@ class FixedValue(ValueSpec):
def validate_value(self, value, varprefix):
self.validate_datatype(value, varprefix)
+
+# Time in seconds
+class Age(ValueSpec):
+ def __init__(self, **kwargs):
+ ValueSpec.__init__(self, **kwargs)
+ self._label = kwargs.get("label")
+
+ def canonical_value(self):
+ return 0
+
+ def render_input(self, varprefix, value):
+ days, rest = divmod(value, 60*60*24)
+ hours, rest = divmod(rest, 60*60)
+ minutes, seconds = divmod(rest, 60)
+ html.write("<div>")
+ html.number_input(varprefix+'_days', days, 2)
+ html.write(_("days"))
+ html.number_input(varprefix+'_hour', hours, 2)
+ html.write(_("hours"))
+ html.number_input(varprefix+'_minutes', minutes, 2)
+ html.write(_("min"))
+ html.number_input(varprefix+'_seconds', seconds, 2)
+ html.write(_("sec"))
+ html.write("</div>")
+ def from_html_vars(self, varprefix):
+ return (saveint(html.var(varprefix+'_hour'))*3600) +
(saveint(html.var(varprefix+'_minutes'))*60) +
saveint(html.var(varprefix+'_seconds'))
+
+ def value_to_text(self, value):
+ days, rest = divmod(value, 60*60*24)
+ hours, rest = divmod(rest, 60*60)
+ minutes, seconds = divmod(rest, 60)
+ return "%sd %sh %sm %ss" % (days, hours, minutes, seconds)
+
+ def validate_datatype(self, value, varprefix):
+ if type(value) != int:
+ raise MKUserError(varprefix, _("The value has type %s, but must be of
type int") % (type(value)))
+
# Editor for a single integer
class Integer(ValueSpec):
def __init__(self, **kwargs):
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 69fe98d..4f6b6bb 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -253,6 +253,37 @@ checkgroups.append((
"first"
))
+checkgroups.append((
+ "fileinfo",
+ _("Fileinfo"),
+ Dictionary(
+ elements = [
+ ( "minage",
+ Tuple(
+ title = _("Minimal age"),
+ elements = [
+ Age(title = _("Warning younger then")),
+ Age(title = _("Critical younger then")),
+ ]
+ )
+ ),
+ ( "maxage",
+ Tuple(
+ title = _("Maximal age"),
+ elements = [
+ Age(title = _("Warning older then")),
+ Age(title = _("Critical older then")),
+ ]
+ )
+ ),
+
+
+ ]
+ ),
+ None,
+ "first"
+))
+
checkgroups.append((
"tcp_conn_stats",
("TCP connection stats"),