Module: check_mk
Branch: master
Commit: 97e3d9cb101b71696f51e5ce275e768c8a403200
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=97e3d9cb101b71…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Tue Jan 27 21:48:33 2015 +0100
#1859 FIX cups_queues: linux agent now runs section cups_queues in cached mode
After reports of problems with the agent run time for printer servers with
very long print queues the agent now runs the cups_queues section in cached
mode with a cache time of 5 mins. This means that the section is updated
only every 5 mins.
---
.werks/1859 | 12 ++++++++++
ChangeLog | 1 +
agents/check_mk_agent.linux | 52 ++++++++++++++++++++++++-------------------
3 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/.werks/1859 b/.werks/1859
new file mode 100644
index 0000000..3e1aa52
--- /dev/null
+++ b/.werks/1859
@@ -0,0 +1,12 @@
+Title: cups_queues: linux agent now runs section cups_queues in cached mode
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1422391502
+Class: fix
+
+After reports of problems with the agent run time for printer servers with
+very long print queues the agent now runs the cups_queues section in cached
+mode with a cache time of 5 mins. This means that the section is updated
+only every 5 mins.
diff --git a/ChangeLog b/ChangeLog
index ff04e32..104713f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -106,6 +106,7 @@
* 1858 FIX: docsis_channels_downstream: allow for negative values of power in dBm
* 1847 FIX: oracle_logswitches: Fixed description of WATO rule for levels...
* 1877 FIX: printer_input/printer_output: Check can now handle non reported capacity
unit
+ * 1859 FIX: cups_queues: linux agent now runs section cups_queues in cached mode...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 4d8fc0f..6a35472 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -418,30 +418,36 @@ 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>>>'
- 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
+ # first define a function to check cups
+ function 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=${LINE%%-*}
+ if echo $LOCAL_PRINTERS | grep -q $PRINTER; then
+ echo $LINE
+ fi
+ done
+ else
+ lpstat -p
+ echo '---'
+ lpstat -o | sort
fi
- done
- echo '---'
- lpstat -o | while read LINE
- do
- PRINTER=${LINE%%-*}
- if echo "$LOCAL_PRINTERS" | grep -q "$PRINTER"; then
- echo $LINE
- fi
- done
- else
- lpstat -p
- echo '---'
- lpstat -o | sort
- fi
+ }
+ # Make cups_queues available for subshell
+ export -f cups_queues
+ # Use cups_queues function with run_cached and cache time of 5 mins
+ run_cached -s cups_queues 300 "cups_queues"
fi
fi