diff --git a/xymon/plugins/client/ext/maco.sh b/xymon/plugins/client/ext/maco.sh index 9027d28..6844863 100755 --- a/xymon/plugins/client/ext/maco.sh +++ b/xymon/plugins/client/ext/maco.sh @@ -21,6 +21,7 @@ readonly DEFAULT_MTIME_MINUTES="600" readonly MACO_LOCAL_DIR="/opt/maco" readonly MACO_PENDING_UPDATE_FILE="${MACO_LOCAL_DIR}/.maco.upgrade" readonly MACO_PENDING_URGENT_UPDATE_FILE="${MACO_LOCAL_DIR}/.maco.urgent.upgrade" +readonly MACO_STATUS_FILE="/var/fr.univ-rennes1.ipr.maco.machinestate.txt" # Temp files readonly TEMP_MACO_UPDATE="${XYMONTMP}/${MACHINEDOTS}.${TEST}.maco_update" @@ -210,6 +211,42 @@ No Maco urgent update is planned." ## No need to add information to PLUGIN_STATE fi +} +# }}} +# Verify the status of last Maco update +check_last_update_status() { + + ## Check if Maco status file is present + if [ -f "${MACO_STATUS_FILE}" ]; then + debug_message "check_last_update_status − \ +Maco status file (${MACO_STATUS_FILE}) exists." + local_maco_status=$(grep --max-count=1 -- MacoStatus "${MACO_STATUS_FILE}" | cut --delimiter="=" --fields=2) + + if [ "${local_maco_status}" = "last-update-succeeded" ]; then + ## Add color and message to PLUGIN_RESULT for detailed informations + echo "${GREEN_PIC} Last Maco update succeed (MacoStatus=${local_maco_status})." >> "${PLUGIN_RESULT}" + ## Add information to PLUGIN_STATE + echo "32${GREEN_PIC} Maco is uptodate and last update succeed" >> "${PLUGIN_STATE}" + + elif [ "${local_maco_status}" = "update-process-running" ]; then + echo "${YELLOW_PIC} Last Maco update is in progress (MacoStatus=${local_maco_status})." >> "${PLUGIN_RESULT}" + echo "22${YELLOW_PIC} Maco update is running" >> "${PLUGIN_STATE}" + + elif [ "${local_maco_status}" = "waiting-for-additional-maco-run" ]; then + echo "${YELLOW_PIC} Last Maco update wait for an extra run (MacoStatus=${local_maco_status})." >> "${PLUGIN_RESULT}" + echo "22${YELLOW_PIC} Maco update needs an extra run" >> "${PLUGIN_STATE}" + + elif [ "${local_maco_status}" = "last-update-failed" ]; then + echo "${RED_PIC} Last Maco update failed (MacoStatus=${local_maco_status})." >> "${PLUGIN_RESULT}" + echo "12${RED_PIC} Maco update failed" >> "${PLUGIN_STATE}" + fi + else + debug_message "check_last_update_status − \ +Maco status file (${MACO_STATUS_FILE}) doesn't exists." + … + echo "42${CLEAR_PIC} Maco last update status is unknow (${MACO_STATUS_FILE} doesn't exists or isn't available)." >> "${PLUGIN_STATE}" + fi + } # }}} # Send plugin results to Xymon server {{{ @@ -253,6 +290,11 @@ main() { # {{{ check_pending_update ## Check for urgent pending update for Maco check_pending_urgent_update + + ## Add HTML header for this part + add_header "Last update" >> "${PLUGIN_RESULT}" + ## Check status of last update + check_last_update_status fi # Send data to Xymon server