Module: check_mk
Branch: master
Commit: 3d1d5dfb4373464697770eacbceb29047e9ad103
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3d1d5dfb437346…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jun 26 09:41:44 2013 +0200
esx_vsphere_object: make check state configurable
---
ChangeLog | 1 +
checkman/esx_vsphere_objects | 19 ++++++++++--
checks/esx_vsphere_objects | 39 ++++++++++++++++++-------
web/plugins/config/builtin.py | 3 ++
web/plugins/icons/builtin.py | 2 +-
web/plugins/wato/check_parameters.py | 53 ++++++++++++++++++++++++++++++++--
6 files changed, 100 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bca2cca..fa73107 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@
* ps.perf: Support Windows with new plugin "psperf.bat". wmicchecks.bat
is obsolete now.
* Special Agent vSphere: support ESX 4.1 (thanks to Mirko Witt)
+ * esx_vsphere_object: make check state configurable
Notifications:
* notify.py: Matching service level: Use the hosts service level if a
diff --git a/checkman/esx_vsphere_objects b/checkman/esx_vsphere_objects
index a0b1587..cb29416 100644
--- a/checkman/esx_vsphere_objects
+++ b/checkman/esx_vsphere_objects
@@ -10,12 +10,25 @@ description:
be used for determining the architecture of a VMWare farm out of the monitoring
data.
- The check will get critical if a host system or virtual machine, that was once
- present, is now missing.
+ The check will get warning if a host or VM is powered off or suspended. But
+ this can be configured via a check parameter.
inventory:
- One service per hostsystem and per VM will be created.
+ One service per hostsystem and per VM will be created, regardless of its state.
item:
The text {HostSystem} or {VM} followed by a space followed by the name of the host system
or VM.
+
+examples:
+ # Allow VMs beginning with "testvm" to be powered off.
+ check_parameters = [
+ ( { "states" : { "poweredOff" : 0 } }, [ "esx" ], [ "VM testvm" ]),
+ ]
+
+
+[parameters]
+params(dict): A dictionary will currently one optional key: {states}. This is again a dictionary
+ with the optional entries {"poweredOn"}, {"poweredOff"} and {"suspended"}. The value for each
+ entry is {0}, {1}, {2} or {3} and sets the check result in that case to OK, WARN, CRIT or UNKNOWN.
+
diff --git a/checks/esx_vsphere_objects b/checks/esx_vsphere_objects
index 282e00c..8a00d89 100644
--- a/checks/esx_vsphere_objects
+++ b/checks/esx_vsphere_objects
@@ -40,7 +40,7 @@
# virtualmachine OpenSUSE_I
vsphere_object_names = {
- "hostsystem" : "HostSystem",
+ "hostsystem" : "HostSystem",
"virtualmachine" : "VM",
}
@@ -55,21 +55,37 @@ vsphere_object_names = {
# '----------------------------------------------------------------------'
def inventory_esx_vsphere_objects(info):
- return [ (vsphere_object_names[line[0]] + " " + line[1], None) for line in info ]
+ return [ (vsphere_object_names[line[0]] + " " + line[1], {}) for line in info ]
+
+# params is a dict with the allowed target states for the systems
+# Example:
+# params = {
+# "states" : {
+# "poweredOn" : 0,
+# "poweredOff" : 0,
+# "suspended" : 3,
+# }
+# }
+
+
+def check_esx_vsphere_objects(item, params, info):
+ if params == None:
+ params = {}
-def check_esx_vsphere_objects(item, _no_params, info):
for line in info:
if vsphere_object_names[line[0]] + " " + line[1] == item and len(line) > 3:
running_on = line[2]
power_state = line[3]
- if power_state == "poweredOn":
- state = 0
- elif power_state == "poweredOff":
- state = 1
- elif power_state == "suspended":
- state = 1
- else:
- state = 3
+ state = params.get("states",{}).get(power_state)
+ if state == None:
+ if power_state == "poweredOn":
+ state = 0
+ elif power_state == "poweredOff":
+ state = 1
+ elif power_state == "suspended":
+ state = 1
+ else:
+ state = 3
infotext = "power state: %s" % power_state
if running_on:
if state == 0:
@@ -91,6 +107,7 @@ check_info['esx_vsphere_objects'] = {
"inventory_function" : inventory_esx_vsphere_objects,
"check_function" : check_esx_vsphere_objects,
"service_description" : "%s",
+ "group" : "esx_vsphere_objects",
}
# .--Cluster-------------------------------------------------------------.
diff --git a/web/plugins/config/builtin.py b/web/plugins/config/builtin.py
index 0cfdaa6..4bd4728 100644
--- a/web/plugins/config/builtin.py
+++ b/web/plugins/config/builtin.py
@@ -177,6 +177,9 @@ selection_livetime = 3600
# Configure HTTP header to read usernames from
auth_by_http_header = False
+# Add an icon pointing to the WATO rule to each service
+multisite_draw_ruleicon = False
+
# _ _ ____ ____
# | | | |___ ___ _ __| _ \| __ )
# | | | / __|/ _ \ '__| | | | _ \
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index c87343e..d4f20cc 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -127,7 +127,7 @@ def paint_rule_editor(what, row, tags, custom_vars):
("check_command", row["service_check_command"]),
("service_description", row["service_description"]),
("host", row["host_name"])], "wato.py")
- title = _("Edit rule for %s") % check_command
+ title = _("Edit check parameters for this service")
return '<a href="%s"><img title="%s" class=icon src="images/icon_rulesets.png"></a>' % \
(url, title)
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index d2cab37..ef2a7e9 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -34,10 +34,8 @@ register_rulegroup("checkparams", _("Parameters for Inventorized Checks"),
group = "checkparams"
subgroup_networking = _("Networking")
-# subgroup_windows = _("Windows")
subgroup_storage = _("Storage, Filesystems and Files")
subgroup_os = _("Operating System Resources")
-# subgroup_time = _("Time synchronization")
subgroup_printing = _("Printers")
subgroup_environment = _("Temperature, Humidity, etc.")
subgroup_applications = _("Applications, Processes & Services")
@@ -1624,6 +1622,57 @@ register_check_parameters(
)
register_check_parameters(
+ subgroup_applications,
+ "esx_vsphere_objects",
+ _("State of ESX hosts and virtual machines"),
+ Dictionary(
+ help = _("Usually the check goes to WARN if a VM or host is powered off and OK otherwise. "
+ "You can change this behaviour on a per-state-base here."),
+ optional_keys = False,
+ elements = [
+ ( "states",
+ Dictionary(
+ title = _("Target states"),
+ optional_keys = False,
+ elements = [
+ ( "poweredOn",
+ MonitoringState(
+ title = _("Powered ON"),
+ help = _("Check result if the host or VM is powered on"),
+ default_value = 0,
+ )
+ ),
+ ( "poweredOff",
+ MonitoringState(
+ title = _("Powered OFF"),
+ help = _("Check result if the host or VM is powered off"),
+ default_value = 1,
+ )
+ ),
+ ( "suspended",
+ MonitoringState(
+ title = _("Suspended"),
+ help = _("Check result if the host or VM is suspended"),
+ default_value = 1,
+ )
+ ),
+ ]
+ )
+ ),
+ ]
+ ),
+ TextAscii(
+ title = _("Name of the VM/HostSystem"),
+ help = _("Please do not forget to specify either <tt>VM</tt> or <tt>HostSystem</tt>. Example: <tt>VM abcsrv123</tt>. Also note, "
+ "that we match the <i>beginning</i> of the name."),
+ regex = "(^VM|HostSystem)( .*|$)",
+ regex_error = _("The name of the system must begin with <tt>VM</tt> or <tt>HostSystem</tt>."),
+ allow_empty = False,
+ ),
+ "dict",
+)
+
+register_check_parameters(
subgroup_printing,
"printer_supply",
_("Printer cardridge levels"),
Module: check_mk
Branch: master
Commit: 9e7c91ca1275def84a6318eb2a9969c6870b42ea
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9e7c91ca1275de…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jun 25 18:13:10 2013 +0200
Updated man page
---
checkman/winperf_tcp_conn | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/checkman/winperf_tcp_conn b/checkman/winperf_tcp_conn
index 845821e..60597e4 100644
--- a/checkman/winperf_tcp_conn
+++ b/checkman/winperf_tcp_conn
@@ -5,16 +5,18 @@ author: Andreas Boesl (ab(a)mathias-kettner.de)
license: GPL
distribution: check_mk
description:
- This check monitors the number of established TCP connections on windows systems
+ This check monitors the number of established TCP connections on windows systems. In order
+ to use this check you need to activate the output of the TCP connection information in
+ {check_mk.ini}. You can do this by adding {counters = 638:tcp_conn} to the section {[winperf]}.
perfdata:
The number of established connections
inventory:
- If the windows agents has the section <<<winperf_tcp_conn>>>, then one check
+ If the windows agents has the section {<<<winperf_tcp_conn>>>}, then one check
will be created
-
[parameters]
-levels(dict from string to (int, int)): A python dictionary with the key ESTABLISHED and a pair of integers for warning and critical levels. If this state is not listed then the check will be always OK
-
+levels(dict from string to (int, int)): A python dictionary with the key
+ ESTABLISHED and a pair of integers for warning and critical levels. If this
+ state is not listed then the check will be always OK