Module: check_mk
Branch: master
Commit: ee8031a7746e97355d77f451f6c5c86661754e3a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ee8031a7746e97…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri Jan 30 13:49:33 2015 +0100
synology_update: Check return state can now be configured in wato
---
checkman/synology_update | 1 +
checks/synology_update | 53 ++++++++++------
web/plugins/wato/check_parameters.py | 112 +++++++++++-----------------------
3 files changed, 72 insertions(+), 94 deletions(-)
diff --git a/checkman/synology_update b/checkman/synology_update
index 85f1c37..4a05c49 100644
--- a/checkman/synology_update
+++ b/checkman/synology_update
@@ -6,6 +6,7 @@ distribution: check_mk
description:
This check reports if the DSM Version is out of Date or if there
any issues connecting to the update service.
+ The resulting check state can be configured in WATO.
inventory:
diff --git a/checks/synology_update b/checks/synology_update
index ad75820..173b14c 100644
--- a/checks/synology_update
+++ b/checks/synology_update
@@ -24,30 +24,45 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
+factory_settings["synology_update_levels"] = {
+ "ok_states" : [ 2, 3 ],
+ "warn_states" : [ 5 ],
+ "crit_states" : [ 1, 4 ],
+}
+
def inventory_synology_update(info):
- return [(None, None)]
+ return [(None, {})]
-def check_synology_update(_no_item, _no_params, info):
+def check_synology_update(_no_item, params, info):
states = {
- 1 : ("Available", 2),
- 2 : ("Unavailable", 0),
- 3 : ("Connecting", 0),
- 4 : ("Disconnected", 2),
- 5 : ("Others", 3),
+ 1 : "Available",
+ 2 : "Unavailable",
+ 3 : "Connection",
+ 4 : "Disconnected",
+ 5 : "Others",
}
- version, state = info[0]
- state = int(state)
- return states[state][1], "Status: %s, Current Version: %s" %
(states[state][0], version)
+ version, device_state = info[0]
+ device_state = int(device_state)
+ state = 3
+ if device_state in params['ok_states']:
+ state = 0
+ elif device_state in params['warn_states']:
+ state = 1
+ elif device_state in params['crit_states']:
+ state = 2
+ return state, "Update Status: %s, Current Version: %s" %
(states[device_state], version)
check_info["synology_update"] = {
- "check_function" : check_synology_update,
- "inventory_function" : inventory_synology_update,
- "service_description" : "Update",
- "snmp_scan_function" : synology_scan_function,
- "snmp_info" : (".1.3.6.1.4.1.6574.1.5", [
- 3, #Version
- 4, #Status
- ]),
- "includes" : [ "synology.include" ],
+ "check_function" : check_synology_update,
+ "inventory_function" : inventory_synology_update,
+ "service_description" : "Update",
+ "snmp_scan_function" : synology_scan_function,
+ "snmp_info" : (".1.3.6.1.4.1.6574.1.5", [
+ 3, #Version
+ 4, #Status
+ ]),
+ "includes" : [ "synology.include" ],
+ "default_levels_variable" : "synology_update_levels",
+ "group" : "synology_update",
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index b2d33fd..f1f3421 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -6291,81 +6291,6 @@ register_check_parameters(
"jvm_memory",
_("JVM memory levels"),
Dictionary(
- help = _("This rule allows to set the warn and crit levels of the heap /
"
- "non-heap and total memory area usage on web application servers.
"
- "Other keywords for this rule: Tomcat, Jolokia, JMX. "),
- elements = [
- ( "totalheap",
- Alternative(
- title = _("Total Memory Levels"),
- elements = [
- Tuple(
- title = _("Percentage levels of used space"),
- elements = [
- Percentage(title = _("Warning if above"), label
= _("% usage")),
- Percentage(title = _("Critical if above"), label
= _("% usage")),
- ]
- ),
- Tuple(
- title = _("Absolute free space in MB"),
- elements = [
- Integer(title = _("Warning if below"), unit =
_("MB")),
- Integer(title = _("Critical if below"), unit =
_("MB")),
- ]
- )
- ])),
- ( "heap",
- Alternative(
- title = _("Heap Memory Levels"),
- elements = [
- Tuple(
- title = _("Percentage levels of used space"),
- elements = [
- Percentage(title = _("Warning if above"), label
= _("% usage")),
- Percentage(title = _("Critical if above"), label
= _("% usage")),
- ]
- ),
- Tuple(
- title = _("Absolute free space in MB"),
- elements = [
- Integer(title = _("Warning if below"), unit =
_("MB")),
- Integer(title = _("Critical if below"), unit =
_("MB")),
- ]
- )
- ])),
- ( "nonheap",
- Alternative(
- title = _("Nonheap Memory Levels"),
- elements = [
- Tuple(
- title = _("Percentage levels of used space"),
- elements = [
- Percentage(title = _("Warning if above"), label
= _("% usage")),
- Percentage(title = _("Critical if above"), label
= _("% usage")),
- ]
- ),
- Tuple(
- title = _("Absolute free space in MB"),
- elements = [
- Integer(title = _("Warning if below"), unit =
_("MB")),
- Integer(title = _("Critical if below"), unit =
_("MB")),
- ]
- )
- ])),
- ]),
- TextAscii(
- title = _("Name of the virtual machine"),
- help = _("The name of the application server"),
- allow_empty = False,
- ),
- "dict"
-)
-
-register_check_parameters(
- subgroup_applications,
- "sym_brightmail_queues",
- "Symantec Brightmail Queues",
- Dictionary(
help = _("This check is used to monitor successful email delivery through
"
"Symantec Brightmail Scanner appliances."),
elements = [
@@ -6474,6 +6399,43 @@ register_check_parameters(
"first"
)
+synology_update_states = [
+ (1, "Available"),
+ (2, "Unavailable"),
+ (3, "Connection"),
+ (4, "Disconnected"),
+ (5, "Others"),
+]
+
+register_check_parameters(
+ subgroup_applications,
+ "synology_update",
+ _("Synology Updates"),
+ Dictionary(
+ title = _("Update State"),
+ elements = [
+ ("ok_states", ListChoice(
+ title = _("States which result in OK"),
+ choices = synology_update_states,
+ default_value = [2, 3]
+ )),
+ ("warn_states", ListChoice(
+ title = _("States which result in Warning"),
+ choices = synology_update_states,
+ default_value = [5]
+ )),
+ ("crit_states", ListChoice(
+ title = _("States which result in Critical"),
+ choices = synology_update_states,
+ default_value = [1,4]
+ )),
+ ],
+ optional_keys = None,
+ ),
+ None,
+ "first"
+)
+
register_check_parameters(
subgroup_applications,
"antivir_update_age",