- allow plugins to open files in /etc/monitoring-plugins/
(Apparmor profiles in /etc/apparmor.d/) - add README files for check_ping and check_ntp_time - enhance all README files with Apparmor information - whitespace and some spelling fixes on check_cups - added debug option to check_cups OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins?expand=0&rev=7
This commit is contained in:
committed by
Git OBS Bridge
parent
fdf63d33a9
commit
f1a27a1d58
@@ -51,5 +51,10 @@ in ''/etc/sudoers'' and an adapted command definition like the following:
|
|||||||
command_line /usr/bin/sudo $USER1$/check_dhcp <other_options_here>
|
command_line /usr/bin/sudo $USER1$/check_dhcp <other_options_here>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
== Apparmor profile ==
|
||||||
|
|
||||||
|
Please check /etc/apparmor.d/usr.lib.nagios.plugins.check_dhcp if you are using
|
||||||
|
the --extra-opts option. The Apparmor profile allows to open every file below
|
||||||
|
the /etc/monitoring-plugins/ directory read only for this. All files in other
|
||||||
|
directories are not allowed.
|
||||||
|
|
||||||
|
@@ -39,4 +39,10 @@ in ''/etc/sudoers'' and an adapted command definition like the following:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
== Apparmor profile ==
|
||||||
|
|
||||||
|
Please check /etc/apparmor.d/usr.lib.nagios.plugins.check_icmp if you are
|
||||||
|
using the --extra-opts option. The Apparmor profile allows to open every file
|
||||||
|
below the /etc/monitoring-plugins/ directory read only for this. All files in
|
||||||
|
other directories are not allowed.
|
||||||
|
|
||||||
|
@@ -38,5 +38,11 @@ in ''/etc/sudoers'' and an adapted command definition like the following:
|
|||||||
command_line /usr/bin/sudo $USER1$/check_ide_smart <other_options_here>
|
command_line /usr/bin/sudo $USER1$/check_ide_smart <other_options_here>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
== Apparmor profile ==
|
||||||
|
|
||||||
|
Please check /etc/apparmor.d/usr.lib.nagios.plugins.check_ide_smart if you are
|
||||||
|
using the --extra-opts option. The Apparmor profile allows to open every file
|
||||||
|
below the /etc/monitoring-plugins/ directory read only for this. All files in
|
||||||
|
other directories are not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
10
monitoring-plugins-README.SUSE-check_ntp_time
Normal file
10
monitoring-plugins-README.SUSE-check_ntp_time
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
README.SUSE for monitoring-plugins-ntp_time
|
||||||
|
|
||||||
|
== Apparmor profile ==
|
||||||
|
|
||||||
|
Please check /etc/apparmor.d/usr.lib.nagios.plugins.check_ntp_time if you are
|
||||||
|
using the --extra-opts option. The Apparmor profile allows to open every file
|
||||||
|
below the /etc/monitoring-plugins/ directory read only for this. All files in
|
||||||
|
other directories are not allowed.
|
||||||
|
|
||||||
|
|
10
monitoring-plugins-README.SUSE-check_ping
Normal file
10
monitoring-plugins-README.SUSE-check_ping
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
README.SUSE for monitoring-plugins-ping
|
||||||
|
|
||||||
|
== Apparmor profile ==
|
||||||
|
|
||||||
|
Please check /etc/apparmor.d/usr.lib.nagios.plugins.check_ping if you are
|
||||||
|
using the --extra-opts option. The Apparmor profile allows to open every file
|
||||||
|
below the /etc/monitoring-plugins/ directory read only for this. All files in
|
||||||
|
other directories are not allowed.
|
||||||
|
|
||||||
|
|
@@ -1,3 +1,13 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jul 22 13:50:10 UTC 2014 - lars@linux-schulserver.de
|
||||||
|
|
||||||
|
- allow plugins to open files in /etc/monitoring-plugins/
|
||||||
|
(Apparmor profiles in /etc/apparmor.d/)
|
||||||
|
- add README files for check_ping and check_ntp_time
|
||||||
|
- enhance all README files with Apparmor information
|
||||||
|
- whitespace and some spelling fixes on check_cups
|
||||||
|
- added debug option to check_cups
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Jul 15 13:05:27 UTC 2014 - lars@linux-schulserver.de
|
Tue Jul 15 13:05:27 UTC 2014 - lars@linux-schulserver.de
|
||||||
|
|
||||||
|
@@ -34,20 +34,19 @@
|
|||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
# $Id$
|
|
||||||
#
|
#
|
||||||
|
# Autor notes:
|
||||||
# Autor notes: I`d like to thank to John E. Vincent (nagios-plugs@lusis.org)
|
# I`d like to thank to John E. Vincent (nagios-plugs@lusis.org)
|
||||||
# I learn a lof from his check CUPS print queue plugin.
|
# I learn a lof from his check CUPS print queue plugin.
|
||||||
# Then I`d like to thank to Mark Shirley for his check_cups_printer.sh
|
# Then I`d like to thank to Mark Shirley for his check_cups_printer.sh
|
||||||
# script, which was also inspiration for me.
|
# script, which was also inspiration for me.
|
||||||
# Both of them you can find on http://exchange.nagios.org/ web site.
|
# Both of them you can find on http://exchange.nagios.org/ web site.
|
||||||
# Martin Caj 31/01/2013 <mcaj@suse.cz>
|
# Martin Caj 31/01/2013 <mcaj@suse.cz>
|
||||||
|
#
|
||||||
# version 0.3 has no awk any more, cut can do it as well.
|
# version 0.3 has no awk any more, cut can do it as well.
|
||||||
# the appamor profile was fix as well.
|
# the appamor profile was fixed as well.
|
||||||
# Martin Caj 01/11/2013
|
# Martin Caj 01/11/2013
|
||||||
|
#
|
||||||
# check_cups - nagios plugin for checking cups service
|
# check_cups - nagios plugin for checking cups service
|
||||||
# Description:
|
# Description:
|
||||||
#
|
#
|
||||||
@@ -63,6 +62,7 @@
|
|||||||
|
|
||||||
#searchning the lpstat:
|
#searchning the lpstat:
|
||||||
LPSTAT="$(which lpstat)"
|
LPSTAT="$(which lpstat)"
|
||||||
|
DEBUG='no'
|
||||||
|
|
||||||
# debug the script:
|
# debug the script:
|
||||||
#set -x
|
#set -x
|
||||||
@@ -78,9 +78,9 @@ STATE_DEPENDENT=4
|
|||||||
# check it lpstat is missing.
|
# check it lpstat is missing.
|
||||||
if [ ! -x "$LPSTAT" ]
|
if [ ! -x "$LPSTAT" ]
|
||||||
then
|
then
|
||||||
echo "UNKNOWN: "$LPSTAT" not found or is not executable by the nagios user"
|
echo "UNKNOWN: "$LPSTAT" not found or is not executable by the nagios user"
|
||||||
exitstatus="$STATE_UNKNOWN"
|
exitstatus="$STATE_UNKNOWN"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PROGNAME=$(basename $0)
|
PROGNAME=$(basename $0)
|
||||||
@@ -88,36 +88,37 @@ PROGNAME=$(basename $0)
|
|||||||
|
|
||||||
print_usage() {
|
print_usage() {
|
||||||
# Name: print_usage
|
# Name: print_usage
|
||||||
# Desc: It just print the usage out.
|
# Desc: It just prints the usage.
|
||||||
|
|
||||||
echo "Usage: "$PROGNAME" -H <hostname> -P -p<The CUPS printer name> | -Q <s|b> -w <size warning level> -c <size critical level> -a <max age>"
|
echo "Usage: $PROGNAME -H <hostname> -w <size warning level> -c <size critical level> [-P] [-p<The CUPS printer name>] [-Q <s|b>] [-a <max age>] [-d]"
|
||||||
echo
|
echo
|
||||||
echo "Notes:"
|
echo "Notes:"
|
||||||
echo "-H: Hostname - Can be a hostname or IP address."
|
echo "-H <hostname> : Hostname - Can be a hostname or IP address."
|
||||||
echo "-P: Check only the printers status."
|
echo "-P : Check only the printers status."
|
||||||
echo "-p: It will check only one specific printer."
|
echo "-p <printername> : will check only the specified printer."
|
||||||
echo "-Q: Type of check - Can be queue size (s) or both queu size and queue age (b)."
|
echo "-Q <s|b> : Type of check - Can be queue size (s) or both queue size and queue age (b)."
|
||||||
echo "-w: WARNING level for queue size."
|
echo "-w <int> : WARNING level for queue size."
|
||||||
echo "-c: CRITICAL level for queue size."
|
echo "-c <int> : CRITICAL level for queue size."
|
||||||
echo "-a: Max age of queue. Returns CRITICAL if jobs exists older than <max age> days."
|
echo "-a <int> : Max age of queue. Returns CRITICAL if jobs exists longer than <max age> days."
|
||||||
echo
|
echo "-d : enable debug output"
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
print_help() {
|
print_help() {
|
||||||
# Name: print_help
|
# Name: print_help
|
||||||
# Desc: It just print the usage and the help out. Then it end with exit code 0
|
# Desc: Print the usage and help.
|
||||||
|
|
||||||
print_usage
|
print_usage
|
||||||
echo
|
echo
|
||||||
echo "This plugin will check the CUPS print service for the printer status"
|
echo "This plugin will check the CUPS print service for the printer status."
|
||||||
echo "it can check the queue on a remote (or local with -H localhost) CUPS server."
|
echo "It can check the 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 "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 "-w and -c are for 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 "-a is optional for specifying the max age of a job in the print queue. Anything older than <max age>"
|
||||||
echo "will return a CRITICAL"
|
echo "will return a CRITICAL"
|
||||||
echo "For more details have look into README file. "
|
echo "For more details have look into the README file. "
|
||||||
echo
|
echo
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,14 +129,14 @@ check_queue_size() {
|
|||||||
|
|
||||||
if [ "$JOBCOUNT" -ge "$critlevel" ]
|
if [ "$JOBCOUNT" -ge "$critlevel" ]
|
||||||
then
|
then
|
||||||
MESSAGE="CRITICAL: CUPS queue size - "$JOBCOUNT"| "$PERFDATA""
|
MESSAGE="CRITICAL: CUPS queue size - "$JOBCOUNT"| "$PERFDATA""
|
||||||
exitstatus="$STATE_CRITICAL"
|
exitstatus="$STATE_CRITICAL"
|
||||||
elif [ "$JOBCOUNT" -ge "$warnlevel" ]
|
elif [ "$JOBCOUNT" -ge "$warnlevel" ]
|
||||||
then
|
then
|
||||||
MESSAGE="WARNING: CUPS queue size - "$JOBCOUNT"| "$PERFDATA""
|
MESSAGE="WARNING: CUPS queue size - "$JOBCOUNT"| "$PERFDATA""
|
||||||
exitstatus="$STATE_WARNING"
|
exitstatus="$STATE_WARNING"
|
||||||
else
|
else
|
||||||
MESSAGE="OK: CUPS queue size - "$JOBCOUNT"| "$PERFDATA""
|
MESSAGE="OK: CUPS queue size - "$JOBCOUNT"| "$PERFDATA""
|
||||||
exitstatus="$STATE_OK"
|
exitstatus="$STATE_OK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -146,70 +147,73 @@ check_printer_status() {
|
|||||||
# Desc: It check status of all printers or one specific printer
|
# Desc: It check status of all printers or one specific printer
|
||||||
# output is store in $OUTPUT and $exitstatus
|
# output is store in $OUTPUT and $exitstatus
|
||||||
|
|
||||||
if [ -z $printername ]
|
if [ -z "$printername" ]
|
||||||
then
|
then
|
||||||
echo "Checking all printers..."
|
if [ "$DEBUG" == 'yes' ]; then
|
||||||
RESULT=$("$LPSTAT" -h "$hostname" -p )
|
echo "Checking all printers..."
|
||||||
if [ $? != 0 ]
|
fi
|
||||||
|
RESULT=$("$LPSTAT" -h "$hostname" -p )
|
||||||
|
if [ $? != 0 ]
|
||||||
then
|
then
|
||||||
echo "ERROR: Probably wrong host name: "$hostname", or CUPS is not running there."
|
echo "ERROR: Probably wrong host name: "$hostname", or CUPS is not running."
|
||||||
exit "$STATE_UNKNOWN"
|
exit "$STATE_UNKNOWN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Checking only the printer "$printername"."
|
if [ "$DEBUG" == 'yes' ]; then
|
||||||
RESULT=$("$LPSTAT" -h "$hostname" -p "$printername")
|
echo "Checking only printer: $printername"
|
||||||
if [ $? != 0 ]
|
fi
|
||||||
then
|
RESULT=$("$LPSTAT" -h "$hostname" -p "$printername")
|
||||||
echo "ERROR: the printer "$printername" doesn't exist on the cups server "$hostname"."
|
if [ $? != 0 ]
|
||||||
echo "please check command: '"$LPSTAT" -h "$hostname" -p' without printer name."
|
then
|
||||||
exit "$STATE_UNKNOWN"
|
echo "ERROR: the printer $printername doesn't exist on CUPS server $hostname."
|
||||||
fi
|
echo "please check command: '$LPSTAT -h $hostname -p' without printer name."
|
||||||
|
exit "$STATE_UNKNOWN"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$RESULT" in
|
case "$RESULT" in
|
||||||
*Rejecting*)
|
*Rejecting*)
|
||||||
messages=$(echo "$RESULT"|grep -i rejecting )
|
messages=$(echo "$RESULT"|grep -i rejecting )
|
||||||
OUTPUT="CRITICAL - CUPS printer is rejecting jobs for: "$messages"."
|
OUTPUT="CRITICAL - CUPS printer is rejecting jobs for: $messages."
|
||||||
exitstatus="$STATE_CRITICAL"
|
exitstatus="$STATE_CRITICAL"
|
||||||
;;
|
;;
|
||||||
*Unable*)
|
*Unable*)
|
||||||
messages=$(echo "$RESULT"|grep -i unable )
|
messages=$(echo "$RESULT"|grep -i unable )
|
||||||
OUTPUT="CRITICAL - CUPS Unable to connect: "$messages"."
|
OUTPUT="CRITICAL - CUPS Unable to connect: $messages."
|
||||||
exitstatus="$STATE_CRITICAL"
|
exitstatus="$STATE_CRITICAL"
|
||||||
;;
|
;;
|
||||||
*disabled*)
|
*disabled*)
|
||||||
messages=$(echo "$RESULT"|grep -i disabled)
|
messages=$(echo "$RESULT"|grep -i disabled)
|
||||||
OUTPUT="CRITICAL - CUPS printer: "$messages"."
|
OUTPUT="CRITICAL - CUPS printer: $messages."
|
||||||
exitstatus="$STATE_CRITICAL"
|
exitstatus="$STATE_CRITICAL"
|
||||||
;;
|
;;
|
||||||
*Paused*)
|
*Paused*)
|
||||||
messages=$(echo "$RESULT"|grep -i paused)
|
messages=$(echo "$RESULT"|grep -i paused)
|
||||||
OUTPUT="WARNING: - CUPS printer is: "$messages"."
|
OUTPUT="WARNING: - CUPS printer is: $messages."
|
||||||
exitstatus="$STATE_WARNING"
|
exitstatus="$STATE_WARNING"
|
||||||
;;
|
;;
|
||||||
*printing*)
|
*printing*)
|
||||||
OUTPUT="OK - CUPS printer is printing now."
|
OUTPUT="OK - CUPS printer is printing now."
|
||||||
exitstatus="$STATE_OK"
|
exitstatus="$STATE_OK"
|
||||||
;;
|
;;
|
||||||
*idle*)
|
*idle*)
|
||||||
OUTPUT="OK - CUPS printer "$printername" is idle."
|
OUTPUT="OK - CUPS printer $printername is idle."
|
||||||
exitstatus="$STATE_OK"
|
exitstatus="$STATE_OK"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
OUTPUT="CRITICAL - Unknown error occured while checking: "$RESULT"."
|
OUTPUT="CRITICAL - Unknown error occured while checking: $RESULT."
|
||||||
exitstatus="$STATE_CRITICAL"
|
exitstatus="$STATE_CRITICAL"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# It testing how many variable user add on command line
|
# Test how many variable we got on command line
|
||||||
# The minimu for test printes only is 3
|
# The minimum for test printers is 3
|
||||||
|
|
||||||
if [ $# -lt 3 ]; then
|
if [ $# -lt 3 ]; then
|
||||||
print_usage
|
print_usage
|
||||||
exit "$STATE_UNKNOWN"
|
exit "$STATE_UNKNOWN"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# this set default exit status to:
|
# this set default exit status to:
|
||||||
@@ -218,153 +222,155 @@ exitstatus="$STATE_UNKNOWN"
|
|||||||
# by default is test pritner disabled, you must allow it with -p $printer or -P all printers
|
# by default is test pritner disabled, you must allow it with -p $printer or -P all printers
|
||||||
testprinter="0"
|
testprinter="0"
|
||||||
|
|
||||||
|
|
||||||
# testing arguments:
|
# testing arguments:
|
||||||
while test -n "$1"; do
|
while test -n "$1"; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--help)
|
--help)
|
||||||
print_help
|
print_help
|
||||||
exit "$STATE_OK"
|
exit "$STATE_OK"
|
||||||
;;
|
;;
|
||||||
-h)
|
-h)
|
||||||
print_help
|
print_help
|
||||||
exit "$STATE_OK"
|
exit "$STATE_OK"
|
||||||
;;
|
;;
|
||||||
-P)
|
-P)
|
||||||
testprinter="1"
|
testprinter="1"
|
||||||
;;
|
;;
|
||||||
-p)
|
-p)
|
||||||
testprinter="2"
|
testprinter="2"
|
||||||
printername="$2"
|
printername="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-H)
|
-H)
|
||||||
hostname=$2
|
hostname="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-Q)
|
-Q)
|
||||||
testtype=$2
|
testtype="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-w)
|
-w)
|
||||||
warnlevel=$2
|
warnlevel="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-c)
|
-c)
|
||||||
critlevel=$2
|
critlevel="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-a)
|
-a)
|
||||||
maxage=$2
|
maxage="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
esac
|
-d)
|
||||||
shift
|
DEBUG='yes'
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check arguments for validity:
|
# Check arguments for validity:
|
||||||
if [ -z $hostname ]
|
if [ -z "$hostname" ]
|
||||||
then
|
then
|
||||||
echo "You must specify a hostname (or localhost to test the local system)"
|
echo "You must specify a hostname (or localhost to test the local system)" >&2
|
||||||
print_usage
|
print_usage
|
||||||
exitstatus="$STATE_UNKNOWN"
|
exitstatus="$STATE_UNKNOWN"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# testing priner(s)
|
# testing printer(s)
|
||||||
|
if [ "$testprinter" -eq "2" ] # Check specific printer and continue with the script
|
||||||
|
|
||||||
if [ $testprinter -eq 2 ] #Check specifics printer and continue with the script
|
|
||||||
then
|
then
|
||||||
check_printer_status "$printername"
|
check_printer_status "$printername"
|
||||||
|
|
||||||
if [ -z $testtype ] # exits if there is no -Q checks
|
if [ -z "$testtype" ] # exit if there is no -Q checks
|
||||||
then
|
then
|
||||||
echo "$OUTPUT"
|
echo "$OUTPUT"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
fi
|
fi
|
||||||
elif [ $testprinter -eq 1 ]; then # check all printers
|
elif [ "$testprinter" -eq "1" ]; then # check all printers
|
||||||
check_printer_status
|
check_printer_status
|
||||||
if [ -z $testtype ]; then # exits if there is no -Q checks
|
if [ -z "$testtype" ]; then # exit if there is no -Q checks
|
||||||
echo "$OUTPUT"
|
echo "$OUTPUT"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
fi
|
fi
|
||||||
else # no cuos check is need
|
else # no cuos check is need
|
||||||
echo "No printer check is require. Checking the queue ..."
|
if [ "$DEBUG" == 'yes' ]; then
|
||||||
|
echo "No printer check required. Checking the queue ..."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# testing arguments for the queue checks:
|
# testing arguments for the queue checks:
|
||||||
if [[ -z $critlevel || -z $warnlevel ]] # Did we get warn and crit values?
|
if [[ -z "$critlevel" || -z "$warnlevel" ]] # Did we get warn and crit values?
|
||||||
then
|
then
|
||||||
echo "You must specify a warning and critical level"
|
echo "You must specify a warning and critical level"
|
||||||
print_usage
|
print_usage
|
||||||
exitstatus="$STATE_UNKNOWN"
|
exitstatus="$STATE_UNKNOWN"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
elif [ $critlevel -lt $warnlevel ] # Do the warn/crit values make sense?
|
elif [ $critlevel -lt $warnlevel ] # Do the warn/crit values make sense?
|
||||||
then
|
then
|
||||||
echo "CRITICAL value of "$critlevel" is less than WARNING level of "$warnlevel""
|
echo "CRITICAL value of $critlevel is less than WARNING level of $warnlevel"
|
||||||
print_usage
|
print_usage
|
||||||
exitstatus="$STATE_UNKNOWN"
|
exitstatus="$STATE_UNKNOWN"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# what kind of queue test will be run:
|
# what kind of queue test will be run:
|
||||||
if [ -z $testtype ]
|
if [ -z "$testtype" ]
|
||||||
then
|
then
|
||||||
|
echo "You must specify a test type"
|
||||||
echo "You must specify a test type"
|
print_usage
|
||||||
print_usage
|
exitstatus="$STATE_UNKNOWN"
|
||||||
exitstatus="$STATE_UNKNOWN"
|
exit "$exitstatus"
|
||||||
exit "$exitstatus"
|
|
||||||
# this is a very nice elif, it match if -a X is missing
|
# this is a very nice elif, it match if -a X is missing
|
||||||
elif [[ "$testtype" = [b]* && -z $maxage ]]
|
elif [[ "$testtype" = [b]* && -z "$maxage" ]]
|
||||||
then
|
then
|
||||||
echo "You must specify <max age> when using a test type of 'b'"
|
echo "You must specify <max age> when using a test type of 'b'"
|
||||||
print_usage
|
print_usage
|
||||||
exitstatus="$STATE_UNKNOWN"
|
exitstatus="$STATE_UNKNOWN"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
else
|
else
|
||||||
echo "Testing queue on the CUPS..."
|
if [ "$DEBUG" == 'yes' ]; then
|
||||||
JOBTMP=$(mktemp -t lpstat.XXXXXX) # Create a tmpfile to store the lpstat results
|
echo "Testing queue on $hostname ..."
|
||||||
STALEJOBCOUNT=0 # default number of old jobs
|
fi
|
||||||
CURDATETS=$(date +%s) # Get the current date as unixtime
|
JOBTMP=$(mktemp -t lpstat.XXXXXX) # Create a tmpfile to store the lpstat results
|
||||||
"$LPSTAT" -h "$hostname" -o > "$JOBTMP" # run the lpstat command against the host.
|
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 ]
|
if [ $? -ne 0 ]
|
||||||
then
|
then
|
||||||
rm -rf "$JOBTMP"
|
rm -rf "$JOBTMP"
|
||||||
echo "UNKNOWN: lpstat command returned an error. Please test this script manually."
|
echo "UNKNOWN: lpstat command returned an error. Please test this script manually."
|
||||||
exitstatus="$STATE_UNKNOWN"
|
exitstatus="$STATE_UNKNOWN"
|
||||||
exit "$exitstatus"
|
exit "$exitstatus"
|
||||||
fi
|
fi
|
||||||
JOBCOUNT=$(wc -l < $JOBTMP) # populate the jobcount
|
JOBCOUNT=$(wc -l < $JOBTMP) # populate the jobcount
|
||||||
PERFDATA="print_jobs="$JOBCOUNT";"$warnlevel";"$critlevel";0"
|
PERFDATA="print_jobs=${JOBCOUNT};${warnlevel};${critlevel};0"
|
||||||
if [[ "$JOBCOUNT" -gt 0 && $maxage ]]
|
if [[ "$JOBCOUNT" -gt 0 && "$maxage" ]]
|
||||||
then
|
then
|
||||||
MAXAGETS=$(echo "86400 * $maxage" | bc) # 86400 seconds in a day * maxage
|
MAXAGETS=$(echo "86400 * $maxage" | bc) # 86400 seconds in a day * maxage
|
||||||
exec<"$JOBTMP" # read the file to determine job age
|
exec<"$JOBTMP" # read the file to determine job age
|
||||||
while read PRINTJOB
|
while read PRINTJOB
|
||||||
do
|
do
|
||||||
# Grab the job date from the job listing
|
# Grab the job date from the job listing
|
||||||
JOBDATE=$(echo $PRINTJOB | cut -c50-73)
|
JOBDATE=$(echo "$PRINTJOB" | cut -c50-73)
|
||||||
# Convert the job date to unixtime
|
# Convert the job date to unixtime
|
||||||
JOBDATETS=$(date --date="$JOBDATE" +%s)
|
JOBDATETS=$(date --date="$JOBDATE" +%s)
|
||||||
DATEDIFF=$(echo "($CURDATETS - $JOBDATETS)" | bc)
|
DATEDIFF=$(echo "($CURDATETS - $JOBDATETS)" | bc)
|
||||||
if [ $DATEDIFF -gt $MAXAGETS ]
|
if [ $DATEDIFF -gt $MAXAGETS ]
|
||||||
then
|
then
|
||||||
MESSAGE="CRITICAL: Some CUPS jobs are older than "$maxage" days| "$PERFDATA""
|
MESSAGE="CRITICAL: Some CUPS jobs are older than $maxage days| $PERFDATA"
|
||||||
exitstatus="$STATE_CRITICAL"
|
exitstatus="$STATE_CRITICAL"
|
||||||
else
|
else
|
||||||
check_queue_size
|
check_queue_size
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
check_queue_size
|
check_queue_size
|
||||||
fi
|
fi
|
||||||
rm -rf "$JOBTMP"
|
rm -rf "$JOBTMP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# end: print the results and end with exit code for Nagios
|
# end: print the results and end with exit code for Nagios
|
||||||
echo "$OUTPUT"
|
echo "$OUTPUT"
|
||||||
echo "$MESSAGE"
|
echo "$MESSAGE"
|
||||||
|
@@ -42,6 +42,8 @@ Source24: usr.lib.nagios.plugins.check_ide_smart
|
|||||||
Source25: usr.lib.nagios.plugins.check_ssh
|
Source25: usr.lib.nagios.plugins.check_ssh
|
||||||
Source26: check_ircd_ssl
|
Source26: check_ircd_ssl
|
||||||
Source27: %{name}-README-extra-opts
|
Source27: %{name}-README-extra-opts
|
||||||
|
Source28: %{name}-README.SUSE-check_ping
|
||||||
|
Source29: %{name}-README.SUSE-check_ntp_time
|
||||||
Patch1: %{name}-1.4.14-ntpd.patch
|
Patch1: %{name}-1.4.14-ntpd.patch
|
||||||
Patch2: %{name}-1.4.14-check_log.patch
|
Patch2: %{name}-1.4.14-check_log.patch
|
||||||
Patch6: %{name}-1.4.6-no_chown.patch
|
Patch6: %{name}-1.4.6-no_chown.patch
|
||||||
@@ -1070,6 +1072,9 @@ it will provide the size of the queue of age of queue.
|
|||||||
%{__cp} %{S:14} ./README.SUSE-check_icmp
|
%{__cp} %{S:14} ./README.SUSE-check_icmp
|
||||||
%{__cp} %{S:15} ./README.SUSE-check_ide_smart
|
%{__cp} %{S:15} ./README.SUSE-check_ide_smart
|
||||||
%{__cp} %{S:20} ./README.SUSE-check_cups
|
%{__cp} %{S:20} ./README.SUSE-check_cups
|
||||||
|
%{__cp} %{S:28} ./README.SUSE-check_ping
|
||||||
|
%{__cp} %{S:29} ./README.SUSE-check_ntp_time
|
||||||
|
|
||||||
for extension in mysql pgsql sqlite3 ; do
|
for extension in mysql pgsql sqlite3 ; do
|
||||||
cat >> README.SUSE-dbi-$extension << EOF
|
cat >> README.SUSE-dbi-$extension << EOF
|
||||||
This program connects to an (SQL) database using DBI and checks the
|
This program connects to an (SQL) database using DBI and checks the
|
||||||
|
@@ -3,4 +3,6 @@
|
|||||||
#include <abstractions/base>
|
#include <abstractions/base>
|
||||||
#include <abstractions/nameservice>
|
#include <abstractions/nameservice>
|
||||||
capability net_raw,
|
capability net_raw,
|
||||||
|
|
||||||
|
/etc/monitoring-plugins/* r,
|
||||||
}
|
}
|
||||||
|
@@ -6,4 +6,6 @@
|
|||||||
capability net_raw,
|
capability net_raw,
|
||||||
capability setuid,
|
capability setuid,
|
||||||
network inet raw,
|
network inet raw,
|
||||||
|
|
||||||
|
/etc/monitoring-plugins/* r,
|
||||||
}
|
}
|
||||||
|
@@ -7,4 +7,6 @@
|
|||||||
capability sys_rawio,
|
capability sys_rawio,
|
||||||
/dev/s* r,
|
/dev/s* r,
|
||||||
/dev/h* r,
|
/dev/h* r,
|
||||||
|
|
||||||
|
/etc/monitoring-plugins/* r,
|
||||||
}
|
}
|
||||||
|
@@ -19,4 +19,6 @@
|
|||||||
/etc/hosts r,
|
/etc/hosts r,
|
||||||
/etc/resolv.conf r,
|
/etc/resolv.conf r,
|
||||||
/var/run/nscd/* r,
|
/var/run/nscd/* r,
|
||||||
|
|
||||||
|
/etc/monitoring-plugins/* r,
|
||||||
}
|
}
|
||||||
|
@@ -9,4 +9,6 @@
|
|||||||
network inet6 raw,
|
network inet6 raw,
|
||||||
/{usr/,}bin/ping rix,
|
/{usr/,}bin/ping rix,
|
||||||
/{usr/,}bin/ping6 rix,
|
/{usr/,}bin/ping6 rix,
|
||||||
|
|
||||||
|
/etc/monitoring-plugins/* r,
|
||||||
}
|
}
|
||||||
|
@@ -2,4 +2,6 @@
|
|||||||
/usr/lib/nagios/plugins/check_ssh flags=(complain) {
|
/usr/lib/nagios/plugins/check_ssh flags=(complain) {
|
||||||
#include <abstractions/base>
|
#include <abstractions/base>
|
||||||
#include <abstractions/nameservice>
|
#include <abstractions/nameservice>
|
||||||
|
|
||||||
|
/etc/monitoring-plugins/* r,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user