2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
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 # Note: Sometimes the esx_vsphere_sensors check reports incorrect sensor data.
28 # The reason is that the data is cached on the esx system. In the worst case some sensors
29 # might get stuck in an unhealthy state. You can find more information under the following link:
30 # http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=1037330
32 # <<<esx_vsphere_sensors:sep(59)>>>
33 # VMware Rollup Health State;;0;system;0;;red;Red;Sensor is operating under critical conditions
34 # Power Domain 1 Power Unit 0 - Redundancy lost;;0;power;0;;yellow;Yellow;Sensor is operating under conditions that are non-critical
35 # Power Supply 2 Power Supply 2 0: Power Supply AC lost - Assert;;0;power;0;;red;Red;Sensor is operating under critical conditions
38 def inventory_esx_vsphere_sensors(info
):
42 def check_esx_vsphere_sensors(_no_item
, params
, info
):
44 mulitline
= ["All sensors are in normal state", "Sensors operating normal are:"]
45 mod_msg
= " (Alert state has been modified by Check_MK rule)"
47 for name
, _base_units
, _current_reading
, _sensor_type
, _unit_modifier
, \
48 _rate_units
, health_key
, health_label
, health_summary
in info
:
50 sensor_state
= {"green": 0, "yellow": 1, "red": 2, "unknown": 3}.get(health_key
.lower(), 2)
51 txt
= "%s: %s (%s)" % (name
, health_label
, health_summary
)
54 if name
.startswith(entry
.get("name", "")):
55 new_state
= entry
.get("states", {}).get(str(sensor_state
))
56 if new_state
is not None:
57 sensor_state
= new_state
60 if sensor_state
> 0 or txt
.endswith(mod_msg
):
61 yield sensor_state
, txt
62 mulitline
[:2] = "", "At least one sensor reported. Sensors readings are:"
65 yield 0, '\n'.join(mulitline
)
68 check_info
['esx_vsphere_sensors'] = {
69 "inventory_function": inventory_esx_vsphere_sensors
,
70 "check_function": check_esx_vsphere_sensors
,
71 "service_description": "Hardware Sensors",
72 "group": "hostsystem_sensors"