[Pkg-nagios-changes] [pkg-nagios-plugins-contrib] 01/18: Add check_cups_queue module from the sitesummary-client package.
Bernd Zeimetz
bernd at bzed.de
Wed Oct 1 11:13:15 UTC 2014
This is an automated email from the git hooks/post-receive script.
bzed pushed a commit to branch master
in repository pkg-nagios-plugins-contrib.
commit 99951c619705578470b1786999361d232fa9cba6
Author: Petter Reinholdtsen <pere at hungry.com>
Date: Thu Sep 11 10:17:28 2014 +0200
Add check_cups_queue module from the sitesummary-client package.
---
check_cups_queue/Makefile | 5 +
check_cups_queue/check_cups_queue | 195 ++++++++++++++++++++++++++++++++++++++
check_cups_queue/control | 8 ++
check_cups_queue/copyright | 14 +++
4 files changed, 222 insertions(+)
diff --git a/check_cups_queue/Makefile b/check_cups_queue/Makefile
new file mode 100644
index 0000000..fc2256f
--- /dev/null
+++ b/check_cups_queue/Makefile
@@ -0,0 +1,5 @@
+#/usr/bin/make -f
+
+PLUGIN = check_cups_queue
+
+include ../common.mk
diff --git a/check_cups_queue/check_cups_queue b/check_cups_queue/check_cups_queue
new file mode 100755
index 0000000..e745dd1
--- /dev/null
+++ b/check_cups_queue/check_cups_queue
@@ -0,0 +1,195 @@
+#!/bin/bash
+# CUPS print queue plugin for Nagios
+# Written by John E. Vincent (nagios-plugs at lusis.org)
+# Last Modified: 06-27-2006
+# License: GNU General Public License, according to
+# <c841561b1002182124g7ca4e8fbme6574b3a558acc80 at mail.gmail.com>
+# on debian-edu at lists.debian.org
+#
+# Description:
+#
+# This plugin will check the status of a remote CUPS
+# print queue. It will provide the size of the queue
+# and optionally the age of the queue
+#
+
+# Location of the lpstat command (if not in path)
+LPSTAT="/usr/bin/lpstat"
+
+# Ensure known locale
+export LC_ALL=C
+
+# Don't change anything below here
+
+# Nagios return codes
+STATE_OK=0
+STATE_WARNING=1
+STATE_CRITICAL=2
+STATE_UNKNOWN=3
+STATE_DEPENDENT=4
+
+if [ ! -x "$LPSTAT" ]
+then
+ echo "UNKNOWN: $LPSTAT not found or is not executable by the nagios user"
+ exitstatus=$STATE_UNKNOWN
+ exit $exitstatus
+fi
+
+PROGNAME=`basename $0`
+
+print_usage() {
+ echo "Usage: $PROGNAME -H <hostname> -T <s|b> -w <size warning level> -c <size critical level> -a <max age>"
+ echo ""
+ echo "Notes:"
+ echo "-H: Hostname - Can be a hostname or IP address"
+ echo "-T: Type of check - Can be queue size (s) or both queu size and queue age (b)"
+ echo "-w: WARNING level for queue size"
+ echo "-c: CRITICAL level for queue size"
+ echo "-a: Max age of queue. Returns CRITICAL if jobs exists older than <max age> days"
+ echo ""
+}
+
+print_help() {
+ print_usage
+ echo ""
+ echo "This plugin will check the CUPS print queue on a remote (or local with -H localhost) CUPS server."
+ echo "It can check both the size of the queue and the age of the oldest print job in the queue."
+ echo "-w and -c are for reporting warning and critical levels of the queue size."
+ echo "-a is optional for specifying the max age of a job in the print queue. Anything older thatn <max age>"
+ echo "will return a CRITICAL"
+ echo ""
+ exit 0
+}
+
+check_queue_size()
+{
+ if [ "$JOBCOUNT" -ge "$critlevel" ]
+ then
+ MESSAGE="CRITICAL: CUPS queue size - $JOBCOUNT| $PERFDATA"
+ exitstatus=$STATE_CRITICAL
+ elif [ "$JOBCOUNT" -ge "$warnlevel" ]
+ then
+ MESSAGE="WARNING: CUPS queue size - $JOBCOUNT| $PERFDATA"
+ exitstatus=$STATE_WARNING
+ else
+ MESSAGE="OK: CUPS queue size - $JOBCOUNT| $PERFDATA"
+ exitstatus=$STATE_OK
+ fi
+}
+
+if [ $# -lt 4 ]; then
+ print_usage
+ exit $STATE_UNKNOWN
+fi
+
+exitstatus=$STATE_UNKNOWN #default
+
+while test -n "$1"; do
+ case "$1" in
+ --help)
+ print_help
+ exit $STATE_OK
+ ;;
+ -h)
+ print_help
+ exit $STATE_OK
+ ;;
+ -H)
+ hostname=$2
+ shift
+ ;;
+ -T)
+ testtype=$2
+ shift
+ ;;
+ -w)
+ warnlevel=$2
+ shift
+ ;;
+ -c)
+ critlevel=$2
+ shift
+ ;;
+ -a)
+ maxage=$2
+ shift
+ ;;
+ esac
+ shift
+done
+
+# Check arguments for validity
+if [ -z $hostname ]
+then
+ echo "You must specify a hostname (or localhost to test the local system)"
+ print_usage
+ exitstatus=$STATE_UNKNOWN
+ exit $exitstatus
+fi
+
+if [[ -z $critlevel || -z $warnlevel ]] # Did we get warn and crit values?
+then
+ echo "You must specify a warning and critical level"
+ print_usage
+ exitstatus=$STATE_UNKNOWN
+ exit $exitstatus
+elif [ $critlevel -lt $warnlevel ] # Do the warn/crit values make sense?
+then
+ echo "CRITICAL value of $critlevel is less than WARNING level of $warnlevel"
+ print_usage
+ exitstatus=$STATE_UNKNOWN
+ exit $exitstatus
+fi
+
+if [ -z $testtype ] # We require a test type
+then
+ echo "You must specify a test type"
+ print_usage
+ exitstatus=$STATE_UNKNOWN
+ exit $exitstatus
+elif [[ "$testtype" = [b]* && -z $maxage ]]
+then
+ echo "You must specify <max age> when using a test type of 'b'"
+ print_usage
+ exitstatus=$STATE_UNKNOWN
+ exit $exitstatus
+else
+
+ JOBTMP=`mktemp -t lpstat.$hostname.XXXXXX` # Create a tmpfile to store the lpstat results
+ STALEJOBCOUNT=0 # default number of old jobs
+ CURDATETS=`date +%s` # Get the current date as unixtime
+ $LPSTAT -h $hostname -o > $JOBTMP # run the lpstat command against the host.
+ if [ $? -ne 0 ]
+ then
+ rm -rf $JOBTMP
+ echo "UNKNOWN: lpstat command returned an error. Please test this script manually."
+ exitstatus=$STATE_UNKNOWN
+ exit $exitstatus
+ fi
+ JOBCOUNT=`wc -l < $JOBTMP` # populate the jobcount
+ PERFDATA="print_jobs=$JOBCOUNT;$warnlevel;$critlevel;0"
+ if [[ "$JOBCOUNT" -gt 0 && $maxage ]]
+ then
+ MAXAGETS=`echo "86400 * $maxage" | bc` # 86400 seconds in a day * maxage
+ exec<$JOBTMP # read the file to determine job age
+ while read PRINTJOB
+ do
+ JOBDATE=`echo $PRINTJOB | awk '{ print $4, $5, $6, $7, $8 }'` # Grab the job date from the job listing
+ JOBDATETS=`date --date="$JOBDATE" +%s` # Convert the job date to unixtime
+ DATEDIFF=`echo "($CURDATETS - $JOBDATETS)" | bc`
+ if [ $DATEDIFF -gt $MAXAGETS ]
+ then
+ MESSAGE="CRITICAL: Some CUPS jobs are older than $maxage days| $PERFDATA"
+ exitstatus=$STATE_CRITICAL
+ else
+ check_queue_size
+ fi
+ done
+ else
+ check_queue_size
+ fi
+ rm -rf $JOBTMP
+fi
+
+echo $MESSAGE
+exit $exitstatus
diff --git a/check_cups_queue/control b/check_cups_queue/control
new file mode 100644
index 0000000..393c558
--- /dev/null
+++ b/check_cups_queue/control
@@ -0,0 +1,8 @@
+Homepage: http://exchange.nagios.org/directory/Plugins/Printing/check_cups_queue/details
+Uploaders: John E. Vincent <nagios-plugs at lusis.org>
+Description: plugin to check age and length of CUPS queue
+ This plugin is monitoring of queues on a local or remote CUPS server,
+ which means that it doesn't need to be installed on the print
+ server and run via NRPE.
+Recommends: cups-client
+Version: ?
diff --git a/check_cups_queue/copyright b/check_cups_queue/copyright
new file mode 100644
index 0000000..a48f2cd
--- /dev/null
+++ b/check_cups_queue/copyright
@@ -0,0 +1,14 @@
+Copyright (C) 2010 John E. Vincent <nagios-plugs at lusis.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at
+your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, see <http://www.gnu.org/licenses/>.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nagios-plugins-contrib.git
More information about the Pkg-nagios-changes
mailing list