From f891b1bfea4490d2fbec1ba0f799f22d65ba5685 Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Sun, 19 May 2019 09:03:57 +0200 Subject: [PATCH] Import bug fix which obsoletes --fix-logs --- opt/hc/bin/check_health.sh | 2 +- opt/hc/lib/core/include_core.sh | 24 +++++++++++++++--------- opt/hc/lib/core/report_std.sh | 4 +++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/opt/hc/bin/check_health.sh b/opt/hc/bin/check_health.sh index a4086bd..cc7393f 100755 --- a/opt/hc/bin/check_health.sh +++ b/opt/hc/bin/check_health.sh @@ -38,7 +38,7 @@ # ------------------------- CONFIGURATION starts here ------------------------- # define the version (YYYY-MM-DD) -typeset -r SCRIPT_VERSION="2019-05-14" +typeset -r SCRIPT_VERSION="2019-05-19" # location of parent directory containing KSH functions/HC plugins typeset -r FPATH_PARENT="/opt/hc/lib" # location of custom HC configuration files diff --git a/opt/hc/lib/core/include_core.sh b/opt/hc/lib/core/include_core.sh index 68e92c5..b82da69 100755 --- a/opt/hc/lib/core/include_core.sh +++ b/opt/hc/lib/core/include_core.sh @@ -30,7 +30,7 @@ # RETURNS: 0 function version_include_core { -typeset _VERSION="2019-04-03" # YYYY-MM-DD +typeset _VERSION="2019-05-19" # YYYY-MM-DD print "INFO: $0: ${_VERSION#version_*}" @@ -62,7 +62,7 @@ typeset TMP2_FILE="${TMP_DIR}/.$0.tmp2.archive.$$" # shellcheck disable=SC2064 trap "rm -f ${TMP1_FILE} ${TMP2_FILE} ${SAVE_LOG_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 -# get pre-archive log co +# get pre-archive log count PRE_LOG_COUNT=$(wc -l ${HC_LOG} 2>/dev/null | cut -f1 -d' ' 2>/dev/null) if (( PRE_LOG_COUNT == 0 )) then @@ -1129,15 +1129,16 @@ then ONE_MSG_EXP_VAL=$(data_magic_unquote "${ONE_MSG_EXP_VAL}") fi fi - printf "%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}" \ - "${ONE_MSG_TIME}" \ - "${HC_NAME}" \ - ${ONE_MSG_STC} \ - "${ONE_MSG_TEXT}" >>${HC_LOG} if (( ONE_MSG_STC > 0 )) then + # do atomic log update # shellcheck disable=SC1117 - printf "%s${LOG_SEP}\n" "${HC_FAIL_ID}" >>${HC_LOG} + printf "%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}\n" \ + "${ONE_MSG_TIME}" \ + "${HC_NAME}" \ + ${ONE_MSG_STC} \ + "${ONE_MSG_TEXT}" \ + "${HC_FAIL_ID}" >>${HC_LOG} # RC handling (max/sum/count) if (( ARG_FLIP_RC > 0 )) then @@ -1157,8 +1158,13 @@ then HC_STC_RC=$(( HC_STC_RC + 1 )) fi else + # do atomic log update # shellcheck disable=SC1117 - printf "\n" >>${HC_LOG} + printf "%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}\n" \ + "${ONE_MSG_TIME}" \ + "${HC_NAME}" \ + ${ONE_MSG_STC} \ + "${ONE_MSG_TEXT}" >>${HC_LOG} fi done diff --git a/opt/hc/lib/core/report_std.sh b/opt/hc/lib/core/report_std.sh index d7289b6..b020a01 100755 --- a/opt/hc/lib/core/report_std.sh +++ b/opt/hc/lib/core/report_std.sh @@ -30,7 +30,7 @@ function report_std { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2019-03-16" # YYYY-MM-DD +typeset _VERSION="2019-05-19" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -327,6 +327,8 @@ else fi # check consistency of log(s) +# note: should no longer be necessary as of release 19/05/2019 but we keep the +# check alive for now # shellcheck disable=SC2086 find ${_LOG_STASH} -type f -print 2>/dev/null | while read -r _CHECK_FILE do