Module: check_mk
Branch: master
Commit: 7c05b8ed51cab545d6946d70db554ffc3cae5669
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7c05b8ed51cab5…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun May 27 12:35:46 2012 +0200
new ValueSpec MonitoringState removes reduntant code
---
web/htdocs/valuespec.py | 10 ++++++++++
web/htdocs/wato.py | 2 +-
web/plugins/wato/check_parameters.py | 21 +++++----------------
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 5e3e858..1a5c77d 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -772,6 +772,16 @@ class DropdownChoice(ValueSpec):
", ".join([v for (v,t) in self._choices]))
+# Special conveniance variant for monitoring states
+class MonitoringState(DropdownChoice):
+ def __init__(self, **kwargs):
+ choices = [ ( 0, _("OK")),
+ ( 1, _("WARN")),
+ ( 2, _("CRIT")),
+ ( 3, _("UNKNOWN")) ]
+ kwargs.setdefault("default_value", 0)
+ DropdownChoice.__init__(self, choices=choices, **kwargs)
+
# A Dropdown choice where the elements are ValueSpecs.
# The currently selected ValueSpec will be displayed.
# The text representations of the ValueSpecs will be used as texts.
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index e4aa2ce..36a1a98 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -9944,7 +9944,7 @@ def mode_edit_rule(phase):
forms.section("")
for posneg, img in [ ("positive", "yes"),
("negative", "no")]:
val = img == "yes"
- html.write('<img align=top src="images/rule_%s.png">
' % img)
+ html.write('<img class=ruleyesno align=top
src="images/rule_%s.png"> ' % img)
html.radiobutton("value", img, value == val, _("Make the
outcome of the ruleset <b>%s</b><br>") % posneg)
# Conditions
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index d06f2fa..bcaadcf 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1176,16 +1176,10 @@ checkgroups.append((
( "auto", _("auto") ),
( "unknown", _("unknown (old agent)")
),
]),
- DropdownChoice(
+ MonitoringState(
title = _("Resulting state"),
- default_value = 0,
- choices = [
- ( 0, _("OK")),
- ( 1, _("WARN")),
- ( 2, _("CRIT")),
- ( 3, _("UNKNWON")),
- ]),
- ],
+ ),
+ ],
default_value = ( "running", "auto", 0)),
title = _("Services states"),
help = _("You can specify a separate monitoring state for each
possible "
@@ -1193,15 +1187,10 @@ checkgroups.append((
"this parameter, then only running/auto will be assumed to
be OK."),
)),
( "else",
- DropdownChoice(
+ MonitoringState(
title = _("State if no entry matches"),
default_value = 2,
- choices = [
- ( 0, _("OK")),
- ( 1, _("WARN")),
- ( 2, _("CRIT")),
- ( 3, _("UNKNWON")),
- ]),
+ ),
),]
),
TextAscii(