forked from jonschipp/nagios-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_enq.sh
executable file
·82 lines (68 loc) · 1.7 KB
/
check_enq.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
# Author: Jon Schipp
########
# Examples:
# 1.) Return critical if any queue is in the DOWN state
# $ ./check_enq.sh -d
#
# 2.) Return critical if any queue is in the DOWN state except those listed
# $ ./check_enq.sh -d -e "color,black,invoice"
#
# 3.) Return critical if color is in DOWN state
# $ ./check_enq.sh -d -q color
# Nagios Exit Codes
OK=0
WARNING=1
CRITICAL=2
UNKNOWN=3
# set default values for the thresholds
usage()
{
cat <<EOF
Check printer queue status (enq) on AIX. If the queue
matches the given status then return OK.
Options:
-q Comma separated list of print queue names (def: all)
-d Given a queue, alert on those in a DOWN state
-e Comma separated list of queues to exclude from the default all list
-s Status to look for (READY/RUNNING/DOWN/QUEUED)
Usage: $0 -q "invoice,black" -s READY
EOF
}
argcheck() {
# if less than n argument
if [ $ARGC -lt $1 ]; then
echo "Missing arguments! Use \`\`-h'' for help."
exit 1
fi
}
ARGC=$#
DOWN_CHECK=0
STATUS_CHECK=0
QUEUE=".*"
WONTMATCH=asdlfjasdlfjasdflasdjfaldsjfaldfj
argcheck 1
while getopts "hde:q:s:" ARG;
do
case $ARG in
d) DOWN_CHECK=1
;;
e) EXCLUDE=$(echo $OPTARG| sed 's/,/|/g')
;;
q) QUEUE=$(echo $OPTARG| sed 's/,/|/g')
;;
s) STATUS=$OPTARG
STATUS_CHECK=1
;;
h) usage
exit
;;
esac
done
if [ $DOWN_CHECK -eq 1 ]; then
enq -A all | grep -v -E "${EXCLUDE:-$WONTMATCH}" | grep -E "$QUEUE" | grep DOWN && exit $CRITICAL ||
(echo "No queues in down state" && exit $OK)
fi
#if [ $STATUS_CHECK -eq 1 ]; then
# enq -A all |
#fi