COLOR is added to PLUGIN_RESULT line if expected
This commit is contained in:
parent
b6eb13621d
commit
19c1756bef
|
@ -17,9 +17,18 @@ readonly XYMON_GROUPNAME="xymon"
|
||||||
# By default, don't empty files newer than 10hours (600 minutes)
|
# By default, don't empty files newer than 10hours (600 minutes)
|
||||||
readonly DEFAULT_MTIME_MINUTES="600"
|
readonly DEFAULT_MTIME_MINUTES="600"
|
||||||
|
|
||||||
## Colors {{{
|
# Temp files
|
||||||
readonly PURPLE='\033[1;35m'
|
readonly TEMP_MACO_UPDATE="${XYMONTMP}/${MACHINEDOTS}.${TEST}.maco_update"
|
||||||
## }}}
|
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
# }}}
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
@ -108,30 +117,36 @@ get_maco_update() {
|
||||||
maco_update_script_path="/opt/repos/ipr.scripts/cluster/maco.check.update.sh"
|
maco_update_script_path="/opt/repos/ipr.scripts/cluster/maco.check.update.sh"
|
||||||
maco_update_script_options="--simulate"
|
maco_update_script_options="--simulate"
|
||||||
|
|
||||||
## Run update_script and store result in PLUGIN_RESULT file
|
## Run update_script and store result in TEMP_MACO_UPDATE file
|
||||||
debug_message "get_maco_update − \
|
debug_message "get_maco_update − \
|
||||||
Run \"${maco_update_script_path}\" script with \"${maco_update_script_options}\" options."
|
Run \"${maco_update_script_path}\" script with \"${maco_update_script_options}\" options."
|
||||||
sh "${maco_update_script_path}" "${maco_update_script_options}" >> "${PLUGIN_RESULT}"
|
sh "${maco_update_script_path}" "${maco_update_script_options}" >> "${TEMP_MACO_UPDATE}"
|
||||||
|
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
# Analyze maco result to define colors to send to Xymon {{{
|
# Analyze maco result to define colors to send to Xymon {{{
|
||||||
analyze_maco_status() {
|
analyze_maco_update() {
|
||||||
|
|
||||||
debug_message "analyze_maco_status − \
|
debug_message "analyze_maco_update − \
|
||||||
Try to detect Maco update with ${PLUGIN_RESULT} content."
|
Try to detect Maco update with ${TEMP_MACO_UPDATE} content."
|
||||||
|
|
||||||
if grep -qE '^Local.* up to date.*' "${PLUGIN_RESULT}"
|
if grep -qE '^Local.* up to date.*' "${TEMP_MACO_UPDATE}"
|
||||||
then
|
then
|
||||||
echo "3&green Maco is uptodate" >> "${PLUGIN_STATE}"
|
## Add color and message to PLUGIN_RESULT for detailed informations
|
||||||
elif grep -qE '^Latest.* available.*' "${PLUGIN_RESULT}"
|
sed "s/^/\&${GREEN_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}"
|
||||||
|
## Add information to PLUGIN_STATE
|
||||||
|
echo "3${GREEN_PIC} Maco is uptodate" >> "${PLUGIN_STATE}"
|
||||||
|
elif grep -qE '^Latest.* available.*' "${TEMP_MACO_UPDATE}"
|
||||||
then
|
then
|
||||||
echo "2&yellow Maco needs upgrade" >> "${PLUGIN_STATE}"
|
sed "s/^/\&${YELLOW_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}"
|
||||||
elif grep -qE '^Urgent.* available.*' "${PLUGIN_RESULT}"
|
echo "2${YELLOW_PIC} Maco needs upgrade" >> "${PLUGIN_STATE}"
|
||||||
|
elif grep -qE '^Urgent.* available.*' "${TEMP_MACO_UPDATE}"
|
||||||
then
|
then
|
||||||
echo "1&red Maco needs urgent upgrade" >> "${PLUGIN_STATE}"
|
sed "s/^/\&${RED_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}"
|
||||||
|
echo "1${RED_PIC} Maco needs urgent upgrade" >> "${PLUGIN_STATE}"
|
||||||
else
|
else
|
||||||
echo "4&clear Maco update state is unknown" >> "${PLUGIN_STATE}"
|
sed "s/^/\&${CLEAR_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}"
|
||||||
|
echo "4${CLEAR_PIC} Maco update state is unknown" >> "${PLUGIN_STATE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -148,14 +163,14 @@ send_result_to_xymon_server() {
|
||||||
|
|
||||||
==================== Detailed status ====================
|
==================== Detailed status ====================
|
||||||
|
|
||||||
&${COLOR} $(cat ${PLUGIN_RESULT})"
|
$(cat ${PLUGIN_RESULT})"
|
||||||
|
|
||||||
# For testing only
|
# For testing only
|
||||||
#echo "$XYMON ${XYMSRV} status ${MACHINE}.${TEST} ${COLOR} ${SUBJECT}
|
#echo "$XYMON ${XYMSRV} status ${MACHINE}.${TEST} ${COLOR} ${SUBJECT}
|
||||||
|
|
||||||
#==================== Detailed status ====================
|
#==================== Detailed status ====================
|
||||||
|
|
||||||
#&${COLOR} $(cat ${PLUGIN_RESULT})" > /tmp/xymon.maco.tmp
|
#$(cat ${PLUGIN_RESULT})" > /tmp/xymon.maco.tmp
|
||||||
|
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -174,7 +189,7 @@ main() { # {{{
|
||||||
# If previous state is empty
|
# If previous state is empty
|
||||||
## analyze Maco's result
|
## analyze Maco's result
|
||||||
is_file_empty "${PLUGIN_STATE}" \
|
is_file_empty "${PLUGIN_STATE}" \
|
||||||
&& analyze_maco_status
|
&& analyze_maco_update
|
||||||
|
|
||||||
# Send data to Xymon server
|
# Send data to Xymon server
|
||||||
## and exit
|
## and exit
|
||||||
|
|
Loading…
Reference in New Issue