Module: check_mk
Branch: master
Commit: e09c72737a6693f512d4cdfd6b49230cc5016e16
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e09c72737a6693…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 30 11:57:12 2015 +0100
#1886 FIX win_printers: Fixed exception in WATO when displaying default parameters
---
.werks/1886 | 10 ++++++++++
ChangeLog | 1 +
checks/win_printers | 15 +++++++++------
web/plugins/wato/check_parameters.py | 20 +++++++++++++-------
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/.werks/1886 b/.werks/1886
new file mode 100644
index 0000000..d8467da
--- /dev/null
+++ b/.werks/1886
@@ -0,0 +1,10 @@
+Title: win_printers: Fixed exception in WATO when displaying default parameters
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1422615407
+
+
diff --git a/ChangeLog b/ChangeLog
index 3ce8c30..ffced7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -125,6 +125,7 @@
* 1881 FIX: omd_status: Check works now event when a site is reported as not OK...
* 1923 FIX: cisco_qos: Fixed exception in discovery that might lead to missing
services
* 1924 FIX: cisco_power: Fixed missing power supplies in case where name is not
unique
+ * 1886 FIX: win_printers: Fixed exception in WATO when displaying default parameters
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/checks/win_printers b/checks/win_printers
index c8c3bd0..7537ad6 100644
--- a/checks/win_printers
+++ b/checks/win_printers
@@ -29,11 +29,10 @@
# check is SNMP-Based, then remove this section
def inventory_win_printers(info):
- return [ (" ".join(x[:-3]), (None, None)) for x in info ]
+ return [ (" ".join(x[:-3]), None) for x in info ]
def check_win_printers(item, params, info):
status_map = {
-
1 : "Other",
2 : "Unkown",
3 : "Idle",
@@ -41,7 +40,6 @@ def check_win_printers(item, params, info):
5 : "Warming Up",
6 : "Stopped Printing",
7 : "Offline",
-
}
error_map = {
0 : "Unkown",
@@ -57,7 +55,12 @@ def check_win_printers(item, params, info):
10 : "Service Requested",
11 : "Output Bin Full"
}
- warn, crit = params
+
+ if params == None:
+ warn, crit = None, None
+ else:
+ warn, crit = params
+
for line in info:
name = " ".join(line[:-3])
if name == item:
@@ -73,10 +76,10 @@ def check_win_printers(item, params, info):
error_text = "Error State: %s(!)" % error_map[error]
queue_label = ""
- if crit and current_jobs >= crit:
+ if crit != None and current_jobs >= crit:
state = 2
queue_label = "(!!)"
- elif warn and current_jobs >= warn:
+ elif warn != None and current_jobs >= warn:
state = max(1, state)
queue_label = "(!)"
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index b2d33fd..7ea853e 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3234,13 +3234,19 @@ register_check_parameters(
subgroup_printing,
"windows_printer_queues",
_("Number of open jobs of a printer on windows" ),
- Tuple(
- help = _("This rule is applied to the number of print jobs "
- "currently waiting in windows printer queue."),
- elements = [
- Integer(title = _("Warning if above"), unit =
_("jobs"), default_value = 40),
- Integer(title = _("Critical if above"), unit =
_("jobs"), default_value = 60),
- ]
+ Transform(
+ Optional(
+ Tuple(
+ help = _("This rule is applied to the number of print jobs "
+ "currently waiting in windows printer queue."),
+ elements = [
+ Integer(title = _("Warning at"), unit =
_("jobs"), default_value = 40),
+ Integer(title = _("Critical at"), unit =
_("jobs"), default_value = 60),
+ ]
+ ),
+ label=_('Enable thresholds on the number of jobs'),
+ ),
+ forth = lambda old: old != (None, None) and old or None,
),
TextAscii(
title = _("Printer Name"),