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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#!/bin/sh
# Check Grid Engine using qping.
# Dave Love <fx@gnu.org>, 2008-03-27
# Copyright (C) 2008, 2014 University of Liverpool
# 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 3 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/>.
# NB This will produce a warning state for daemons from releases prior
# to SGE 8.1.7.
# Configure these:
# SGE_ROOT=/opt/sge
# export SGE_ROOT
[ -f /etc/profile.d/sge.sh ] && . /etc/profile.d/sge.sh
qping=$SGE_ROOT/bin/$($SGE_ROOT/util/arch)/qping
if [ -f /bin/basename ]; then
PROGNAME=`/bin/basename $0`
else
PROGNAME=`/usr/bin/basename $0`
fi
REVISION=1.0
PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
. $PROGPATH/utils.sh
usage () {
echo "\
Grid Engine plugin for Nagios
-H, --hostname=HOST Name of host to check
-P, --port=PORT Port on which service runs (default 6445 for execd,
6444 for qmaster)
-d, --daemon=NAME Name of daemon to check, either 'execd' or 'qmaster'
(default 'execd')
-h, --help Print this help
--version Print version
Requires SGE version >= 8.1.7.
For qmaster, the number of connected clients is a performance datum."
}
help () {
print_revision $PROGNAME $REVISION
echo; usage
}
cleanup () {
exit $state
}
arg () {
expr $1 : '[^=]*=\(.*\)'
}
daemon=execd
while [ $# -gt 0 ]; do
case $1 in
-h|--help) help; exit $STATE_OK;;
-H|--hostname) shift; host=$1; shift;;
--hostname=*) host=$(arg $1); shift;;
-P|--port) shift; port=$1; shift;;
--port=*) port=$(arg $1); shift;;
-d|--daemon) shift; daemon=$1; shift;;
--daemon=*) daemon=$(arg $1); shift;;
--version | -V)
print_revision $PROGNAME $REVISION
exit $STATE_OK;;
*) usage; exit $STATE_UNKNOWN;;
esac
done
if [ -z "$host" ]; then
usage; exit $STATE_UNKNOWN
fi
case $daemon in
execd) [ -z "$port" ] && port=6445 ;;
qmaster) [ -z "$port" ] && port=6444 ;;
*) usage; exit $STATE_UNKNOWN ;;
esac
state=$STATE_CRITICAL
trap cleanup EXIT
result=$("$qping" -info $host $port $daemon 1 2>&1)
if [ $? -eq 0 ]; then
if [ $daemon = qmaster ]; then
clients=" | connected_clients=$(echo "$result" | awk '/^no. of connected clients:/ {print $NF}')"
fi
case $(echo "$result" | grep "^info:") in
*OK) echo "$daemon OK$clients"; state=$STATE_OK;;
*WARNING|*ERROR) echo "$daemon WARNING$clients"; state=$STATE_WARNING;;
esac
else
echo "CRITICAL Checking $daemon: $result"
fi
exit $state
|