From c6c1fd2bd00e2db93b7dc12009a57179b4faa9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 13 Jan 2021 15:43:37 +0100 Subject: [PATCH] Manage case if file isn't readable or unknown status --- xymon/plugins/client/ext/maco.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xymon/plugins/client/ext/maco.sh b/xymon/plugins/client/ext/maco.sh index 6844863..f682a40 100755 --- a/xymon/plugins/client/ext/maco.sh +++ b/xymon/plugins/client/ext/maco.sh @@ -216,8 +216,8 @@ No Maco urgent update is planned." # Verify the status of last Maco update check_last_update_status() { - ## Check if Maco status file is present - if [ -f "${MACO_STATUS_FILE}" ]; then + ## Check if Maco status file is present and readable + if [ -r "${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) @@ -239,12 +239,15 @@ Maco status file (${MACO_STATUS_FILE}) exists." 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}" + else + echo "${CLEAR_PIC} Maco last update status is unknown (MacoStatus=${local_maco_status})." >> "${PLUGIN_RESULT}" + echo "42${CLEAR_PIC} Maco last update status is unknown" >> "${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}" + echo "${CLEAR_PIC} Maco last update status is unknown (${MACO_STATUS_FILE} doesn't exists or isn't available)." >> "${PLUGIN_RESULT}" + echo "44${CLEAR_PIC} Maco last update status is unknown" >> "${PLUGIN_STATE}" fi }