2020-06-05 14:51:58 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2020-06-09 11:57:57 +02:00
|
|
|
# SGE: Sun Grid Engine check - Xymon external script test
|
2020-06-05 14:51:58 +02:00
|
|
|
#
|
|
|
|
##### Purpose is to report back to a central server, all Sun
|
|
|
|
##### Grid Engine software faults.
|
|
|
|
#####
|
|
|
|
#
|
2020-06-09 11:57:57 +02:00
|
|
|
# version 0.4
|
2020-06-05 14:51:58 +02:00
|
|
|
#
|
|
|
|
# BIG BROTHER / XXXXXXXXXXXXXXXX status
|
|
|
|
#
|
|
|
|
# Written by Butch Deal <butchdeal@yahoo.com>
|
|
|
|
# Daniel Gomez <dgomez@tigr.org,daniel@ixplosive.com>
|
2020-06-09 11:57:57 +02:00
|
|
|
# Jérémy Gardais <jeremy.gardais@univ-rennes1.fr>
|
2020-06-05 14:51:58 +02:00
|
|
|
#
|
2020-06-09 11:57:57 +02:00
|
|
|
# v0.4 09/06/20 clean, correction,… for Xymon 4.3.28
|
2020-06-05 14:51:58 +02:00
|
|
|
# v0.3e 10/14/08 cut down on the number of qhost runs
|
|
|
|
# v0.3d 03/31/06 added alarm/suspend state identification
|
|
|
|
# v0.3c 03/01/06 propogated yellow state upon UNAVAILABLE queue intances
|
|
|
|
# v0.3b 01/31/06 fixed yellow warning queue status for ambigious config test
|
|
|
|
# v0.3a 01/31/06 added unknown queue status and ambigious config test
|
|
|
|
# v0.3 01/26/06 fixed status reporting and optimized job status
|
|
|
|
# v0.2 08/03/05 flag disabled queues as clear
|
|
|
|
# v0.1 07/28/05 authored
|
|
|
|
|
|
|
|
########################################
|
|
|
|
# NOTE
|
2020-06-09 11:57:57 +02:00
|
|
|
# The version v0.4 has only been tested with Xymon (server and client) 4.2.x.
|
2020-06-05 14:51:58 +02:00
|
|
|
#
|
|
|
|
# The color status with respects to queue status is arbitrary and should be
|
|
|
|
# reviewed for your particular environment.
|
|
|
|
#
|
|
|
|
# Tested on :
|
|
|
|
# Solaris & Linux
|
2020-06-09 11:57:57 +02:00
|
|
|
# Linux only (for v0.4)
|
2020-06-05 14:51:58 +02:00
|
|
|
########################################
|
|
|
|
|
|
|
|
########################################
|
|
|
|
# INSTALLATION
|
2020-06-09 11:57:57 +02:00
|
|
|
# step 1 - copy to Xymon client's ext dir
|
|
|
|
# step 2 - New clientlaunch.d/sge.cfg file
|
|
|
|
# step 3 - restart Xymon client
|
2020-06-05 14:51:58 +02:00
|
|
|
#
|
|
|
|
# NOTE - the TEST variable in the configuration section, this is the name used
|
|
|
|
# as the column header.
|
|
|
|
########################################
|
|
|
|
|
|
|
|
##################################
|
|
|
|
# CONFIGURE IT HERE
|
|
|
|
##################################
|
2020-06-05 15:24:51 +02:00
|
|
|
readonly PLUGIN_NAME=$(basename "${0}")
|
2020-06-05 14:51:58 +02:00
|
|
|
|
2020-06-05 15:24:51 +02:00
|
|
|
readonly TEST="sge"
|
|
|
|
readonly PLUGIN_RESULT="${XYMONTMP}/${MACHINEDOTS}.${TEST}.plugin_result"
|
2020-06-10 15:57:38 +02:00
|
|
|
readonly PLUGIN_STATE="${XYMONTMP}/${MACHINEDOTS}.${TEST}.plugin_state"
|
|
|
|
true > "${PLUGIN_STATE}"
|
2020-06-05 15:24:51 +02:00
|
|
|
|
|
|
|
readonly QSTAT=$(command -v qstat)
|
|
|
|
readonly QHOST=$(command -v qhost)
|
|
|
|
readonly QSELECT=$(command -v qselect)
|
|
|
|
export QSTAT QHOST QSELECT
|
2020-06-05 14:51:58 +02:00
|
|
|
|
|
|
|
# define colours for graphics
|
|
|
|
# Comment these out if using older BB versions
|
|
|
|
CLEAR_PIC="&clear"
|
|
|
|
RED_PIC="&red"
|
|
|
|
YELLOW_PIC="&yellow"
|
|
|
|
GREEN_PIC="&green"
|
|
|
|
UNKNOWN_PIC="&purple"
|
|
|
|
|
|
|
|
##################################
|
|
|
|
# Start of script
|
|
|
|
##################################
|
|
|
|
|
|
|
|
get_header()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
#echo "<FONT SIZE=+2><b>$1</b></FONT> ($2)<BR>"
|
|
|
|
echo "<FONT SIZE=+2><b>$1</b></FONT> <BR>"
|
|
|
|
# If you do not want the header in a bigger font use line below instead
|
|
|
|
#echo "<b>$1</b> ($2)"
|
|
|
|
# If you want the "Paul Luzzi" look uncomment this section and comment
|
|
|
|
# out the above sections:
|
|
|
|
#echo "<P><DIV ALIGN=\"CENTER\"><HR>"
|
|
|
|
#echo "<B>============== $1 ==============</B>"
|
|
|
|
#echo "<B>--- ($2) ---</B>"
|
|
|
|
#echo "<HR></DIV>"
|
|
|
|
#echo "<BLOCKQUOTE>"
|
|
|
|
}
|
|
|
|
get_header_small()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
#echo "<FONT SIZE=+2><b>$1</b></FONT> ($2)<BR>"
|
|
|
|
echo "<FONT SIZE=+1><b>$1</b></FONT> <BR>"
|
|
|
|
# If you do not want the header in a bigger font use line below instead
|
|
|
|
# echo "<b>$1</b> ($2)"
|
|
|
|
# If you want the "Paul Luzzi" look uncomment this section and comment
|
|
|
|
# out the above sections:
|
|
|
|
#echo "<P><DIV ALIGN=\"CENTER\"><HR>"
|
|
|
|
#echo "<B>============== $1 ==============</B>"
|
|
|
|
#echo "<B>--- ($2) ---</B>"
|
|
|
|
#echo "<HR></DIV>"
|
|
|
|
#echo "<BLOCKQUOTE>"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
get_footer()
|
|
|
|
{
|
|
|
|
echo ""
|
|
|
|
# If you want the "Paul Luzzi" look uncomment this section and comment
|
|
|
|
# out the above sections:
|
|
|
|
#echo "</BLOCKQUOTE>"
|
|
|
|
}
|
|
|
|
|
|
|
|
#####
|
|
|
|
##### Get Status proc - used to get all responses
|
|
|
|
#####
|
|
|
|
get_status()
|
|
|
|
{
|
|
|
|
|
|
|
|
# Check defaults have been set
|
2020-06-05 15:24:51 +02:00
|
|
|
if [ "${QSTAT}" = "" ]; then
|
|
|
|
readonly QSTAT=$(command -v qstat)
|
2020-06-05 14:51:58 +02:00
|
|
|
echo ""
|
2020-06-05 15:24:51 +02:00
|
|
|
echo "$YELLOW_PIC QSTAT command is not defined in etc/bbsys.local - using default: ${QSTAT}"
|
2020-06-05 14:51:58 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-05 15:24:51 +02:00
|
|
|
if [ "${QHOST}" = "" ]; then
|
|
|
|
readonly QHOST=$(command -v qhost)
|
2020-06-05 14:51:58 +02:00
|
|
|
echo ""
|
2020-06-05 15:24:51 +02:00
|
|
|
echo "$YELLOW_PIC QHOST command is not defined in etc/bbsys.local - using default: ${QHOST}"
|
2020-06-05 14:51:58 +02:00
|
|
|
fi
|
|
|
|
|
2020-06-05 15:24:51 +02:00
|
|
|
if [ "${QSELECT}" = "" ]; then
|
|
|
|
readonly QSELECT=$(command -v qselect)
|
2020-06-05 14:51:58 +02:00
|
|
|
echo ""
|
2020-06-05 15:24:51 +02:00
|
|
|
echo "$YELLOW_PIC QSELECT command is not defined in etc/bbsys.local - using default: ${QSELECT}"
|
2020-06-05 14:51:58 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
###
|
|
|
|
### Check the jobs
|
|
|
|
###
|
|
|
|
get_header "Jobs" "$QSTAT -l hostname=$MACHINEDOTS"
|
2020-06-09 11:59:33 +02:00
|
|
|
jobs=$(${QSTAT} -l hostname="${MACHINEDOTS}" -s r -u \*)
|
2020-06-05 14:51:58 +02:00
|
|
|
if [ -z "$jobs" ]; then
|
|
|
|
echo "No Running Jobs"
|
|
|
|
else
|
2020-06-09 11:59:33 +02:00
|
|
|
${QSTAT} -l hostname="${MACHINEDOTS}" -s r -u \*
|
2020-06-05 14:51:58 +02:00
|
|
|
fi
|
|
|
|
get_footer
|
|
|
|
|
|
|
|
###
|
|
|
|
### Check the host
|
|
|
|
###
|
|
|
|
get_header "Host" "$METAHS -i"
|
2020-06-09 11:59:33 +02:00
|
|
|
${QHOST} -h "${MACHINEDOTS}" | grep -v "global"
|
2020-06-05 14:51:58 +02:00
|
|
|
get_footer
|
|
|
|
|
|
|
|
###
|
|
|
|
### Identify queue memberships
|
|
|
|
###
|
|
|
|
#get_header "Queue Membership" "$QHOST -q"
|
2020-06-05 15:49:21 +02:00
|
|
|
#${QHOST} -h ${MACHINEDOTS} -q | tail +5
|
2020-06-05 14:51:58 +02:00
|
|
|
#get_footer
|
|
|
|
|
|
|
|
###
|
|
|
|
### Check queue instance states
|
|
|
|
###
|
|
|
|
queueTriggered=false;
|
2020-06-09 11:59:33 +02:00
|
|
|
${QHOST} -h "${MACHINEDOTS}" -q | tail +5 > "${PLUGIN_RESULT}.QSTATE"
|
2020-06-10 16:11:17 +02:00
|
|
|
while IFS= read -r _LINE; do
|
|
|
|
queue=$(printf -- '%s' "${_LINE}" | awk '{ print $1 }')
|
|
|
|
qstate=$(printf -- '%s' "${_LINE}" | awk '{ print $4 }')
|
2020-06-05 14:51:58 +02:00
|
|
|
|
2020-06-10 15:57:38 +02:00
|
|
|
# Order determines more significant alert status
|
2020-06-05 15:49:21 +02:00
|
|
|
if [ "$(echo "${qstate}" | grep -c d)" != "0" ]; then
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "4&clear $queue@$HOST is DISABLED" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$CLEAR_PIC $queue@$HOST is DISABLED<BR>${_LINE}")
|
2020-06-05 14:51:58 +02:00
|
|
|
queueTriggered=true;
|
2020-06-05 15:49:21 +02:00
|
|
|
elif [ "$(echo "${qstate}" | grep -c E)" != "0" ]; then
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "1&red $queue@$HOST is in ERROR!" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$RED_PIC $queue@$HOST is in ERROR!<BR>${_LINE}")
|
2020-06-05 14:51:58 +02:00
|
|
|
queueTriggered=true;
|
2020-06-05 15:49:21 +02:00
|
|
|
elif [ "$(echo "${qstate}" | grep -c c)" != "0" ]; then
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "2&yellow $queue@$HOST has an ambigious configuration!" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $queue@$HOST has an ambigious configuration!<BR>${_LINE}")
|
2020-06-05 14:51:58 +02:00
|
|
|
queueTriggered=true;
|
2020-06-05 15:49:21 +02:00
|
|
|
elif [ "$(echo "${qstate}" | grep -c a)" != "0" ] || \
|
|
|
|
[ "$(echo "${qstate}" | grep -c A)" != "0" ]; then
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "2&yellow $queue@$HOST is in ALARM" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $queue@$HOST is in ALARM<BR>${_LINE}")
|
2020-06-05 15:49:21 +02:00
|
|
|
elif [ "$(echo "${qstate}" | grep -c s)" != "0" ] || \
|
|
|
|
[ "$(echo "${qstate}" | grep -c S)" != "0" ]; then
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "2&yellow $queue@$HOST is SUSPENDED" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $queue@$HOST is SUSPENDED<BR>${_LINE}")
|
2020-06-05 15:49:21 +02:00
|
|
|
elif [ "$(echo "${qstate}" | grep -c u)" != "0" ]; then
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "2&yellow $queue@$HOST is UNAVAILABLE" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $queue@$HOST is UNAVAILABLE!<BR>${_LINE}")
|
2020-06-05 14:51:58 +02:00
|
|
|
queueTriggered=true;
|
|
|
|
elif [ "$qstate" = "" ]; then
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "3&green $queue@$HOST is OK" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$GREEN_PIC $queue@$HOST is OK<BR>${_LINE}")
|
2020-06-05 14:51:58 +02:00
|
|
|
else
|
2020-06-10 16:11:17 +02:00
|
|
|
echo "5&purple $queue@$HOST is UNKNOWN" >> "${PLUGIN_STATE}"
|
2020-06-10 16:15:29 +02:00
|
|
|
queueMsg=$(echo "$queueMsg<BR>$UNKNOWN_PIC $queue@$HOST is UNKNOWN<BR>${_LINE}")
|
2020-06-05 14:51:58 +02:00
|
|
|
queueTriggered=true;
|
|
|
|
fi
|
2020-06-10 16:11:17 +02:00
|
|
|
done < "${PLUGIN_RESULT}.QSTATE"
|
2020-06-05 14:51:58 +02:00
|
|
|
|
|
|
|
get_header "Queue Instance Status Report"
|
|
|
|
echo "$queueMsg"
|
|
|
|
get_footer
|
|
|
|
|
|
|
|
#####
|
|
|
|
##### End of get_status proc
|
|
|
|
#####
|
|
|
|
}
|
|
|
|
|
|
|
|
#####
|
|
|
|
##### Main body
|
|
|
|
#####
|
2020-06-05 15:24:51 +02:00
|
|
|
get_status > "${PLUGIN_RESULT}"
|
2020-06-05 14:51:58 +02:00
|
|
|
|
2020-06-10 15:57:38 +02:00
|
|
|
# Set the global color according to the highest alert
|
|
|
|
COLOR=$(< "${PLUGIN_STATE}" awk '{print $1}' | sort | uniq | head -1 | cut -c3-)
|
|
|
|
|
2020-06-05 15:24:51 +02:00
|
|
|
# NOW USE THE XYMON COMMAND TO SEND THE DATA ACROSS
|
2020-06-09 11:47:53 +02:00
|
|
|
$XYMON "${XYMSRV}" "status ${MACHINE}.${TEST} ${COLOR} $($DATE) $(cat ${PLUGIN_RESULT})"
|
2020-06-05 14:51:58 +02:00
|
|
|
#For testing only
|
2020-06-09 11:47:53 +02:00
|
|
|
# echo $XYMON "${XYMSRV}" "status ${MACHINE}.${TEST} ${COLOR} $($DATE) $(cat ${PLUGIN_RESULT})" > /tmp/sgetmp
|
2020-06-05 14:51:58 +02:00
|
|
|
|
|
|
|
# Clean up our mess
|
|
|
|
# Checking for existence of each file since the whole test may be optional
|
|
|
|
# and may not actually run on every client
|
|
|
|
#
|
2020-06-05 15:24:51 +02:00
|
|
|
if [ -f "${PLUGIN_RESULT}" ]; then
|
2020-06-10 16:15:29 +02:00
|
|
|
rm -f -- "${PLUGIN_RESULT}" "${PLUGIN_STATE}" "${PLUGIN_RESULT}.QSTATE"
|
2020-06-05 14:51:58 +02:00
|
|
|
fi
|
|
|
|
##############################################
|
|
|
|
# end of script
|
|
|
|
##############################################
|