Module: check_mk
Branch: master
Commit: 51c57ed9337b83ddd1e70f52a45237f937640021
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=51c57ed9337b83…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Sat Jun 17 11:09:44 2017 +0200
4760 FIX Fixed vanishing CUPS queues services on systems using systemd
When monitoring CUPS queues on linux systems using systemd it happened
that the agent did not provide CUPS queue information suddenly.
When using systemd the cupsd process is stopped when nothing is using
the daemon. Systemd is starting the daemon again automatically once
any process wants use the printer system.
The CUPS part of the Check_MK agent was only executed when the cupsd
process was running which is wrong for such systems. Additionally the
agent is now checking whether or not systemd is used and the cups.service
is enabled and checks the queues if so, even when the cupsd is not running.
Change-Id: I29c156f95eda0a18598039dc943a4c923a18a729
---
.werks/4760 | 21 +++++++++++++++++++++
agents/check_mk_agent.linux | 5 ++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/.werks/4760 b/.werks/4760
new file mode 100644
index 0000000..cedfc6a
--- /dev/null
+++ b/.werks/4760
@@ -0,0 +1,21 @@
+Title: Fixed vanishing CUPS queues services on systems using systemd
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1497690367
+
+When monitoring CUPS queues on linux systems using systemd it happened
+that the agent did not provide CUPS queue information suddenly.
+
+When using systemd the cupsd process is stopped when nothing is using
+the daemon. Systemd is starting the daemon again automatically once
+any process wants use the printer system.
+
+The CUPS part of the Check_MK agent was only executed when the cupsd
+process was running which is wrong for such systems. Additionally the
+agent is now checking whether or not systemd is used and the cups.service
+is enabled and checks the queues if so, even when the cupsd is not running.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index ba6cee1..8af57f4 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -579,7 +579,10 @@ fi
# Status of CUPS printer queues
if type lpstat > /dev/null 2>&1; then
- if pgrep -f "\bcupsd" > /dev/null 2>&1; then
+ # Systemd starts cupsd on demand: Instead of checking that the cupsd is
+ # running we check that the cups service exists and is enabled.
+ if pgrep -f "\bcupsd" > /dev/null 2>&1 \
+ || (type systemctl >/dev/null 2>&1 && systemctl is-enabled
cups.service); then
# first define a function to check cups
function cups_queues () {
CPRINTCONF=/etc/cups/printers.conf