Module: check_mk
Branch: master
Commit: 9ca3372a82601a195584c4908918887a612b08aa
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9ca3372a82601a…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Tue Aug 5 11:06:52 2014 +0200
#0196 esx_vsphere_hostsystem: New subcheck for maintenance mode
It is no possible to monitor if a hostsystem is in maintenance mode or not
---
.werks/196 | 10 +++++++++
ChangeLog | 1 +
checks/esx_vsphere_hostsystem | 40 +++++++++++++++++++++++++++++++---
web/plugins/wato/check_parameters.py | 20 +++++++++++++++++
4 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/.werks/196 b/.werks/196
new file mode 100644
index 0000000..4577bc0
--- /dev/null
+++ b/.werks/196
@@ -0,0 +1,10 @@
+Title: esx_vsphere_hostsystem: New subcheck for maintenance mode
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1407229557
+Class: feature
+
+It is no possible to monitor if a hostsystem is in maintenance mode or not
+
diff --git a/ChangeLog b/ChangeLog
index 038136c..5626a53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@
* 0190 docsis_signal_quality: New Check to monitor Signal Qualtiy on Devices with
DOCSIS MIB
* 0193 docsis_cm_status: New Check Status Check for Cable Modems with Docsis MIB.
* 1070 printer_input/printer_output: New checks to monitor input/output sub-units of
printers...
+ * 0196 esx_vsphere_hostsystem: New subcheck for maintenance mode...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/checks/esx_vsphere_hostsystem b/checks/esx_vsphere_hostsystem
index 7c556ec..b885c00 100644
--- a/checks/esx_vsphere_hostsystem
+++ b/checks/esx_vsphere_hostsystem
@@ -162,7 +162,7 @@ def inventory_esx_vsphere_hostsystem_state(info):
if 'runtime.inMaintenanceMode' in data:
return [(None, None)]
-def check_esx_vsphere_hostsystem_state(item, params, info):
+def check_esx_vsphere_hostsystem_state(_no_item, _no_params, info):
data = esx_vsphere_hostsystem_convert(info)
state = 0
label = {}
@@ -187,8 +187,6 @@ def check_esx_vsphere_hostsystem_state(item, params, info):
label['powerState'] = "(!)"
messages.append("Power state: %s%s" % (powerState,
label['powerState']))
- if str(data['runtime.inMaintenanceMode'][0]) == 'True':
- messages.append("System is in maintenance(!!)")
return(state, ", ".join(messages))
@@ -197,7 +195,43 @@ check_info['esx_vsphere_hostsystem.state'] = {
"check_function" : check_esx_vsphere_hostsystem_state,
"service_description" : "Overall state",
}
+#.
+# .--Maintenance---------------------------------------------------------.
+# | __ __ _ _ |
+# | | \/ | __ _(_)_ __ | |_ ___ _ __ __ _ _ __ ___ ___ |
+# | | |\/| |/ _` | | '_ \| __/ _ \ '_ \ / _` | '_ \ / __/ _ \ |
+# | | | | | (_| | | | | | || __/ | | | (_| | | | | (_| __/ |
+# | |_| |_|\__,_|_|_| |_|\__\___|_| |_|\__,_|_| |_|\___\___| |
+# | |
+# +----------------------------------------------------------------------+
+# | |
+# '----------------------------------------------------------------------'
+
+def inventory_esx_vsphere_hostsystem_maintenance(info):
+ data = esx_vsphere_hostsystem_convert(info)
+ if 'runtime.inMaintenanceMode' in data:
+ current_state = str(data['runtime.inMaintenanceMode'][0]).lower()
+ print current_state
+ return [(None, { 'target_state' : current_state })]
+def check_esx_vsphere_hostsystem_maintenance(_no_item, params, info):
+ data = esx_vsphere_hostsystem_convert(info)
+ target_state = params['target_state']
+ current_state = str(data['runtime.inMaintenanceMode'][0]).lower()
+ state = 0
+ if target_state != current_state:
+ state = 2
+ if current_state == "true":
+ return state, "System running is in Maintenance mode"
+ else:
+ return state, "System not in Maintenance mode"
+
+check_info['esx_vsphere_hostsystem.maintenance'] = {
+ "inventory_function" : inventory_esx_vsphere_hostsystem_maintenance,
+ "check_function" : check_esx_vsphere_hostsystem_maintenance,
+ "service_description" : "Maintenace Mode",
+ "group" : "esx_hostystem_maintenance",
+}
#.
# .--Multipath-----------------------------------------------------------.
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index d5adec9..1d78d16 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1964,6 +1964,26 @@ register_check_parameters(
)
register_check_parameters(
+ subgroup_storage,
+ "esx_hostystem_maintenance",
+ _("ESX Hostsystem Maintenance Mode"),
+ Dictionary(
+ elements = [
+ ("target_state", DropdownChoice(
+ title = _("Target State"),
+ help = _("Configure the target mode for the system."),
+ choices = [
+ ('true', "System should be in Maintenance Mode"),
+ ('false', "System not should be in Maintenance
Mode"),
+ ]
+ )),
+ ],
+ ),
+ None,
+ "dict"
+)
+
+register_check_parameters(
subgroup_networking,
"bonding",
_("Status of Linux bonding interfaces"),