Module: check_mk
Branch: master
Commit: bd6468fb460ce822b037bc1188fdd460f289ce03
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bd6468fb460ce8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 27 15:01:55 2012 +0200
search for rules in "Host & Service Configuration"
---
ChangeLog | 1 +
web/htdocs/wato.py | 42 +++++++++++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f84d053..3055a7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,7 @@
* Implemented new option in WATO attributes: editable
When set to False the attribute can only be changed during creation
of a new object. When editing an object this attribute is only displayed.
+ * new: search for rules in "Host & Service Configuration"
BI:
* Great speed up of rule compilation in large environments
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 1050e3f..ed69bc3 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -9356,15 +9356,39 @@ def mode_ruleeditor(phase):
help = help.split('\n')[0] # Take only first line as button text
menu.append((url, title, icon, "rulesets", help))
render_main_menu(menu)
+
+ html.write("<BR>")
+ rule_search_form()
+def rule_search_form():
+ html.begin_form("search")
+ html.write(_("Search for rules: "))
+ html.text_input("search", size=32)
+ html.hidden_fields()
+ html.hidden_field("mode", "rulesets")
+ html.set_focus("search")
+ html.write(" ")
+ html.button("_do_seach", _("Search"))
+ html.end_form()
+ html.write("<br>")
+
+
def mode_rulesets(phase):
group = html.var("group") # obligatory
+ search = html.var("search")
+ if search != None:
+ search = search.strip().lower()
+
if group == "used":
title = _("Used Rulesets")
help = _("Non-empty rulesets")
only_used = True
+ elif search != None:
+ title = _("Rules matching ") + search
+ help = _("All rules that contain '%s' in their name of help") % search
+ only_used = False
else:
title, help = g_rulegroups.get(group, (group, None))
only_used = False
@@ -9397,6 +9421,9 @@ def mode_rulesets(phase):
if not only_host:
render_folder_path(keepvarnames = ["mode", "local", "group"])
+ if search != None:
+ rule_search_form()
+
if help != None:
help = "".join(help.split("\n", 1)[1:]).strip()
if help:
@@ -9415,8 +9442,7 @@ def mode_rulesets(phase):
# Select matching rule groups while keeping their configured order
groupnames = [ gn for gn, rulesets in g_rulespec_groups
- if only_used or gn == group or gn.startswith(group + "/") ]
- do_folding = len(groupnames) > 1
+ if only_used or search != None or gn == group or gn.startswith(group + "/") ]
something_shown = False
html.write('<div class=rulesets>')
@@ -9431,11 +9457,21 @@ def mode_rulesets(phase):
varname = rulespec["varname"]
valuespec = rulespec["valuespec"]
+
+ # handle only_used
rules = all_rulesets.get(varname, [])
num_rules = len(rules)
if num_rules == 0 and (only_used or only_local):
continue
+ # handle search
+ if search != None \
+ and not (rulespec["help"] and search in rulespec["help"].lower()) \
+ and search not in rulespec["title"].lower() \
+ and search not in varname:
+ continue
+
+
# Handle case where a host is specified
rulespec = g_rulespecs[varname]
this_host = False
@@ -9451,7 +9487,7 @@ def mode_rulesets(phase):
if only_local and num_local_rules == 0:
continue
- if only_used:
+ if only_used or search != None:
titlename = g_rulegroups[groupname.split("/")[0]][0]
else:
if '/' in groupname:
Module: check_mk
Branch: master
Commit: dba4dd191c16981b60065172afbe70bbd6c056a4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dba4dd191c1698…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 27 14:24:01 2012 +0200
cmctc.temp: added parameters for warn/crit
---
ChangeLog | 2 +
checkman/cmctc.temp | 14 +++++++--
checks/cmctc | 81 ++++++++++++++++++++++++++++----------------------
checks/cmctc_lcp | 2 +-
4 files changed, 59 insertions(+), 40 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6668ccd..f84d053 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,8 @@
* added perf-o-meters for a lot of temperature checks
* cmctc_lcp.*: added new checks for Rittal CMC-TC LCP
* FIX: diskstat (linux): Don't inventorize check when data empty
+ * cmctc.temp: added parameters for warn/crit, use now WATO rule
+ "Room temperature (external thermal sensors)"
WATO:
* Added permission to control the "clone host" feature in WATO
diff --git a/checkman/cmctc.temp b/checkman/cmctc.temp
index 79eb551..27d9974 100644
--- a/checkman/cmctc.temp
+++ b/checkman/cmctc.temp
@@ -6,9 +6,11 @@ distribution: check_mk
description:
This check polls the state of temperature sensors
attached to a ComputerMultiControl-TopConcept unit.
- Warning and critical levels are read via SNMP and
- need to be configured in Nagios. Configure them
- in your CMC unit.
+ Per default warning and critical levels are read via SNMP and
+ need to be configured in Check_Mk. Configure them
+ in your CMC unit. It is also possible to configure
+ levels. That way the state and levels from the SNMP
+ output are being ignored.
item:
Combination of IO unit number (3-6) and sensors index (1-4).
@@ -19,3 +21,9 @@ perfdata:
inventory:
All available temperature sensors are automatically inventorized.
+
+[parameters]
+warn(int): Optional warning level for the temperature. If you use no
+ parameters, then the builtin state will be used (this is the default).
+crit(int): Critical level for the temperature.
+
diff --git a/checks/cmctc b/checks/cmctc
index 7c1655d..e46896f 100644
--- a/checks/cmctc
+++ b/checks/cmctc
@@ -37,7 +37,7 @@
def inventory_cmctc_temp(info):
return [ (line[0], None) for line in info if saveint(line[1]) == 10 ]
-def check_cmctc_temp(item, _no_params, info):
+def check_cmctc_temp(item, params, info):
for line in info: # , value1, value2 in info:
if line[0] != item:
continue
@@ -53,50 +53,59 @@ def check_cmctc_temp(item, _no_params, info):
"8" : "tooLow",
"9" : "tooHigh",
}
- status, current, crit, low, warn, descr = line[2:8]
-
- info_text = " - %s at %sC" % (descr, current)
+ status, current, crit, low, warn = map(int, line[2:7])
+ descr = line[7]
+ info_text = " - %s at %d°C" % (descr, current)
+ if params:
+ warn, crit = params
+ if current >= crit:
+ status = 2
+ elif current >= warn:
+ status = 7
levels_text = " (warn/crit at %sC/%sC)" % (warn, crit)
status_is = ", status is %s" % status_text.get(status, "UNKNOWN")
perfdata = [ ("temp", current, warn, crit, 0 ) ]
- if status == "7":
+ if status == 7:
return (1, "WARNING" + info_text + levels_text, perfdata)
- elif status == "8":
+ elif status == 8:
return (1, "WARNING" + info_text + ": too low (below %sC)" % low, perfdata)
- elif status == "4":
+ elif status == 4:
return (0, "OK" + info_text, perfdata)
else:
return (2, "CRIT" + info_text + levels_text + status_is, perfdata)
return (3, "UNKNOWN - Sensor %s not found in SNMP data" % item)
-check_info['cmctc.temp'] = (check_cmctc_temp, "Temperature %s", 1, inventory_cmctc_temp)
-snmp_info['cmctc'] = (
- # Base to all IO units
- ".1.3.6.1.4.1.2606.4.2",
- # Each of the up to 4 units has its own subtree
- ["3", "4", "5", "6"],
- [
- # sensors index (1-4)
- "5.2.1.1",
- # sensor type (10 = temperature)
- "5.2.1.2",
- # unit status: notAvail(1), lost(2), changed(3), ok(4), off(5), on(6), warning(7), tooLow(8), tooHigh(9)
- "5.2.1.4",
- # current value
- "5.2.1.5",
- # high value (used for critical state)
- "5.2.1.6",
- # low value (used for warning, if temp falls below this value)
- "5.2.1.7",
- # warn value (used for warning state)
- "5.2.1.8",
- # description (configured by user via admin interface)
- "7.2.1.2"
- ]
- )
-
-snmp_scan_functions["cmctc.temp"] = \
- lambda oid: "CMC-TC" in oid(".1.3.6.1.2.1.1.1.0")
+check_info['cmctc.temp'] = {
+ "check_function" : check_cmctc_temp,
+ "inventory_function" : inventory_cmctc_temp,
+ "has_perfdata" : True,
+ "service_description" : "Temperature %s",
+ "group" : "room_temperature",
+ "snmp_scan_function" : lambda oid: "CMC-TC" in oid(".1.3.6.1.2.1.1.1.0"),
+ "snmp_info" : (
+ # Base to all IO units
+ ".1.3.6.1.4.1.2606.4.2",
+ # Each of the up to 4 units has its own subtree
+ ["3", "4", "5", "6"],
+ [
+ # sensors index (1-4)
+ "5.2.1.1",
+ # sensor type (10 = temperature)
+ "5.2.1.2",
+ # unit status: notAvail(1), lost(2), changed(3), ok(4), off(5), on(6), warning(7), tooLow(8), tooHigh(9)
+ "5.2.1.4",
+ # current value
+ "5.2.1.5",
+ # high value (used for critical state)
+ "5.2.1.6",
+ # low value (used for warning, if temp falls below this value)
+ "5.2.1.7",
+ # warn value (used for warning state)
+ "5.2.1.8",
+ # description (configured by user via admin interface)
+ "7.2.1.2",
+ ]
+ ),
+}
-checkgroup_of["cmctc.temp"] = "temperature_auto"
diff --git a/checks/cmctc_lcp b/checks/cmctc_lcp
index 83a3323..f8e2dde 100644
--- a/checks/cmctc_lcp
+++ b/checks/cmctc_lcp
@@ -166,7 +166,7 @@ cmctc_lcp_sensortypes = {
def inventory_cmctc_lcp(info, sensortype):
inventory = []
for index, typeid, status, value, description in info:
- typeid = int(typeid)
+ typeid = saveint(typeid)
if typeid in cmctc_lcp_sensors:
item, st = cmctc_lcp_sensors[typeid]
if st == sensortype:
Module: check_mk
Branch: master
Commit: 89b922b7661ec65e6f4c21d787b4120819ac5556
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=89b922b7661ec6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 27 13:15:28 2012 +0200
cmctc_lcp.*: added new checks for Rittal CMC-TC LCP
---
ChangeLog | 1 +
checkman/cmctc_lcp.blower | 19 +++++++++++++++++++
checkman/cmctc_lcp.blowergrade | 16 ++++++++++++++++
checkman/cmctc_lcp.flow | 19 +++++++++++++++++++
checkman/cmctc_lcp.regulator | 19 +++++++++++++++++++
checkman/cmctc_lcp.temp | 23 +++++++++++++++++++++++
6 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2982234..e6c5927 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@
* FIX: mssql agent: Added compatibility code for MSSQL 9
* f5_bigip_temp: add performance data
* added perf-o-meters for a lot of temperature checks
+ * cmctc_lcp.*: added new checks for Rittal CMC-TC LCP
WATO:
* Added permission to control the "clone host" feature in WATO
diff --git a/checkman/cmctc_lcp.blower b/checkman/cmctc_lcp.blower
new file mode 100644
index 0000000..c56255d
--- /dev/null
+++ b/checkman/cmctc_lcp.blower
@@ -0,0 +1,19 @@
+title: Rittal CMC-TC LCP Blowers
+agents: snmp
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ Check the state of blowers of a Rittal CMC-TC LCP.
+
+item:
+ A descriptive name of the sensor, followed by " - ", followed by
+ the combination of IO unit number (3-6) and sensors index (1-4).
+ Example: {"3.2"} for first IO unit and second sensor.
+
+perfdata:
+ One variable: the current rotation speed of the blower in RPM
+
+inventory:
+ All available blowers sensors are automatically inventorized.
+
diff --git a/checkman/cmctc_lcp.blowergrade b/checkman/cmctc_lcp.blowergrade
new file mode 100644
index 0000000..d7d05b1
--- /dev/null
+++ b/checkman/cmctc_lcp.blowergrade
@@ -0,0 +1,16 @@
+title: Rittal CMC-TC LCP Blower total state
+agents: snmp
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ Check the state of blowers of a Rittal CMC-TC LCP.
+
+item:
+ A descriptive name of the sensor, followed by " - ", followed by
+ the combination of IO unit number (3-6) and sensors index (1-4).
+ Example: {"3.2"} for first IO unit and second sensor.
+
+inventory:
+ One check per LCP will be created
+
diff --git a/checkman/cmctc_lcp.flow b/checkman/cmctc_lcp.flow
new file mode 100644
index 0000000..de346c3
--- /dev/null
+++ b/checkman/cmctc_lcp.flow
@@ -0,0 +1,19 @@
+title: Rittal CMC-TC LCP Water flow
+agents: snmp
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ Check the speed of the water flow of a Rittal CMC-TC LCP.
+
+item:
+ A descriptive name of the sensor, followed by " - ", followed by
+ the combination of IO unit number (3-6) and sensors index (1-4).
+ Example: {"3.2"} for first IO unit and second sensor.
+
+perfdata:
+ One variable: the current flow in liters per second
+
+inventory:
+ One check per LCP will be generated.
+
diff --git a/checkman/cmctc_lcp.regulator b/checkman/cmctc_lcp.regulator
new file mode 100644
index 0000000..81ae101
--- /dev/null
+++ b/checkman/cmctc_lcp.regulator
@@ -0,0 +1,19 @@
+title: Rittal CMC-TC LCP Regulator
+agents: snmp
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ Check the percentage of the regular of a Rittal CMC-TC LCP.
+
+item:
+ A descriptive name of the sensor, followed by " - ", followed by
+ the combination of IO unit number (3-6) and sensors index (1-4).
+ Example: {"3.2"} for first IO unit and second sensor.
+
+perfdata:
+ One variable: the current percentage of the regulator
+
+inventory:
+ One check per LCP will be generated.
+
diff --git a/checkman/cmctc_lcp.temp b/checkman/cmctc_lcp.temp
new file mode 100644
index 0000000..b896b0d
--- /dev/null
+++ b/checkman/cmctc_lcp.temp
@@ -0,0 +1,23 @@
+title: Rittal CMC-TC LCP Temperature sensors
+agents: snmp
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ This check polls the state of temperature sensors of a Rittal LCP.
+
+item:
+ A descriptive name of the sensor, followed by " - ", followed by
+ the combination of IO unit number (3-6) and sensors index (1-4).
+ Example: {"3.2"} for first IO unit and second sensor.
+
+perfdata:
+ One variable: the current temperature in degrees celsius.
+
+inventory:
+ All available temperature sensors are automatically inventorized.
+
+[parameters]
+warn(int): Optional warning level for the temperature. If you use no
+ parameters, then the builtin state will be used (this is the default).
+crit(int): Critical level for the temperature.