diff --git a/xymon/plugins/client/ext/maco.sh b/xymon/plugins/client/ext/maco.sh index 7c09cbf..3ebde14 100755 --- a/xymon/plugins/client/ext/maco.sh +++ b/xymon/plugins/client/ext/maco.sh @@ -17,10 +17,13 @@ readonly XYMON_GROUPNAME="xymon" # By default, don't empty files newer than 10hours (600 minutes) readonly DEFAULT_MTIME_MINUTES="600" +# Maco +readonly MACO_LOCAL_DIR="/opt/maco" +readonly MACO_PENDING_UPDATE_FILE="${MACO_LOCAL_DIR}/.maco.upgrade" + # Temp files readonly TEMP_MACO_UPDATE="${XYMONTMP}/${MACHINEDOTS}.${TEST}.maco_update" - # define colours for graphics {{{ # Comment these out if using older BB versions CLEAR_PIC="&clear" @@ -135,18 +138,38 @@ Try to detect Maco update with ${TEMP_MACO_UPDATE} content." ## Add color and message to PLUGIN_RESULT for detailed informations sed "s/^/\&${GREEN_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}" ## Add information to PLUGIN_STATE - echo "3${GREEN_PIC} Maco is uptodate" >> "${PLUGIN_STATE}" + echo "36${GREEN_PIC} Maco is uptodate" >> "${PLUGIN_STATE}" elif grep -qE '^Latest.* available.*' "${TEMP_MACO_UPDATE}" then sed "s/^/\&${YELLOW_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}" - echo "2${YELLOW_PIC} Maco needs upgrade" >> "${PLUGIN_STATE}" + echo "26${YELLOW_PIC} Maco needs upgrade" >> "${PLUGIN_STATE}" elif grep -qE '^Urgent.* available.*' "${TEMP_MACO_UPDATE}" then sed "s/^/\&${RED_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}" - echo "1${RED_PIC} Maco needs urgent upgrade" >> "${PLUGIN_STATE}" + echo "16${RED_PIC} Maco needs urgent upgrade" >> "${PLUGIN_STATE}" else sed "s/^/\&${CLEAR_PIC} /" "${TEMP_MACO_UPDATE}" >> "${PLUGIN_RESULT}" - echo "4${CLEAR_PIC} Maco update state is unknown" >> "${PLUGIN_STATE}" + echo "46${CLEAR_PIC} Maco update state is unknown" >> "${PLUGIN_STATE}" + fi + +} +# }}} +# Verify if a normal Maco update is planned {{{ +check_pending_update() { + + if [ -f "${MACO_PENDING_UPDATE_FILE}" ]; then + debug_message "check_pending_update − \ +A normal Maco update is planned." + ## Add color and message to PLUGIN_RESULT for detailed informations + echo "${YELLOW_PIC} A normal update is planned (${MACO_PENDING_UPDATE_FILE} file exists)." >> "${PLUGIN_RESULT}" + ## Add information to PLUGIN_STATE + echo "24${YELLOW_PIC} A normal update is planned" >> "${PLUGIN_STATE}" + else + debug_message "check_pending_update − \ +No Maco normal update is planned." + ## Add color and message to PLUGIN_RESULT for detailed informations + echo "${GREEN_PIC} No Maco normal update is planned (${MACO_PENDING_UPDATE_FILE} file doesn't exists)." >> "${PLUGIN_RESULT}" + ## No need to add information to PLUGIN_STATE fi } @@ -187,6 +210,9 @@ main() { # {{{ get_maco_update ## Analyze Maco update result (add color,…) analyze_maco_update + + ## Check for pending update for Maco + check_pending_update fi # Send data to Xymon server