Module: check_mk
Branch: master
Commit: 9c48e6ceb1224350104c7f1fb7d8968140b72f92
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9c48e6ceb12243…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Tue Oct 4 10:09:47 2016 +0200
3841 cups_queues: thresholds are now configurable in WATO
Thresholds are now configurable through WATO. Additionally the
printer states are also confugrable.
Defaults are the following:
job_count: (5,10)
job_age: (360,720)
is idle: OK
now printing: OK
disbaled since: CRIT
---
.werks/3841 | 16 ++++++++++++
ChangeLog | 1 +
checkman/cups_queues | 21 +++++++---------
checks/cups_queues | 32 +++++++++++++-----------
web/plugins/wato/check_parameters.py | 47 ++++++++++++++++++++++++++++++++++++
5 files changed, 91 insertions(+), 26 deletions(-)
diff --git a/.werks/3841 b/.werks/3841
new file mode 100644
index 0000000..270b7e0
--- /dev/null
+++ b/.werks/3841
@@ -0,0 +1,16 @@
+Title: cups_queues: thresholds are now configurable in WATO
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i2
+Date: 1475568172
+Class: feature
+
+Thresholds are now configurable through WATO. Additionally the
+printer states are also confugrable.
+Defaults are the following:
+job_count: (5,10)
+job_age: (360,720)
+is idle: OK
+now printing: OK
+disbaled since: CRIT
diff --git a/ChangeLog b/ChangeLog
index 27277fa..b37861d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* 3648 FIX: Fixed log file parsing of host states...
Checks & Agents:
+ * 3841 cups_queues: thresholds are now configurable in WATO...
* 3894 FIX: mkeventd_status: Fixed bug in case Event Console is not running
* 3907 FIX: oracle_tablespaces: simplyfied free space calculation depending on
version...
diff --git a/checkman/cups_queues b/checkman/cups_queues
index a736ba5..1f92e2d 100644
--- a/checkman/cups_queues
+++ b/checkman/cups_queues
@@ -14,27 +14,24 @@ description:
The resulting state also depends on the number of jobs in the queue and
the age of the oldest job in the queue.
+ Be aware that custom parameters for jobs in
+ queue will be preferred. Even if e.g. "disabled since" would result in {CRIT}
+ but the length of queue is {OK} and vice versa.
+
item:
The name of the printer in CUPS as printed by {lpstat -p}.
-examples:
- # Set number of minimum jobs to 5 to result in a warning state and 10 to result in a
critical state
- # Set the maximum age of a job to 5 minutes to result in a warning state and 10 minutes
to result in
- # a critical state. The age is given in seconds.
- cups_queues_default_levels = (5, 10, 360, 720)
-
perfdata:
- It contains the current number of jobs in the queue in the {jobs} value.
+ It contains the current number of jobs in the queue.
inventory:
Checks are created for all available printers in {lpstat -p} output.
[parameters]
-warning_count (int): Number of jobs to result in a warning state
-critical_count (int): Number of jobs to result in a critical state
-warning_age (int): Age of oldest job to result in a warning state
-critical_age (int): Age of oldest job to result in a critical state
+ job_count (int, int): WARN/CRIT if number of jobs are above
+ job_age (int, int): WARN/CRIT if oldest job is above in seconds
+ is_idle (int): Internal state for pritner state "is idle"
[configuration]
-cups_queues_default_levels (int, int, int, int): The global default levels for
+ cups_queues_default_levels (int, int, int, int): The global default levels for
all checks of this type. This is {(5, 10, 360, 720)}.
diff --git a/checks/cups_queues b/checks/cups_queues
index 2dccf4e..e719180 100644
--- a/checks/cups_queues
+++ b/checks/cups_queues
@@ -45,14 +45,19 @@
# zam19-113565 Sebastian Hirschdobler 3561472 Fri Jul 31 12:58:01 2015
# Default thresholds
-# ("<Warning max entries>", "<Critical num entries>",
"<Warning entry age in seconds>", "<Critical entry age>")
-cups_queues_default_levels = (5, 10, 360, 720)
+factory_settings['cups_queues_default_levels'] = {
+ 'job_count' : (5,10), #warn/crit for queue entries
+ 'job_age' : (360,720), #warn/crit for entry age in seconds
+ 'is_idle' : 0, #state for "is idle"
+ 'now_printing' : 0, #state for "now printing"
+ 'disabled_since' : 2, #state for "disbaled
since"
+}
def inventory_cups_queues(info):
- return [ ('%s' % line[1], '', "cups_queues_default_levels")
for line in info if line[0] == 'printer' ]
-
+ return [ ('%s' % line[1], '', {}) for line in info if line[0] ==
'printer' ]
def check_cups_queues(item, params, info):
- warnNum, critNum, warnAge, critAge = params
+ warnNum, critNum = params["job_count"]
+ warnAge, critAge = params["job_age"]
state = 3
output = "Queue not found"
numJobs = 0
@@ -68,11 +73,8 @@ def check_cups_queues(item, params, info):
if len(info) > num+1 and not info[num+1][0] in [ 'printer',
'---' ]:
statusoutput += " (%s)" % " ".join(info[num+1])
- if status == "disabled since":
- state = 2
- output = "%s" % statusoutput
- elif status in [ "is idle.", "now printing" ]:
- state = 0
+ if status in [ "is idle.", "now printing", "disabled
since"]:
+ state = params[status.replace(" ",
"_").replace(".", "")]
output = "%s" % statusoutput
else:
state = 3
@@ -110,8 +112,10 @@ def check_cups_queues(item, params, info):
check_info["cups_queues"] = {
- 'check_function': check_cups_queues,
- 'inventory_function': inventory_cups_queues,
- 'service_description': 'CUPS Queue %s',
- 'has_perfdata': True,
+ 'inventory_function' : inventory_cups_queues,
+ 'check_function' : check_cups_queues,
+ 'service_description' : 'CUPS Queue %s',
+ 'has_perfdata' : True,
+ 'default_levels_variable' : 'cups_queues_default_levels',
+ 'group' : 'cups_queues'
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 65469a7..373bcdf 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3715,6 +3715,53 @@ register_check_parameters(
"first"
)
+register_check_parameters(
+ subgroup_printing,
+ "cups_queues",
+ _("CUPS Queue"),
+ Dictionary(
+ elements = [
+ ( "job_count", Tuple(
+ title = _("Levels of current jobs"),
+ default_value = (5, 10),
+ elements = [
+ Integer(title = _("Warning at")),
+ Integer(title = _("Critical at"))
+ ]
+ ),
+ ),
+ ( "job_age", Tuple(
+ title = _("Levels for age of jobs"),
+ help = _("A value in seconds"),
+ default_value = (360, 720),
+ elements = [
+ Integer(title = _("Warning at")),
+ Integer(title = _("Critical at"))
+ ]
+ ),
+ ),
+ ( "is_idle", MonitoringState(
+ title = _("State for 'is idle'"),
+ default_value = 0,
+ )
+ ),
+ ( "now_printing", MonitoringState(
+ title = _("State for 'now printing'"),
+ default_value = 0,
+ )
+ ),
+ ( "disabled_since", MonitoringState(
+ title = _("State for 'disabled since'"),
+ default_value = 2,
+ )
+ ),
+ ],
+ ),
+ TextAscii(
+ title = _("CUPS Queue") ),
+ "dict",
+)
+
#.
# .--Unsorted--(Don't create new stuff here!)----------------------------.
# | _ _ _ _ |