Module: check_mk
Branch: master
Commit: 7b6a5fa84721238aa33a90613f8b6e25ee7789ee
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7b6a5fa8472123…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Feb 24 18:09:44 2014 +0100
FIX check_mk_agent.linux: more efficient handling of cups printer queues
The handling of printer queues has been made more efficient for cases when
many printer queues (>> 100) are to be monitored. This part of the agent
is now a factor of 10-20 faster !
---
.werks/585 | 10 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 43 ++++++++++++++++++++++++++-----------------
3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/.werks/585 b/.werks/585
new file mode 100644
index 0000000..55a064c
--- /dev/null
+++ b/.werks/585
@@ -0,0 +1,10 @@
+Title: check_mk_agent.linux: more efficient handling of cups printer queues
+Level: 2
+Component: checks
+Version: 1.2.5i1
+Date: 1393261649
+Class: fix
+
+The handling of printer queues has been made more efficient for cases when
+many printer queues (>> 100) are to be monitored. This part of the agent
+is now a factor of 10-20 faster !
diff --git a/ChangeLog b/ChangeLog
index 598e2da..6aa1a7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -184,6 +184,7 @@
* 0673 FIX: zfsget: Fixed broken check - was not compatible to current agent output
of "df"
* 0719 FIX: postfix_mailq: fix Linux agent in case of ssmtp being installed
* 0584 FIX: agent_vsphere: special agent now handles non-standard https port
correctly...
+ * 0585 FIX: check_mk_agent.linux: more efficient handling of cups printer queues...
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index c5f6ac9..639421c 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -372,23 +372,32 @@ fi
# Status of CUPS printer queues
if type lpstat > /dev/null 2>&1; then
- if pgrep cups > /dev/null 2>&1; then
- echo '<<<cups_queues>>>'
- WAITMAX="waitmax 3"
- CPRINTCONF=/etc/cups/printers.conf
- PRINTERS=$(waitmax 10 lpstat -a | awk '{print $1}')
- if [ -r "$CPRINTCONF" ] ; then
- for PQ in $PRINTERS ; do
- grep -q -x -E "<(Default)?Printer $PQ>" $CPRINTCONF
&& $WAITMAX lpstat -p $PQ
- done
- echo '---'
- for PQ in $PRINTERS ; do
- grep -q -x -E "<(Default)?Printer $PQ>" $CPRINTCONF
&& $WAITMAX lpstat -o $PQ
- done
- else
- $WAITMAX lpstat -p ; echo '---' ; $WAITMAX lpstat -o | sort
- fi
- fi
+ if pgrep cups > /dev/null 2>&1; then
+ echo '<<<cups_queues>>>'
+ CPRINTCONF=/etc/cups/printers.conf
+ if [ -r "$CPRINTCONF" ] ; then
+ LOCAL_PRINTERS=$(grep -E "<(Default)?Printer .*>" $CPRINTCONF
| awk '{print $2}' | sed -e 's/>//')
+ lpstat -p | while read LINE
+ do
+ PRINTER=$(echo $LINE | awk '{print $2}')
+ if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
+ echo $LINE
+ fi
+ done
+ echo '---'
+ lpstat -o | while read LINE
+ do
+ PRINTER=$(echo $LINE | awk '{print $2}')
+ if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
+ echo $LINE
+ fi
+ done
+ else
+ lpstat -p
+ echo '---'
+ lpstat -o | sort
+ fi
+ fi
fi
# Heartbeat monitoring