* Fix in check_hpux_drd_status()
* Fixed a problem in the --run workflow whereby some log_hc's were not being reported * Added handling of empty lines to fix_logs() and count_log_errors()
This commit is contained in:
@@ -97,8 +97,9 @@ return ${ARCHIVE_RC}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: count_log_errors()
|
||||
# DOES: check hc log file(s) for rogue entries. Log entries may get scrambled
|
||||
# if the append operation in handle_hc() does not happen fully atomically.
|
||||
# DOES: check hc log file(s) for rogue entries (=lines with NF<>$NUM_LOG_FIELDS
|
||||
# or empty lines). Log entries may get scrambled if the append operation
|
||||
# in handle_hc() does not happen fully atomically.
|
||||
# This means that log entries are written without line separator (same line)
|
||||
# There is no proper way to avoid this without an extra file locking utility
|
||||
# EXPECTS: path to log file to check
|
||||
@@ -111,7 +112,14 @@ function count_log_errors
|
||||
typeset LOG_STASH="${1}"
|
||||
typeset ERROR_COUNT=0
|
||||
|
||||
ERROR_COUNT=$(cat ${LOG_STASH} 2>/dev/null | awk -F"${LOG_SEP}" 'BEGIN { num = 0 } { if (NF>'"${NUM_LOG_FIELDS}"') { num++ }} END { print num }' 2>/dev/null)
|
||||
ERROR_COUNT=$(cat ${LOG_STASH} 2>/dev/null | awk -F"${LOG_SEP}" '
|
||||
BEGIN { num = 0 }
|
||||
{
|
||||
if (NF>'"${NUM_LOG_FIELDS}"' || $0 == "") {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
END { print num }' 2>/dev/null)
|
||||
|
||||
print ${ERROR_COUNT}
|
||||
|
||||
@@ -641,6 +649,7 @@ function fix_logs
|
||||
typeset FIX_FILE=""
|
||||
typeset FIX_RC=0
|
||||
typeset LOG_STASH=""
|
||||
typeset EMPTY_COUNT=0
|
||||
typeset ERROR_COUNT=0
|
||||
typeset STASH_COUNT=0
|
||||
typeset TMP_COUNT=0
|
||||
@@ -670,6 +679,9 @@ do
|
||||
# does it have errors?
|
||||
ERROR_COUNT=$(count_log_errors ${FIX_FILE})
|
||||
|
||||
# we count the empty lines (again)
|
||||
EMPTY_COUNT=$(grep -c -E -e '^$' ${FIX_FILE} 2>/dev/null)
|
||||
|
||||
# rewrite if needed
|
||||
if (( ERROR_COUNT > 0 ))
|
||||
then
|
||||
@@ -743,17 +755,21 @@ do
|
||||
}
|
||||
}
|
||||
printf ("\n")
|
||||
} else if ($0 == "") {
|
||||
# skip empty line
|
||||
next;
|
||||
} else {
|
||||
# correct log line, no rewrite needed
|
||||
print $0
|
||||
}
|
||||
}' >${TMP_FILE} 2>/dev/null
|
||||
|
||||
# count after rewrite
|
||||
# count after rewrite (include empty lines again in the count)
|
||||
TMP_COUNT=$(wc -l ${TMP_FILE} 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
||||
TMP_COUNT=$(( TMP_COUNT + EMPTY_COUNT ))
|
||||
|
||||
# bail out when we do not have enough records
|
||||
if (( TMP_COUNT <= STASH_COUNT ))
|
||||
if (( TMP_COUNT < STASH_COUNT ))
|
||||
then
|
||||
warn "found inconsistent record count (${TMP_COUNT}<${STASH_COUNT}), aborting"
|
||||
return 2
|
||||
@@ -1722,12 +1738,15 @@ awk -F"${LOG_SEP}" '{
|
||||
|
||||
END {
|
||||
for (hc in total_count) {
|
||||
printf ("\t%s:\n", hc)
|
||||
printf ("\t\t# entries: %s\n", total_count[hc])
|
||||
printf ("\t\t# STC==0 : %s\n", ok_count[hc])
|
||||
printf ("\t\t# STC<>0 : %s\n", nok_count[hc])
|
||||
printf ("\t\tfirst : %s\n", first_entry[hc])
|
||||
printf ("\t\tlast : %s\n", last_entry[hc])
|
||||
# empty hc variable means count of empty lines in log file
|
||||
if (hc != "") {
|
||||
printf ("\t%s:\n", hc)
|
||||
printf ("\t\t# entries: %s\n", total_count[hc])
|
||||
printf ("\t\t# STC==0 : %s\n", ok_count[hc])
|
||||
printf ("\t\t# STC<>0 : %s\n", nok_count[hc])
|
||||
printf ("\t\tfirst : %s\n", first_entry[hc])
|
||||
printf ("\t\tlast : %s\n", last_entry[hc])
|
||||
}
|
||||
}
|
||||
}
|
||||
' ${HC_LOG} 2>/dev/null
|
||||
@@ -1761,12 +1780,15 @@ do
|
||||
|
||||
END {
|
||||
for (hc in total_count) {
|
||||
printf ("\t%s:\n", hc)
|
||||
printf ("\t\t# entries: %s\n", total_count[hc])
|
||||
printf ("\t\t# STC==0 : %s\n", ok_count[hc])
|
||||
printf ("\t\t# STC<>0 : %s\n", nok_count[hc])
|
||||
printf ("\t\tfirst : %s\n", first_entry[hc])
|
||||
printf ("\t\tlast : %s\n", last_entry[hc])
|
||||
# empty hc variable means count of empty lines in log file
|
||||
if (hc != "") {
|
||||
printf ("\t%s:\n", hc)
|
||||
printf ("\t\t# entries: %s\n", total_count[hc])
|
||||
printf ("\t\t# STC==0 : %s\n", ok_count[hc])
|
||||
printf ("\t\t# STC<>0 : %s\n", nok_count[hc])
|
||||
printf ("\t\tfirst : %s\n", first_entry[hc])
|
||||
printf ("\t\tlast : %s\n", last_entry[hc])
|
||||
}
|
||||
}
|
||||
}
|
||||
' ${_ARCHIVE_FILE} 2>/dev/null
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# @(#) 2018-10-18: changed boot status [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-10-31: better result check for DRD output [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@@ -38,7 +39,7 @@ function check_hpux_drd_status
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _DRD_BIN="/opt/drd/bin/drd"
|
||||
typeset _VERSION="2018-10-28" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-10-31" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@@ -120,13 +121,15 @@ else
|
||||
# drd outputs on STDERR
|
||||
${_DRD_BIN} status >${HC_STDOUT_LOG} 2>&1
|
||||
_RC=$?
|
||||
# check for result in output since _RC is not reliable
|
||||
grep -q -E -e "succeeded" ${HC_STDOUT_LOG} 2>/dev/null || _RC=1
|
||||
fi
|
||||
|
||||
# check drd status
|
||||
if (( _RC == 0 )) && (( $(grep -c -E -e ".*Information succeeded.*" ${HC_STDOUT_LOG} 2>/dev/null) > 0 ))
|
||||
if (( _RC == 0 ))
|
||||
then
|
||||
# convert NOW to epoch (pass date values as unquoted parameters)
|
||||
_NOW_EPOCH=$(data_date2epoch "$(date '+%Y')" "$(date '+%m')" "$(date '+%d')" "$(date '+%H')" "$(date '+%M')" "$(date '+%S')")
|
||||
# convert NOW to epoch (pass date values as quoted parameters)
|
||||
_NOW_EPOCH=$(data_date2epoch "$(date '+%Y' 2>/dev/null)" "$(date '+%m' 2>/dev/null)" "$(date '+%d' 2>/dev/null)" "$(date '+%H' 2>/dev/null)" "$(date '+%M' 2>/dev/null)" "$(date '+%S' 2>/dev/null)")
|
||||
|
||||
# get devices
|
||||
_ORIGINAL_DISK=$(data_strip_space "$(grep "Original Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
|
||||
|
||||
Reference in New Issue
Block a user