Refactoring: Moved check parameters from unsorted.py to dedicated modules (CMK-1393)
[check_mk.git] / cmk / gui / plugins / wato / check_parameters / ipmi.py
blob5c537e6f11992956db1a744d602cfe96e3854d30
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
27 from cmk.gui.i18n import _
28 from cmk.gui.valuespec import (
29 CascadingDropdown,
30 Dictionary,
31 Float,
32 ListOf,
33 ListOfStrings,
34 MonitoringState,
35 TextAscii,
36 Transform,
37 Tuple,
39 from cmk.gui.plugins.wato import (
40 RulespecGroupCheckParametersDiscovery,
41 RulespecGroupCheckParametersEnvironment,
42 register_check_parameters,
43 register_rule,
47 def transform_ipmi_inventory_rules(p):
48 if not isinstance(p, dict):
49 return p
50 if p.get("summarize", True):
51 return 'summarize'
52 if p.get('ignored_sensors', []):
53 return ('single', {'ignored_sensors': p["ignored_sensors"]})
54 return ('single', {})
57 register_rule(
58 RulespecGroupCheckParametersDiscovery,
59 varname="inventory_ipmi_rules",
60 title=_("Discovery of IPMI sensors"),
61 valuespec=Transform(
62 CascadingDropdown(
63 orientation="vertical",
64 choices=
65 [("summarize", _("Summary")),
66 ("single", _("Single"),
67 Dictionary(
68 show_titles=True,
69 elements=[
70 ("ignored_sensors",
71 ListOfStrings(
72 title=_("Ignore the following IPMI sensors"),
73 help=_("Names of IPMI sensors that should be ignored during inventory "
74 "and when summarizing."
75 "The pattern specified here must match exactly the beginning of "
76 "the actual sensor name (case sensitive)."),
77 orientation="horizontal")),
78 ("ignored_sensorstates",
79 ListOfStrings(
80 title=_("Ignore the following IPMI sensor states"),
81 help=_(
82 "IPMI sensors with these states that should be ignored during inventory "
83 "and when summarizing."
84 "The pattern specified here must match exactly the beginning of "
85 "the actual sensor name (case sensitive)."),
86 orientation="horizontal",
87 )),
88 ]))]),
89 forth=transform_ipmi_inventory_rules),
90 match='first')
92 register_check_parameters(
93 RulespecGroupCheckParametersEnvironment,
94 "ipmi",
95 _("IPMI sensors"),
96 Dictionary(
97 elements=[
98 ("sensor_states",
99 ListOf(
100 Tuple(elements=[TextAscii(), MonitoringState()]),
101 title=_("Set states of IPMI sensor status texts"),
102 help=_("The pattern specified here must match exactly the beginning of "
103 "the sensor state (case sensitive)."),
104 orientation="horizontal",
106 ("ignored_sensors",
107 ListOfStrings(
108 title=_("Ignore the following IPMI sensors"),
109 help=_("Names of IPMI sensors that should be ignored during discovery "
110 "and when summarizing."
111 "The pattern specified here must match exactly the beginning of "
112 "the actual sensor name (case sensitive)."),
113 orientation="horizontal")),
114 ("ignored_sensorstates",
115 ListOfStrings(
116 title=_("Ignore the following IPMI sensor states"),
117 help=_("IPMI sensors with these states that should be ignored during discovery "
118 "and when summarizing."
119 "The pattern specified here must match exactly the beginning of "
120 "the actual sensor name (case sensitive)."),
121 orientation="horizontal",
122 default_value=["nr", "ns"])),
123 ("numerical_sensor_levels",
124 ListOf(
125 Tuple(
126 elements=[
127 TextAscii(
128 title=_("Sensor name (only summary)"),
129 help=_(
130 "In summary mode you have to state the sensor name. "
131 "In single mode the sensor name comes from service description.")),
132 Dictionary(elements=[
133 ("lower",
134 Tuple(title=_("Lower levels"), elements=[Float(), Float()])),
135 ("upper",
136 Tuple(title=_("Upper levels"), elements=[Float(), Float()])),
138 ],),
139 title=_("Set lower and upper levels for numerical sensors"))),
141 ignored_keys=["ignored_sensors", "ignored_sensor_states"],
143 TextAscii(title=_("The sensor name")),
144 "dict",