Module: check_mk
Branch: master
Commit: d3a9016b27bae5b02001f7827807f396c1ea922e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d3a9016b27bae5…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Oct 28 17:56:01 2013 +0100
esx_vsphere_vm.heartbeat: heartbeat status now configurable
---
ChangeLog | 1 +
checkman/esx_vsphere_vm.heartbeat | 9 ++++++++
checks/esx_vsphere_vm | 29 +++++++++++++++---------
web/plugins/wato/check_parameters.py | 40 ++++++++++++++++++++++++++++++++++
4 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 74abad2..aa3359b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -72,6 +72,7 @@
* windows_tasks: New check to monitor the Windows Task Scheduler
* sensatronics_temp: New check for Sensatronic E4 Temperatur Sensor
* akcp_sensor_drycontact: New Check for AKCP drycontact Sensors
+ * esx_vsphere_vm.heartbeat: Heartbeat status alert level now configurable
* ps: new configuration option: handle_count (windows only)
* FIX: Windows agent: gracefully handle garbled logstate.txt
* FIX: esx_vsphere_counters: added missing ramdisk type upgradescratch
diff --git a/checkman/esx_vsphere_vm.heartbeat b/checkman/esx_vsphere_vm.heartbeat
index 6ba0012..1bd49ec 100644
--- a/checkman/esx_vsphere_vm.heartbeat
+++ b/checkman/esx_vsphere_vm.heartbeat
@@ -25,3 +25,12 @@ description:
inventory:
On each VM one check is generated.
+
+[parameters]
+parameters (dict): A dictionary with the following keys
+{"heartbeat_missing"}: vsphere state: red (see above)
+{"heartbeat_intermittend"}: vsphere state: yello (see above)
+{"heartbeat_no_tools"}: vsphere state: gray (see above)
+{"heartbeat_ok"}: vsphere state: gree (see above)
+
+ The value of each keys represents the alert level: 0(OK), 1(WARN), 2(CRIT), 3(UNKNOWN)
diff --git a/checks/esx_vsphere_vm b/checks/esx_vsphere_vm
index 8813c0f..c0a723f 100644
--- a/checks/esx_vsphere_vm
+++ b/checks/esx_vsphere_vm
@@ -138,26 +138,35 @@ def inventory_esx_vsphere_vm_hb_status(info):
if 'guestHeartbeatStatus' in data:
return [(None, None)]
-def check_esx_vsphere_vm_hb_status(_no_item, _no_params, info):
+def check_esx_vsphere_vm_hb_status(_no_item, params, info):
data = esx_vsphere_vm_convert(info)
vm_status = data['guestHeartbeatStatus'][0]
state = 3
- if vm_status == 'gray':
- return 1, "No VMWare Tools installed"
- elif vm_status == 'green':
- state = 0
- elif vm_status == 'red':
- state = 2
- elif vm_status == 'yellow':
- state = 1
- return state, "Heartbeat status is %s" % vm_status
+
+ vm_heartbeat_map = { "gray" : (1, "heartbeat_no_tools"),
+ "green" : (0, "heartbeat_ok"),
+ "red" : (2, "heartbeat_missing"),
+ "yellow" : (1, "heartbeat_intermittend") }
+ if vm_status in vm_heartbeat_map:
+ if params:
+ state = params.get(vm_heartbeat_map.get(vm_status)[1], 3)
+ else:
+ state = vm_heartbeat_map.get(vm_status)[0]
+ if vm_status == 'gray':
+ return state, "No VMWare Tools installed"
+ else:
+ return state, "Heartbeat status is %s" % vm_status
+ else:
+ return 3, "Unknown heartbeat status %s" % vm_status
+
check_info['esx_vsphere_vm.heartbeat'] = {
"inventory_function" : inventory_esx_vsphere_vm_hb_status,
"check_function" : check_esx_vsphere_vm_hb_status,
"service_description" : "ESX Heartbeat",
+ "group" : "vm_heartbeat"
}
#.
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index f391dad..7222157 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1963,6 +1963,46 @@ register_check_parameters(
)
register_check_parameters(
+ subgroup_os,
+ "vm_heartbeat",
+ _("Virtual machine heartbeat status"),
+ Dictionary(
+ optional_keys = False,
+ elements = [
+ ( "heartbeat_missing",
+ MonitoringState(
+ title = _("No heartbeat"),
+ help = _("Guest operating system may have stopped
responding."),
+ default_value = 2,
+ )
+ ),
+ ( "heartbeat_intermittend",
+ MonitoringState(
+ title = _("Intermittent heartbeat"),
+ help = _("May be due to high guest load."),
+ default_value = 1,
+ )
+ ),
+ ( "heartbeat_no_tools",
+ MonitoringState(
+ title = _("Heartbeat tools missing or not installed"),
+ help = _("No VMWare Tools installed."),
+ default_value = 1,
+ )
+ ),
+ ( "heartbeat_ok",
+ MonitoringState(
+ title = _("Heartbeat OK"),
+ help = _(" Guest operating system is responding
normally."),
+ default_value = 0,
+ )
+ ),
+ ]
+ ),
+ None,
+ "dict",
+)
+register_check_parameters(
subgroup_applications,
"esx_vsphere_objects",
_("State of ESX hosts and virtual machines"),