Order alert status to get global color
This commit is contained in:
parent
8377f3ddce
commit
2dd8aa2ecc
|
@ -53,6 +53,8 @@ readonly PLUGIN_NAME=$(basename "${0}")
|
|||
|
||||
readonly TEST="sge"
|
||||
readonly PLUGIN_RESULT="${XYMONTMP}/${MACHINEDOTS}.${TEST}.plugin_result"
|
||||
readonly PLUGIN_STATE="${XYMONTMP}/${MACHINEDOTS}.${TEST}.plugin_state"
|
||||
true > "${PLUGIN_STATE}"
|
||||
|
||||
readonly QSTAT=$(command -v qstat)
|
||||
readonly QHOST=$(command -v qhost)
|
||||
|
@ -116,10 +118,6 @@ get_footer()
|
|||
#####
|
||||
get_status()
|
||||
{
|
||||
#####
|
||||
##### Setup some variables for use later
|
||||
#####
|
||||
COLOR="green"
|
||||
|
||||
# Check defaults have been set
|
||||
if [ "${QSTAT}" = "" ]; then
|
||||
|
@ -177,32 +175,36 @@ get_status()
|
|||
# qstate=$(${QHOST} -q -h "${MACHINEDOTS}" | tail +5 | grep " $Qset" | awk '{print $4}')
|
||||
qstate=$(grep " $Qset" "${PLUGIN_RESULT}.QSTATE" | awk '{print $4}')
|
||||
|
||||
# Order determines more significant color status
|
||||
# Order determines more significant alert status
|
||||
if [ "$(echo "${qstate}" | grep -c d)" != "0" ]; then
|
||||
COLOR="clear"
|
||||
echo "4&clear $Qset@$HOST is DISABLED" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$CLEAR_PIC $Qset@$HOST is DISABLED")
|
||||
queueTriggered=true;
|
||||
elif [ "$(echo "${qstate}" | grep -c E)" != "0" ]; then
|
||||
COLOR="red"
|
||||
echo "1&red $Qset@$HOST is in ERROR!" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$RED_PIC $Qset@$HOST is in ERROR!")
|
||||
queueTriggered=true;
|
||||
elif [ "$(echo "${qstate}" | grep -c c)" != "0" ]; then
|
||||
COLOR="yellow"
|
||||
echo "2&yellow $Qset@$HOST has an ambigious configuration!" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $Qset@$HOST has an ambigious configuration!")
|
||||
queueTriggered=true;
|
||||
elif [ "$(echo "${qstate}" | grep -c a)" != "0" ] || \
|
||||
[ "$(echo "${qstate}" | grep -c A)" != "0" ]; then
|
||||
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $Qset@$HOST is in ALARM")
|
||||
echo "2&yellow $Qset@$HOST is in ALARM" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $Qset@$HOST is in ALARM<BR>$Qset")
|
||||
elif [ "$(echo "${qstate}" | grep -c s)" != "0" ] || \
|
||||
[ "$(echo "${qstate}" | grep -c S)" != "0" ]; then
|
||||
echo "2&yellow $Qset@$HOST is SUSPENDED" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $Qset@$HOST is SUSPENDED")
|
||||
elif [ "$(echo "${qstate}" | grep -c u)" != "0" ]; then
|
||||
COLOR="yellow"
|
||||
echo "2&yellow $Qset@$HOST is UNAVAILABLE" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$YELLOW_PIC $Qset@$HOST is UNAVAILABLE!")
|
||||
queueTriggered=true;
|
||||
elif [ "$qstate" = "" ]; then
|
||||
echo "3&green $Qset@$HOST is OK" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$GREEN_PIC $Qset@$HOST is OK")
|
||||
else
|
||||
echo "5&purple $Qset@$HOST is UNKNOWN" >> "${PLUGIN_STATE}"
|
||||
queueMsg=$(echo "$queueMsg<BR>$UNKNOWN_PIC $Qset@$HOST is UNKNOWN")
|
||||
queueTriggered=true;
|
||||
fi
|
||||
|
@ -216,11 +218,6 @@ get_status()
|
|||
echo "$queueMsg"
|
||||
get_footer
|
||||
|
||||
#####
|
||||
##### Make sure to export COLOR so that it gets back to "central"
|
||||
#####
|
||||
export COLOR
|
||||
|
||||
#####
|
||||
##### End of get_status proc
|
||||
#####
|
||||
|
@ -231,6 +228,9 @@ get_status()
|
|||
#####
|
||||
get_status > "${PLUGIN_RESULT}"
|
||||
|
||||
# Set the global color according to the highest alert
|
||||
COLOR=$(< "${PLUGIN_STATE}" awk '{print $1}' | sort | uniq | head -1 | cut -c3-)
|
||||
|
||||
# NOW USE THE XYMON COMMAND TO SEND THE DATA ACROSS
|
||||
$XYMON "${XYMSRV}" "status ${MACHINE}.${TEST} ${COLOR} $($DATE) $(cat ${PLUGIN_RESULT})"
|
||||
#For testing only
|
||||
|
@ -241,7 +241,7 @@ get_status > "${PLUGIN_RESULT}"
|
|||
# and may not actually run on every client
|
||||
#
|
||||
if [ -f "${PLUGIN_RESULT}" ]; then
|
||||
rm -f -- "${PLUGIN_RESULT}"
|
||||
rm -f -- "${PLUGIN_RESULT}" "${PLUGIN_STATE}"
|
||||
fi
|
||||
##############################################
|
||||
# end of script
|
||||
|
|
Loading…
Reference in New Issue