Module: check_mk
Branch: master
Commit: 67c90d81ee34114db1b12d2e0867bbd146a90716
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=67c90d81ee3411…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Jan 21 14:11:56 2016 +0100
merge conflict
---
checks/win_printers | 36 +++++++++++-----
web/plugins/wato/check_parameters.py | 78 +++++++++++++++++++++++++++++-----
2 files changed, 93 insertions(+), 21 deletions(-)
diff --git a/checks/win_printers b/checks/win_printers
index 80000f1..28280fa 100644
--- a/checks/win_printers
+++ b/checks/win_printers
@@ -31,10 +31,16 @@
# WH1_BC_O3_UPS 0 3 0
+factory_settings['win_printer_default_levels'] = {
+ "levels" : (None, None),
+ "warn_states" : [ 8, 11 ],
+ "crit_states" : [ 9, 10 ],
+}
+
def inventory_win_printers(info):
for line in info:
if line[-1] != '9': # Do not discovery offline printers
- yield " ".join(line[:-3]), None
+ yield " ".join(line[:-3]), {}
def check_win_printers(item, params, info):
status_map = {
@@ -61,10 +67,17 @@ def check_win_printers(item, params, info):
11 : "Output Bin Full"
}
- if params == None:
- warn, crit = None, None
+ if type(params) != dict:
+ # Legacy params:
+ if params == None:
+ warn, crit = None, None
+ else:
+ warn, crit = params
+ params = {}
+ params['crit_states'] = [9,10]
+ params['warn_states'] = [8,11]
else:
- warn, crit = params
+ warn, crit = params['levels']
for line in info:
name = " ".join(line[:-3])
@@ -73,10 +86,10 @@ def check_win_printers(item, params, info):
current_jobs, status, error = map(int, line[-3:])
error_text = ""
- if error in [ 9, 10 ]:
+ if error in params['crit_states']:
state = 2
error_text = "Error State: %s(!!)" % error_map[error]
- elif error in [ 8, 11 ]:
+ elif error in params['warn_states']:
state = 1
error_text = "Error State: %s(!)" % error_map[error]
@@ -94,10 +107,11 @@ def check_win_printers(item, params, info):
return 3, "Printer not found in agent output"
check_info["win_printers"] = {
- "check_function" : check_win_printers,
- "group" : "windows_printer_queues",
- "inventory_function" : inventory_win_printers,
- "service_description" : "Printer %s",
- "has_perfdata" : False,
+ "check_function" : check_win_printers,
+ "group" : "windows_printer_queues",
+ "inventory_function" : inventory_win_printers,
+ "service_description" : "Printer %s",
+ "has_perfdata" : False,
+ "default_level_variable" : "win_printer_default_levels",
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 337f235..cf63990 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4505,23 +4505,81 @@ register_check_parameters(
),
match_type = "first",
)
+
+def windows_printer_queues_forth(old):
+ default = {
+ "levels" : (None, None),
+ "warn_states" : [ 8, 11 ],
+ "crit_states" : [ 9, 10 ],
+ }
+ if type(old) == tuple:
+ default['levels'] = old
+ if type(old) == dict:
+ return old
+ return default
+
register_check_parameters(
subgroup_printing,
"windows_printer_queues",
_("Number of open jobs of a printer on windows" ),
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),
+ Dictionary(
+ title = _("Windows Printer Configuration"),
+ elements = [
+ ( "levels",
+ Tuple(
+ title = _("Levels for the number of print jobs"),
+ 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),
+ ]
+ ),
+ ),
+ ("crit_states",
+ ListChoice(
+ title = _("States who should lead to critical"),
+ choices = [
+ ( 0, "Unkown"),
+ ( 1, "Other"),
+ ( 2, "No Error"),
+ ( 3, "Low Paper"),
+ ( 4, "No Paper"),
+ ( 5, "Low Toner"),
+ ( 6, "No Toner"),
+ ( 7, "Door Open"),
+ ( 8, "Jammed"),
+ ( 9, "Offline"),
+ ( 10, "Service Requested"),
+ ( 11, "Output Bin Full"),
+ ],
+ default_value = [9, 10],
+ )
+ ),
+ ("warn_states",
+ ListChoice(
+ title = _("States who should lead to warning"),
+ choices = [
+ ( 0, "Unkown"),
+ ( 1, "Other"),
+ ( 2, "No Error"),
+ ( 3, "Low Paper"),
+ ( 4, "No Paper"),
+ ( 5, "Low Toner"),
+ ( 6, "No Toner"),
+ ( 7, "Door Open"),
+ ( 8, "Jammed"),
+ ( 9, "Offline"),
+ ( 10, "Service Requested"),
+ ( 11, "Output Bin Full"),
+ ],
+ default_value = [8, 11],
+ )
+ ),
]
- ),
- label=_('Enable thresholds on the number of jobs'),
),
- forth = lambda old: old != (None, None) and old or None,
+ forth = windows_printer_queues_forth,
),
TextAscii(
title = _("Printer Name"),