Fix old SGE and BB vars

This commit is contained in:
Jeremy Gardais 2020-06-05 15:24:51 +02:00
parent fa02d6d485
commit a4a6ba597f
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 28 additions and 46 deletions

View File

@ -46,14 +46,15 @@
################################## ##################################
# CONFIGURE IT HERE # CONFIGURE IT HERE
################################## ##################################
TEST="sge" readonly PLUGIN_NAME=$(basename "${0}")
BBPROG="$0"; export BBPROG
SGEBIN=/usr/local/bin readonly TEST="sge"
QSTAT=${SGEBIN}/qstat readonly PLUGIN_RESULT="${XYMONTMP}/${MACHINEDOTS}.${TEST}.plugin_result"
QHOST=${SGEBIN}/qhost
QSELECT=${SGEBIN}/qselect readonly QSTAT=$(command -v qstat)
export SGEBIN QSTAT QHOST QSELECT readonly QHOST=$(command -v qhost)
readonly QSELECT=$(command -v qselect)
export QSTAT QHOST QSELECT
# define colours for graphics # define colours for graphics
# Comment these out if using older BB versions # Comment these out if using older BB versions
@ -66,25 +67,6 @@ UNKNOWN_PIC="&purple"
################################## ##################################
# Start of script # Start of script
################################## ##################################
BBHOME="/var/BB/bb"; export BBHOME
if test ! "$BBHOME"
then
echo "template: BBHOME is not set"
exit 1
fi
if test ! -d "$BBHOME"
then
echo "template: BBHOME is invalid"
exit 1
fi
if test ! "$BBTMP" # GET DEFINITIONS IF NEEDED
then
# echo "*** LOADING BBDEF ***"
. $BBHOME/etc/bbdef.sh # INCLUDE STANDARD DEFINITIONS
fi
get_header() get_header()
{ {
@ -137,22 +119,22 @@ get_status()
COLOR="green" COLOR="green"
# Check defaults have been set # Check defaults have been set
if [ "$SGEBIN" = "" ]; then if [ "${QSTAT}" = "" ]; then
SGEBIN=/usr/local/bin readonly QSTAT=$(command -v qstat)
echo "" echo ""
echo "$YELLOW_PIC SGEBIN command is not defined in etc/bbsys.local - using default: $SGEBIN" echo "$YELLOW_PIC QSTAT command is not defined in etc/bbsys.local - using default: ${QSTAT}"
fi fi
if [ "$QSTAT" = "" ]; then if [ "${QHOST}" = "" ]; then
QSTAT=${SGEBIN}/qstat readonly QHOST=$(command -v qhost)
echo "" echo ""
echo "$YELLOW_PIC QSTAT command is not defined in etc/bbsys.local - using default: $QSTAT" echo "$YELLOW_PIC QHOST command is not defined in etc/bbsys.local - using default: ${QHOST}"
fi fi
if [ "$QHOST" = "" ]; then if [ "${QSELECT}" = "" ]; then
QHOST=${SGEBIN}/qhost readonly QSELECT=$(command -v qselect)
echo "" echo ""
echo "$YELLOW_PIC QHOST command is not defined in etc/bbsys.local - using default: $QHOST" echo "$YELLOW_PIC QSELECT command is not defined in etc/bbsys.local - using default: ${QSELECT}"
fi fi
### ###
@ -186,11 +168,11 @@ get_status()
### ###
queueTriggered=false; queueTriggered=false;
# Queueset=`${QHOST} -h ${MACHINEDOTS} -q | ${TAIL} +5 | ${AWK} '{ print $1 }'` # Queueset=`${QHOST} -h ${MACHINEDOTS} -q | ${TAIL} +5 | ${AWK} '{ print $1 }'`
${QHOST} -h ${MACHINEDOTS} -q | ${TAIL} +5 > $BBTMP/$MACHINE.$TEST.QSTATE ${QHOST} -h ${MACHINEDOTS} -q | ${TAIL} +5 > "${PLUGIN_RESULT}.QSTATE"
Queueset=`cat $BBTMP/$MACHINE.$TEST.QSTATE | ${AWK} '{ print $1 }'` Queueset=`cat "${PLUGIN_RESULT}.QSTATE" | ${AWK} '{ print $1 }'`
for Qset in $Queueset; do for Qset in $Queueset; do
# qstate=`${QHOST} -q -h ${MACHINEDOTS} | ${TAIL} +5 | $GREP " $Qset" | $AWK '{print $4}'` # qstate=`${QHOST} -q -h ${MACHINEDOTS} | ${TAIL} +5 | $GREP " $Qset" | $AWK '{print $4}'`
qstate=`cat $BBTMP/$MACHINE.$TEST.QSTATE | $GREP " $Qset" | $AWK '{print $4}'` qstate=`cat "${PLUGIN_RESULT}.QSTATE" | $GREP " $Qset" | $AWK '{print $4}'`
# Order determines more significant color status # Order determines more significant color status
if [ "`echo $qstate | $GREP -c d`" != "0" ]; then if [ "`echo $qstate | $GREP -c d`" != "0" ]; then
@ -223,8 +205,8 @@ get_status()
fi fi
done done
if [ -f $BBTMP/$MACHINE.$TEST.QSTATE ]; then if [ -f "${PLUGIN_RESULT}.QSTATE" ]; then
$RM $BBTMP/$MACHINE.$TEST.QSTATE rm -f -- "${PLUGIN_RESULT}.QSTATE"
fi fi
get_header "Queue Instance Status Report" get_header "Queue Instance Status Report"
@ -244,20 +226,20 @@ get_status()
##### #####
##### Main body ##### Main body
##### #####
get_status > $BBTMP/$MACHINE.$TEST get_status > "${PLUGIN_RESULT}"
# NOW USE THE BB COMMAND TO SEND THE DATA ACROSS # NOW USE THE XYMON COMMAND TO SEND THE DATA ACROSS
$BB $BBDISP "status $MACHINE.$TEST $COLOR `$DATE` `$CAT $BBTMP/$MACHINE.$TEST`" $XYMON "${XYMONSRV}" "status ${MACHINE}.${TEST} ${COLOR} `$DATE` `cat ${PLUGIN_RESULT}`"
#For testing only #For testing only
# echo $BB $BBDISP "status $BBTMP/$MACHINE.$TEST $COLOR `$DATE` `$CAT $BBTMP/$MACHINE.$TEST` ">/tmp/qtmp # echo $XYMON "${XYMONSRV}" "status ${MACHINE}.${TEST} ${COLOR} `$DATE` `cat ${PLUGIN_RESULT}`" > /tmp/sgetmp
# Clean up our mess # Clean up our mess
# Checking for existence of each file since the whole test may be optional # Checking for existence of each file since the whole test may be optional
# and may not actually run on every client # and may not actually run on every client
# #
if [ -f $BBTMP/$MACHINE.$TEST ]; then if [ -f "${PLUGIN_RESULT}" ]; then
$RM $BBTMP/$MACHINE.$TEST rm -f -- "${PLUGIN_RESULT}"
fi fi
############################################## ##############################################
# end of script # end of script