Module: check_mk
Branch: master
Commit: 9e25c7b620a6f2b566c157c98ade89f81a75f654
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9e25c7b620a6f2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 20 10:31:16 2017 +0100
5532 Host/Service states and outputs can now be translated
The states and service status detail of hosts and services can now be translated. You can
now
use the rules {{Host state translation}} and {{Service state translation}} to configure
the
Check_MK core to translate either specific states to other states or the status detail to
other
texts.
States: For each host/service you can configure a transformation of each possible
monitoring state
to another one.
The state translation can, for example, be used to inverse a host check in case you want
to get
a notification in case a host becomes reachable.
The translation of detail outputs is done using regular expressions. You can specify
multiple
regular expressions (infix match, case sensitive) per object which are applied to the
current
status detail. The matched text will be replaced by the specified replacement text. You
can
use match groups to extract parts of the original text using the regular expression.
Change-Id: I1f81a91bfbedcf3a3f14566fe5a7a121418f38fe
---
.werks/5532 | 24 ++++++++++++++++++++++++
web/htdocs/valuespec.py | 12 ++++++++++++
2 files changed, 36 insertions(+)
diff --git a/.werks/5532 b/.werks/5532
new file mode 100644
index 0000000..c9f53df
--- /dev/null
+++ b/.werks/5532
@@ -0,0 +1,24 @@
+Title: Host/Service states and outputs can now be translated
+Level: 2
+Component: cmc
+Compatible: compat
+Edition: cee
+Version: 1.5.0i2
+Date: 1511169817
+Class: feature
+
+The states and service status detail of hosts and services can now be translated. You can
now
+use the rules {{Host state translation}} and {{Service state translation}} to configure
the
+Check_MK core to translate either specific states to other states or the status detail to
other
+texts.
+
+States: For each host/service you can configure a transformation of each possible
monitoring state
+to another one.
+
+The state translation can, for example, be used to inverse a host check in case you want
to get
+a notification in case a host becomes reachable.
+
+The translation of detail outputs is done using regular expressions. You can specify
multiple
+regular expressions (infix match, case sensitive) per object which are applied to the
current
+status detail. The matched text will be replaced by the specified replacement text. You
can
+use match groups to extract parts of the original text using the regular expression.
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index 8de080f..a09712a 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -1733,6 +1733,7 @@ class DropdownChoice(ValueSpec):
# Special conveniance variant for monitoring states
+# TODO: Rename to ServiceState() or something like this
class MonitoringState(DropdownChoice):
def __init__(self, **kwargs):
choices = [ ( 0, _("OK")),
@@ -1742,6 +1743,17 @@ class MonitoringState(DropdownChoice):
kwargs.setdefault("default_value", 0)
DropdownChoice.__init__(self, choices=choices, **kwargs)
+
+class HostState(DropdownChoice):
+ def __init__(self, **kwargs):
+ choices = [
+ ( 0, _("UP")),
+ ( 1, _("DOWN")),
+ ( 2, _("UNREACHABLE")),
+ ]
+ 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.