Module: check_mk
Branch: master
Commit: 745c3de0a9fe4b839c0a35043281864ccab77d5d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=745c3de0a9fe4b…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Nov 7 10:40:03 2013 +0100
esx_vsphere_sensors: it is now possible override the state of sensors
---
.werks/27 | 7 +++++++
ChangeLog | 1 +
checkman/esx_vsphere_sensors | 11 +++++++++++
checks/esx_vsphere_sensors | 32 ++++++++++++++++++++++++--------
web/plugins/wato/check_parameters.py | 33 ++++++++++++++++++++++++++++++++-
5 files changed, 75 insertions(+), 9 deletions(-)
diff --git a/.werks/27 b/.werks/27
new file mode 100644
index 0000000..4b07653
--- /dev/null
+++ b/.werks/27
@@ -0,0 +1,7 @@
+Title: esx_vsphere_sensors: it is now possible override the state of sensors
+Level: 2
+Component: checks
+Version: 1.2.3i7
+Date: 1383817062
+Class: feature
+
diff --git a/ChangeLog b/ChangeLog
index 42fffe9..5986f3a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
* 0063 veeam_client: new check to monitor status of veeam clients with special agent
plugin...
* 0064 veeam_jobs: new check to monitor the backup jobs of the veeam backup tool...
* 0047 Add new collection of checks to monitor Fritz!Box devices...
+ * 0027 esx_vsphere_sensors: it is now possible override the state of sensors
* 0024 FIX: cisco_wlc: removed configuration parameter ap_model...
Multisite:
diff --git a/checkman/esx_vsphere_sensors b/checkman/esx_vsphere_sensors
index 0934271..62ef5c9 100644
--- a/checkman/esx_vsphere_sensors
+++ b/checkman/esx_vsphere_sensors
@@ -12,3 +12,14 @@ description:
inventory:
One check per ESX Host System will be created.
+examples:
+ check_parameters = [
+ ([{'states': {'2': 0, '1': 0}, 'name': 'VMware
Rollup Health'}], [], ALL_HOSTS, ["Hardware Sensors"]),
+ ]
+
+[parameters]
+a list of (dict): with the following keys
+
+ {"name"}: The name of the sensor in question
+
+ {"states"}: A dictionary with with the optional keys for each sensor state and
its new value
diff --git a/checks/esx_vsphere_sensors b/checks/esx_vsphere_sensors
index 1f96016..287b108 100644
--- a/checks/esx_vsphere_sensors
+++ b/checks/esx_vsphere_sensors
@@ -32,25 +32,40 @@
def inventory_esx_vsphere_sensors(info):
return [(None, None)]
-def check_esx_vsphere_sensors(_no_item, _no_params, info):
+def check_esx_vsphere_sensors(_no_item, params, info):
state = 0
infos = []
+ sensor_state_modified = False
+
for name, base_units, current_reading, sensor_type, unit_modifier, rate_units,
health_key, health_label, health_summary in info:
if health_key == "green":
continue # usually not output by agent anyway
infos.append("%s: %s (%s)" % (name, health_label, health_summary))
+
+ sensor_state = 0
if health_key == "yellow":
- state = max(state, 1)
- infos[-1] += "(!)"
+ sensor_state = 1
elif health_key == "unknown":
- state = max(state, 1)
- infos[-1] += "(!)"
+ sensor_state = 1
else:
- state = 2
- infos[-1] += "(!!)"
+ sensor_state = 2
+
+ extra_info = ""
+ if params:
+ for entry in params:
+ if name.startswith(entry.get("name")):
+ new_state = entry.get("states").get(str(sensor_state))
+ if new_state != None:
+ sensor_state = new_state
+ extra_info = "(state modified by rule)"
+ sensor_state_modified = True
+
+ state = max(state, sensor_state)
+ infos[-1] += ["", "(!)", "(!!)",
"(!)"][state]
+ infos[-1] += extra_info
- if state > 0:
+ if state > 0 or sensor_state_modified:
return state, ", ".join(infos)
else:
return 0, "All sensors are in normal state"
@@ -59,4 +74,5 @@ check_info['esx_vsphere_sensors'] = {
"inventory_function" : inventory_esx_vsphere_sensors,
"check_function" : check_esx_vsphere_sensors,
"service_description" : "Hardware Sensors",
+ "group" : "hostsystem_sensors"
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 3bfa502..252037a 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3326,12 +3326,43 @@ register_check_parameters(
register_check_parameters(
subgroup_environment,
+ "hostsystem_sensors",
+ _("Hostsystem sensor alerts"),
+ ListOf(
+ Dictionary(
+ help = _("This rule allows to override alert levels for the given sensor
names."),
+ elements = [("name", TextAscii(title = _("Sensor name")) ),
+ ("states", Dictionary(
+ title = _("Custom states"),
+ elements = [
+ (element,
+ MonitoringState( title = "Sensor %s" %
+ description, label = _("Set state
to"),
+ default_value = int(element) )
+ ) for (element, description) in [
+ ("0", _("OK")),
+ ("1", _("WARNING")),
+ ("2", _("CRITICAL")),
+ ("3", _("UNKNOWN"))
+ ]
+ ],
+ ))],
+ optional_keys = False
+ ),
+ add_label = _("Add sensor name")
+ ),
+ None,
+ "first"
+)
+
+register_check_parameters(
+ subgroup_environment,
"temperature_auto",
_("Temperature sensors with builtin levels"),
None,
TextAscii(
title = _("Sensor ID"),
- help = _("The identificator of the themal sensor.")),
+ help = _("The identificator of the thermal sensor.")),
"first"
)