From f27d7aa07b78ec9dbe75ba62e12545fb52f128f9 Mon Sep 17 00:00:00 2001 From: patvdv Date: Sat, 27 Oct 2018 22:16:08 +0200 Subject: [PATCH] Fixed (linter) issues --- sources/bin/check_health.sh | 45 +++++++++++-- sources/lib/core/display_csv.sh | 10 +-- sources/lib/core/display_init.sh | 10 ++- sources/lib/core/display_json.sh | 12 ++-- sources/lib/core/display_terse.sh | 12 ++-- sources/lib/core/display_zenoss.sh | 12 ++-- sources/lib/core/include_core.sh | 31 +++++---- sources/lib/core/include_data.sh | 66 +++++++++---------- sources/lib/core/include_os.sh | 1 + sources/lib/core/notify_eif.sh | 8 +-- sources/lib/core/notify_mail.sh | 19 ++++-- sources/lib/core/notify_sms.sh | 12 ++-- sources/lib/core/report_std.sh | 8 ++- sources/lib/platform/aix/check_aix_errpt.sh | 12 ++-- .../lib/platform/aix/check_aix_file_age.sh | 35 +++++----- .../lib/platform/aix/check_aix_file_change.sh | 21 +++--- .../platform/hp-ux/check_hpux_drd_status.sh | 7 +- .../lib/platform/hp-ux/check_hpux_file_age.sh | 9 +-- .../platform/hp-ux/check_hpux_file_change.sh | 21 +++--- .../hp-ux/check_hpux_fs_mounts_options.sh | 6 +- .../platform/hp-ux/check_hpux_guid_status.sh | 7 +- .../hp-ux/check_hpux_hpvm_vpar_status.sh | 51 +++++++------- .../platform/hp-ux/check_hpux_httpd_status.sh | 7 +- .../hp-ux/check_hpux_ignite_backup.sh | 23 ++++++- .../lib/platform/hp-ux/check_hpux_ioscan.sh | 25 +++---- .../hp-ux/check_hpux_kernel_params.sh | 8 +-- .../platform/hp-ux/check_hpux_kernel_usage.sh | 16 ++--- .../lib/platform/hp-ux/check_hpux_lunpaths.sh | 7 +- .../platform/hp-ux/check_hpux_named_status.sh | 4 +- .../platform/hp-ux/check_hpux_ntp_status.sh | 21 +++--- .../platform/hp-ux/check_hpux_ovpa_status.sh | 5 +- .../hp-ux/check_hpux_patch_version.sh | 6 +- .../hp-ux/check_hpux_sg_cluster_config.sh | 8 +-- .../hp-ux/check_hpux_sg_cluster_status.sh | 4 +- .../hp-ux/check_hpux_sg_package_config.sh | 8 +-- .../hp-ux/check_hpux_sg_package_status.sh | 4 +- .../platform/hp-ux/check_hpux_sg_qs_status.sh | 8 +-- .../platform/hp-ux/check_hpux_sshd_status.sh | 7 +- .../lib/platform/hp-ux/check_hpux_syslog.sh | 8 +-- .../platform/linux/check_linux_burp_backup.sh | 5 +- .../platform/linux/check_linux_file_age.sh | 37 ++++++----- .../platform/linux/check_linux_file_change.sh | 21 +++--- .../platform/linux/check_linux_hpacucli.sh | 9 ++- .../platform/linux/check_linux_hpasmcli.sh | 9 ++- .../lib/platform/linux/check_linux_hplog.sh | 9 ++- .../platform/linux/check_linux_hpssacli.sh | 9 ++- .../platform/linux/check_linux_ntp_status.sh | 28 +++++--- .../linux/check_linux_process_limits.sh | 19 +++--- .../linux/check_linux_sg_cluster_config.sh | 8 +-- .../linux/check_linux_sg_cluster_status.sh | 16 ++--- .../linux/check_linux_sg_package_config.sh | 8 +-- .../linux/check_linux_sg_package_status.sh | 18 ++--- .../linux/check_linux_sg_qs_status.sh | 7 +- .../linux/check_linux_vz_ct_status.sh | 47 ++++++------- 54 files changed, 458 insertions(+), 376 deletions(-) diff --git a/sources/bin/check_health.sh b/sources/bin/check_health.sh index 98ee1a4..9e27966 100644 --- a/sources/bin/check_health.sh +++ b/sources/bin/check_health.sh @@ -37,7 +37,7 @@ # ------------------------- CONFIGURATION starts here ------------------------- # define the version (YYYY-MM-DD) -typeset -r SCRIPT_VERSION="2018-07-12" +typeset -r SCRIPT_VERSION="2018-10-28" # location of parent directory containing KSH functions/HC plugins typeset -r FPATH_PARENT="/opt/hc/lib" # location of custom HC configuration files @@ -54,13 +54,18 @@ typeset -r EXEC_USER="root" # read-only settings (but should not be changed) typeset -r SCRIPT_NAME="$(basename $0)" typeset -r SCRIPT_DIR="$(dirname $0)" +# shellcheck disable=SC2034 typeset -r HOST_NAME="$(hostname)" typeset -r OS_NAME="$(uname -s)" typeset -r LOCK_DIR="${TMP_DIR}/.${SCRIPT_NAME}.lock" typeset -r HC_MSG_FILE="${TMP_DIR}/.${SCRIPT_NAME}.hc.msg.$$" # plugin messages files +# shellcheck disable=SC2034 typeset -r LOG_SEP="|" # single character only +# shellcheck disable=SC2034 typeset -r MSG_SEP="%" # single character only +# shellcheck disable=SC2034 typeset -t NUM_LOG_FIELDS=6 # current number of fields in $HC_LOG + 1 +# shellcheck disable=SC2034 typeset -r MAGIC_QUOTE="!_!" # magic quote typeset -r LOG_DIR="/var/opt/hc" typeset -r LOG_FILE="${LOG_DIR}/${SCRIPT_NAME}.log" @@ -74,28 +79,35 @@ typeset PATH=${PATH}:/sbin:/usr/bin:/usr/sbin:/usr/local/bin typeset CMD_LINE="" typeset CMD_PARAMETER="" typeset CHILD_ERROR=0 +# shellcheck disable=SC2034 typeset DIR_PREFIX="$(date '+%Y-%m')" typeset EXIT_CODE=0 typeset FDIR="" typeset FFILE="" typeset FPATH="" typeset HC_FAIL_ID="" +# shellcheck disable=SC2034 typeset HC_FILE_LINE="" typeset HC_NOW="" typeset HC_TIME_OUT=60 typeset HC_MIN_TIME_OUT=30 +# shellcheck disable=SC2034 typeset HC_MSG_VAR="" typeset HC_STDOUT_LOG="" typeset HC_STDERR_LOG="" +# shellcheck disable=SC2034 typeset LINUX_DISTRO="" +# shellcheck disable=SC2034 typeset LINUX_RELEASE="" typeset ARCHIVE_RC=0 typeset DISABLE_RC=0 typeset ENABLE_RC=0 +# shellcheck disable=SC2034 typeset FIX_FC=0 typeset RUN_RC=0 typeset RUN_CONFIG_FILE="" typeset RUN_TIME_OUT=0 +# shellcheck disable=SC2034 typeset SORT_CMD="" typeset DEBUG_OPTS="" # command-line parameters @@ -217,7 +229,7 @@ function check_core # check and include core helper libs if [[ -r ${FPATH_PARENT}/core/include_core.sh && -h ${FPATH_PARENT}/core/include_core ]] then - # source /opt/hc/lib/core/include_core.sh + # shellcheck source=/opt/hc/lib/core/include_core.sh . ${FPATH_PARENT}/core/include_core.sh else print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_core.sh is not present (tip: run --fix-symlinks)" @@ -225,7 +237,7 @@ else fi if [[ -r ${FPATH_PARENT}/core/include_data.sh && -h ${FPATH_PARENT}/core/include_data ]] then - # source /opt/hc/lib/core/include_data.sh + # shellcheck source=/opt/hc/lib/core/include_data.sh . ${FPATH_PARENT}/core/include_data.sh else print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_data.sh is not present (tip: run --fix-symlinks)" @@ -233,7 +245,7 @@ else fi if [[ -r ${FPATH_PARENT}/core/include_os.sh && -h ${FPATH_PARENT}/core/include_os ]] then - # source /opt/hc/lib/core/include_os.sh + # shellcheck source=/opt/hc/lib/core/include_os.sh . ${FPATH_PARENT}/core/include_os.sh else print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_os.sh is not present (tip: run --fix-symlinks)" @@ -468,6 +480,7 @@ function check_user typeset WHOAMI="" # avoid sub-shell for mksh/pdksh +# shellcheck disable=SC2046 WHOAMI=$(IFS='()'; set -- $(id); print $2) if [[ "${WHOAMI}" != "${EXEC_USER}" ]] then @@ -493,6 +506,7 @@ case "${KSH_VERSION}" in *) if [[ -z "${ERRNO}" ]] then + # shellcheck disable=SC2154 (( ARG_DEBUG != 0 )) && print "running ksh: ${.sh.version}" else (( ARG_DEBUG != 0 )) && print "running ksh: ksh88 or older" @@ -648,6 +662,7 @@ done print "${FPATH}" | tr ':' '\n' | while read -r FDIR do # do not use 'find -type l' here! + # shellcheck disable=SC2010 ls ${FDIR} 2>/dev/null | grep -v "\." | while read -r FSYML do # check if file is a dead symlink @@ -672,7 +687,6 @@ return 0 function read_config { (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" -typeset SMS_CONFIG_FILE="" if [[ -z "${CONFIG_FILE}" ]] || [[ -z "${CONFIG_FILE}" ]] then @@ -682,6 +696,7 @@ if [[ ! -r "${CONFIG_FILE}" ]] then die "unable to read configuration file at ${CONFIG_FILE}" else + # shellcheck source=/dev/null . "${CONFIG_FILE}" fi @@ -741,6 +756,7 @@ do ARG_DEBUG_LEVEL="${CMD_PARAMETER#--debug-level=}" ;; -detail|--detail) + # shellcheck disable=SC2034 ARG_DETAIL=1 ;; -d|-disable|--disable) @@ -769,6 +785,7 @@ do ARG_DISPLAY="${CMD_PARAMETER#-display=}" ;; --display=*) + # shellcheck disable=SC2034 ARG_DISPLAY="${CMD_PARAMETER#--display=}" ;; -e|-enable|--enable) @@ -824,15 +841,19 @@ do ARG_HC_ARGS="${CMD_PARAMETER#--hc-args=}" ;; -with-history|--with-history) + # shellcheck disable=SC2034 ARG_HISTORY=1 ;; -id=*) + # shellcheck disable=SC2034 ARG_FAIL_ID="${CMD_PARAMETER#-id=}" ;; --id=*) + # shellcheck disable=SC2034 ARG_FAIL_ID="${CMD_PARAMETER#--id=}" ;; -last|--last) + # shellcheck disable=SC2034 ARG_LAST=1 ;; -list|--list) @@ -885,12 +906,14 @@ do ARG_MAIL_TO="${CMD_PARAMETER#-mail-to=}" ;; --mail-to=*) + # shellcheck disable=SC2034 ARG_MAIL_TO="${CMD_PARAMETER#--mail-to=}" ;; -notify=*) ARG_NOTIFY="${CMD_PARAMETER#-notify=}" ;; --notify=*) + # shellcheck disable=SC2034 ARG_NOTIFY="${CMD_PARAMETER#--notify=}" ;; -no-log|--no-log) @@ -933,10 +956,12 @@ do else ARG_ACTION=8 fi + # shellcheck disable=SC2034 ARG_REPORT="${CMD_PARAMETER#--report=}" ARG_LOG=0; ARG_VERBOSE=0 ;; -reverse|--reverse) + # shellcheck disable=SC2034 ARG_REVERSE=1 ;; -r|-run|--run) @@ -956,7 +981,9 @@ do else ARG_ACTION=5 fi - ARG_LOG=0; ARG_VERBOSE=0 + ARG_LOG=0 + # shellcheck disable=SC2034 + ARG_VERBOSE=0 ;; -show-stats|--show-stats) if (( ARG_ACTION > 0 )) @@ -971,12 +998,14 @@ do ARG_SMS_PROVIDER="${CMD_PARAMETER#-sms-provider=}" ;; --sms-provider=*) + # shellcheck disable=SC2034 ARG_SMS_PROVIDER="${CMD_PARAMETER#--sms-provider=}" ;; -sms-to=*) ARG_SMS_TO="${CMD_PARAMETER#-sms-to=}" ;; --sms-to=*) + # shellcheck disable=SC2034 ARG_SMS_TO="${CMD_PARAMETER#--sms-to=}" ;; -timeout=*) @@ -986,6 +1015,7 @@ do ARG_TIME_OUT="${CMD_PARAMETER#--timeout=}" ;; -today|--today) + # shellcheck disable=SC2034 ARG_TODAY=1 ;; -v|-version|--version) @@ -1047,6 +1077,7 @@ log "*** start of ${SCRIPT_NAME} [${CMD_LINE}] ***" (( ARG_ACTION == 4 || ARG_ACTION == 11 || ARG_ACTION == 12 )) && check_lock_dir # general HC log +# shellcheck disable=SC2034 HC_LOG="${LOG_DIR}/hc.log" # get linux stuff @@ -1152,7 +1183,9 @@ case ${ARG_ACTION} in # set & initialize STDOUT/STDERR locations (not in init_hc()!) HC_STDOUT_LOG="${TMP_DIR}/${HC_RUN}.stdout.log.$$" HC_STDERR_LOG="${TMP_DIR}/${HC_RUN}.stderr.log.$$" + # shellcheck disable=SC2188 >${HC_STDOUT_LOG} 2>/dev/null + # shellcheck disable=SC2188 >${HC_STDERR_LOG} 2>/dev/null # --check-host handling: alternative configuration file, mangle ARG_CONFIG_FILE & HC_TIME_OUT diff --git a/sources/lib/core/display_csv.sh b/sources/lib/core/display_csv.sh index 9e59aa6..6c04809 100644 --- a/sources/lib/core/display_csv.sh +++ b/sources/lib/core/display_csv.sh @@ -30,7 +30,7 @@ function display_csv { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match typeset _DISPLAY_SEP=";" # ------------------------- CONFIGURATION ends here --------------------------- @@ -42,11 +42,10 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" typeset _DISPLAY_FAIL_ID="$2" -typeset _HC_MSG_ENTRY="" typeset _DISPLAY_MSG_STC="" typeset _DISPLAY_MSG_TIME="" typeset _DISPLAY_MSG_TEXT="" -typeset _DISPLAY_MSG_CUR_VAL="" +typeset _DISPLAY_MSG_CUR_VAL="" typeset _DISPLAY_MSG_EXP_VAL="" typeset _ID_BIT="" @@ -56,6 +55,7 @@ then printf "%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s\n" "Health Check" "STC" "Message" "FAIL ID" \ "Current Value" "Expected Value" + # shellcheck disable=SC2034 print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _DISPLAY_MSG_STC _DISPLAY_MSG_TIME _DISPLAY_MSG_TEXT _DISPLAY_MSG_CUR_VAL _DISPLAY_MSG_EXP_VAL do # magically unquote if needed @@ -82,8 +82,8 @@ then then _DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}") fi - fi - if (( _DISPLAY_MSG_STC > 0 )) + fi + if (( _DISPLAY_MSG_STC > 0 )) then _ID_BIT="${_DISPLAY_FAIL_ID}" else diff --git a/sources/lib/core/display_init.sh b/sources/lib/core/display_init.sh index 5a8f8c8..b63c363 100644 --- a/sources/lib/core/display_init.sh +++ b/sources/lib/core/display_init.sh @@ -31,7 +31,7 @@ function display_init { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-05-14" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -59,7 +59,6 @@ then typeset _BLUE=$(tput setaf 4) typeset _MAGENTA=$(tput setaf 5) typeset _CYAN=$(tput setaf 6) - typeset _WHITE=$(tput setaf 7) typeset _BOLD=$(tput bold) typeset _NORMAL=$(tput sgr0) else @@ -69,7 +68,6 @@ else typeset _BLUE="" typeset _MAGENTA="" typeset _CYAN="" - typeset _WHITE="" typeset _BOLD="" typeset _NORMAL="" fi @@ -98,9 +96,9 @@ else print "${HC_MSG_VAR}" | while read _HC_MSG_ENTRY do # determine _DISPLAY_MSG_STC (sum of all STCs) - _DISPLAY_MSG_STC=$(print "${HC_MSG_VAR}" | awk -F"${MSG_SEP}" 'BEGIN { stc = 0 } { for (i=1;i<=NF;i++) { stc = stc + $1 } } END { print stc }' 2>/dev/null) + _DISPLAY_MSG_STC=$(print "${_HC_MSG_ENTRY}" | awk -F"${MSG_SEP}" 'BEGIN { stc = 0 } { for (i=1;i<=NF;i++) { stc = stc + $1 } } END { print stc }' 2>/dev/null) done - + # display HC results if (( _DISPLAY_MSG_STC == 0 )) then @@ -114,7 +112,7 @@ else then _DISPLAY_ID=" (${_BOLD}${_DISPLAY_FAIL_ID}${_NORMAL})" else - _DISPLAY_ID=" (${_BOLD}not logged${_NORMAL})" + _DISPLAY_ID=" (${_BOLD}not logged${_NORMAL})" fi fi else diff --git a/sources/lib/core/display_json.sh b/sources/lib/core/display_json.sh index 0a65f6c..c928408 100644 --- a/sources/lib/core/display_json.sh +++ b/sources/lib/core/display_json.sh @@ -30,9 +30,8 @@ function display_json { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match -typeset _DISPLAY_SEP=";" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults @@ -42,11 +41,10 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" typeset _DISPLAY_FAIL_ID="$2" -typeset _HC_MSG_ENTRY="" typeset _DISPLAY_MSG_STC="" typeset _DISPLAY_MSG_TIME="" typeset _DISPLAY_MSG_TEXT="" -typeset _DISPLAY_MSG_CUR_VAL="" +typeset _DISPLAY_MSG_CUR_VAL="" typeset _DISPLAY_MSG_EXP_VAL="" typeset _ID_BIT="" @@ -79,8 +77,8 @@ then then _DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}") fi - fi - if (( _DISPLAY_MSG_STC > 0 )) + fi + if (( _DISPLAY_MSG_STC > 0 )) then _ID_BIT="${_DISPLAY_FAIL_ID}" else @@ -90,7 +88,7 @@ then _DISPLAY_MSG_TEXT=$(data_escape_json "${_DISPLAY_MSG_TEXT}") _DISPLAY_MSG_CUR_VAL=$(data_escape_json "${_DISPLAY_MSG_CUR_VAL}") _DISPLAY_MSG_EXP_VAL=$(data_escape_json "${_DISPLAY_MSG_EXP_VAL}") - + printf '{"hc":"%s","stc":"%s","time":"%s","fail_id":"%s","text":"%s","current_value":"%s","expected_value":"%s"}\n' \ "${_DISPLAY_HC}" \ diff --git a/sources/lib/core/display_terse.sh b/sources/lib/core/display_terse.sh index 75b967e..c88196c 100644 --- a/sources/lib/core/display_terse.sh +++ b/sources/lib/core/display_terse.sh @@ -41,11 +41,10 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" typeset _DISPLAY_FAIL_ID="$2" -typeset _HC_MSG_ENTRY="" typeset _DISPLAY_MSG_STC="" typeset _DISPLAY_MSG_TIME="" typeset _DISPLAY_MSG_TEXT="" -typeset _DISPLAY_MSG_CUR_VAL="" +typeset _DISPLAY_MSG_CUR_VAL="" typeset _DISPLAY_MSG_EXP_VAL="" typeset _ID_BIT="" @@ -54,6 +53,7 @@ if [[ -n "${HC_MSG_VAR}" ]] then printf "%-30s\t%s\t%-16s\t%s\n" "HC" "STC" "FAIL ID" "Message" + # shellcheck disable=SC2034 print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _DISPLAY_MSG_STC _DISPLAY_MSG_TIME _DISPLAY_MSG_TEXT _DISPLAY_MSG_CUR_VAL _DISPLAY_MSG_EXP_VAL do # magically unquote if needed @@ -80,8 +80,8 @@ then then _DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}") fi - fi - if (( _DISPLAY_MSG_STC > 0 )) + fi + if (( _DISPLAY_MSG_STC > 0 )) then _ID_BIT="${_DISPLAY_FAIL_ID}" else @@ -91,8 +91,8 @@ then "${_DISPLAY_HC}" \ "${_DISPLAY_MSG_STC}" \ "${_ID_BIT}" \ - "${_DISPLAY_MSG_TEXT}" - done + "${_DISPLAY_MSG_TEXT}" + done else ARG_LOG=0 ARG_VERBOSE=1 log "INFO: no HC results to display" fi diff --git a/sources/lib/core/display_zenoss.sh b/sources/lib/core/display_zenoss.sh index da11aa2..1af688e 100644 --- a/sources/lib/core/display_zenoss.sh +++ b/sources/lib/core/display_zenoss.sh @@ -32,7 +32,7 @@ function display_zenoss { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -43,16 +43,16 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" typeset _DISPLAY_FAIL_ID="$2" -typeset _HC_MSG_ENTRY="" typeset _DISPLAY_MSG_STC="" typeset _DISPLAY_MSG_TIME="" typeset _DISPLAY_MSG_TEXT="" -typeset _DISPLAY_MSG_CUR_VAL="" +typeset _DISPLAY_MSG_CUR_VAL="" typeset _DISPLAY_MSG_EXP_VAL="" # parse $HC_MSG_VAR if [[ -n "${HC_MSG_VAR}" ]] then + # shellcheck disable=SC2034 print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _DISPLAY_MSG_STC _DISPLAY_MSG_TIME _DISPLAY_MSG_TEXT _DISPLAY_MSG_CUR_VAL _DISPLAY_MSG_EXP_VAL do # magically unquote if needed @@ -79,8 +79,8 @@ then then _DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}") fi - fi - if (( _DISPLAY_MSG_STC > 0 )) + fi + if (( _DISPLAY_MSG_STC > 0 )) then printf "NOK|data1=%s data2=%s data3=%s data4=\"%s\" data5=%s data6=%s\n" \ "${_DISPLAY_HC}" \ @@ -97,7 +97,7 @@ then "${_DISPLAY_MSG_TEXT}" \ "${_DISPLAY_MSG_CUR_VAL}" \ "${_DISPLAY_MSG_EXP_VAL}" - fi + fi done fi diff --git a/sources/lib/core/include_core.sh b/sources/lib/core/include_core.sh index fc3e42e..e981eb6 100644 --- a/sources/lib/core/include_core.sh +++ b/sources/lib/core/include_core.sh @@ -153,6 +153,7 @@ then then print - "$*" | while read -r LOG_LINE do + # shellcheck disable=SC2153 print "${NOW}: ERROR: [$$]:" "${LOG_LINE}" >>${LOG_FILE} done fi @@ -220,6 +221,7 @@ HAS_REPORT_STD=0 # check which core display/notification plugins are installed # do not use a while-do loop here because mksh/pdksh does not pass updated # variables back from the sub shell (only works for true ksh88/ksh93) +# shellcheck disable=SC2010 for FFILE in $(ls -1 ${FPATH_PARENT}/core/*.sh 2>/dev/null | grep -v "include_" 2>/dev/null) do case "${FFILE}" in @@ -593,7 +595,7 @@ typeset EXISTS_RC=0 # variables back from the sub shell (only works for true ksh88/ksh93) for FDIR in $(print "${FPATH}" | tr ':' ' ' 2>/dev/null) do - $(data_contains_string "${FDIR}" "core") + data_contains_string "${FDIR}" "core" if (( $? == 0 )) then ls "${FDIR}/${EXISTS_HC}" >/dev/null 2>&1 && EXISTS_RC=1 @@ -613,7 +615,6 @@ function find_hc { (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset FIND_HC="${1}" -typeset FIND_PATH="" typeset FDIR="" print "${FPATH}" | tr ':' '\n' | grep -v "core$" | while read -r FDIR @@ -670,6 +671,7 @@ do # rewrite if needed if (( ERROR_COUNT > 0 )) then + # shellcheck disable=SC2188 >${TMP_FILE} 2>/dev/null cat ${FIX_FILE} 2>/dev/null | awk -F"${LOG_SEP}" -v OFS="${LOG_SEP}" ' @@ -797,7 +799,6 @@ function handle_hc typeset HC_NAME="${1}" typeset HC_STDOUT_LOG_SHORT="" typeset HC_STDERR_LOG_SHORT="" -typeset HC_MSG_ENTRY="" typeset HC_STC_RC=0 typeset ONE_MSG_STC=0 typeset ONE_MSG_TIME="" @@ -823,7 +824,7 @@ then # determine ALL_MSG_STC (sum of all STCs) ALL_MSG_STC=$(print "${HC_MSG_VAR}" | awk -F"${MSG_SEP}" 'BEGIN { stc = 0 } { for (i=1;i<=NF;i++) { stc = stc + $1 }} END { print stc }' 2>/dev/null) (( ARG_DEBUG != 0 )) && debug "HC all STC: ${ALL_MSG_STC}" - $(data_is_numeric ${ALL_MSG_STC}) || die "HC all STC computes to a non-numeric value" + data_is_numeric ${ALL_MSG_STC} || die "HC all STC computes to a non-numeric value" else # nothing to do return 0 @@ -1128,6 +1129,7 @@ function handle_timeout (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" [[ -n "${CHILD_PID}" ]] && kill -s TERM ${CHILD_PID} warn "child process with PID ${CHILD_PID} has been forcefully stopped" +# shellcheck disable=SC2034 CHILD_ERROR=1 return 0 @@ -1142,9 +1144,6 @@ return 0 function init_check_host { (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" -typeset DUMMY="" -typeset HC_CONFIG="" -typeset HC_DESC="" typeset HC_EXEC="" typeset DISPLAY_STYLE="" @@ -1152,7 +1151,7 @@ typeset DISPLAY_STYLE="" # read required config values DISPLAY_STYLE=$(_CONFIG_FILE="${HOST_CONFIG_FILE}" data_get_lvalue_from_config 'display_style') -case "${REPORT_STYLE}" in +case "${DISPLAY_STYLE}" in csv|CSV) # csv format if (( HAS_DISPLAY_CSV == 1 )) then @@ -1258,7 +1257,7 @@ esac # mangle $ARG_HC to build the full list of HCs to be executed ARG_HC="" grep -i '^hc:' ${HOST_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read DUMMY HC_EXEC HC_CONFIG HC_DESC + while IFS=':' read _ HC_EXEC _ _ do ARG_HC="${ARG_HC},${HC_EXEC}" done @@ -1359,11 +1358,13 @@ typeset HC_VERSION="" if [[ "${FACTION}" != "list" ]] then printf "%-30s\t%-8s\t%s\t\t%s\n" "Core plugin" "State" "Version" "Config?" + # shellcheck disable=SC2183 printf "%80s\n" | tr ' ' - fi print "${FPATH}" | tr ':' '\n' | grep "core$" | sort 2>/dev/null | while read -r FDIR do # exclude core helper librar(y|ies) + # shellcheck disable=SC2010 ls -1 ${FDIR}/*.sh 2>/dev/null | grep -v "include_" | sort 2>/dev/null | while read -r FFILE do # reset state @@ -1405,6 +1406,7 @@ then print "${FPATH}" | tr ':' '\n' | grep "core$" | while read -r FDIR do # do not use 'find -type l' here! + # shellcheck disable=SC2010 ls ${FDIR} 2>/dev/null | grep -v "\." | while read -r FFILE do if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]] @@ -1460,6 +1462,7 @@ fi if [[ "${FACTION}" != "list" ]] then printf "%-30s\t%-8s\t%s\t\t%s\t%s\t%s\n" "Health Check" "State" "Version" "Config?" "Sched?" "H+?" + # shellcheck disable=SC2183 printf "%100s\n" | tr ' ' - fi print "${FPATH}" | tr ':' '\n' | grep -v "core$" | sort 2>/dev/null | while read -r FDIR @@ -1492,8 +1495,8 @@ do ;; esac else - FHEALTHY="N/S" - fi + FHEALTHY="N/S" + fi # *.conf next if [[ -r ${CONFIG_DIR}/${FNAME#function *}.conf ]] then @@ -1509,7 +1512,7 @@ do *) FHEALTHY="N/S" ;; - esac + esac fi # check for log_healthy support through --hc-args (plugin) elif (( $(grep -c -E -e "_LOG_HEALTHY" "${FFILE}" 2>/dev/null) > 0 )) @@ -1562,6 +1565,7 @@ then print "${FPATH}" | tr ':' '\n' | grep -v "core" | while read -r FDIR do # do not use 'find -type l' here! + # shellcheck disable=SC2010 ls ${FDIR} 2>/dev/null | grep -v "\." | while read -r FFILE do if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]] @@ -1635,7 +1639,6 @@ function log_hc (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset HC_NAME="${1}" typeset HC_STC=${2} -typeset HC_MSG="${3}" typeset HC_NOW="$(date '+%Y-%m-%d %H:%M:%S' 2>/dev/null)" typeset HC_MSG_CUR_VAL="" typeset HC_MSG_EXP_VAL="" @@ -1823,4 +1826,4 @@ return 0 #****************************************************************************** # END of script -#****************************************************************************** \ No newline at end of file +#****************************************************************************** diff --git a/sources/lib/core/include_data.sh b/sources/lib/core/include_data.sh index cde10ac..46240cb 100644 --- a/sources/lib/core/include_data.sh +++ b/sources/lib/core/include_data.sh @@ -41,7 +41,7 @@ _LVALUE=$(grep -i "^${_PARAMETER} *=" ${_CONFIG_FILE} | cut -f2- -d'=') if [[ -n "${_LVALUE}" ]] then - print $(data_dequote "${_LVALUE}") + print "$(data_dequote \"${_LVALUE}\")" else _RC=1 fi @@ -88,7 +88,7 @@ return ${_RC} # ----------------------------------------------------------------------------- # @(#) FUNCTION: data_magic_quote() # DOES: magically quotes a needle in a string (default needle is: %) -# EXPECTS: to be magically quoted [string]; $2=needle [string] +# EXPECTS: to be magically quoted [string]; $2=needle [string] # OUTPUTS: magically quoted [string] # RETURNS: n/a # REQUIRES: n/a @@ -106,7 +106,7 @@ return 0 # ----------------------------------------------------------------------------- # @(#) FUNCTION: data_magic_unquote() # DOES: magically unquotes a needle in a string (default needle is: %) -# EXPECTS: to be magically unquoted [string]; $2=needle [string] +# EXPECTS: to be magically unquoted [string]; $2=needle [string] # OUTPUTS: magically unquoted [string] # RETURNS: n/a # REQUIRES: n/a @@ -473,9 +473,9 @@ case "${1}" in +([0-9])*(.)*([0-9])) # numeric, OK ;; - *) + *) # not numeric - return 1 + return 1 ;; esac @@ -544,7 +544,7 @@ return 0 # OUTPUTS: 32 bit number [string] # REQUIRES: n/a # REFERENCE: https://raw.githubusercontent.com/dualbus/tutorial_nmap/master/iprange -function data_dot2ip +function data_dot2ip { (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _DOT="${1}" @@ -553,7 +553,7 @@ typeset _OLD_IFS="${IFS}" IFS="." set -A _COMPS ${_DOT} -IFS="${OLD_IFS}" +IFS="${_OLD_IFS}" _IP=$((_IP | ((_COMPS[0] & 255) << 24) )) _IP=$((_IP | ((_COMPS[1] & 255) << 16) )) @@ -573,13 +573,13 @@ return 0 # RETURNS: 0 # REQUIRES: n/a # REFERENCE: https://raw.githubusercontent.com/dualbus/tutorial_nmap/master/iprange -function data_ip2dot +function data_ip2dot { (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _IP="${1}" -typeset _W="" -typeset _X="" -typeset _Y="" +typeset _W="" +typeset _X="" +typeset _Y="" typeset _Z="" _W=$(( (_IP >> 24) & 255 )) @@ -617,21 +617,21 @@ case "${_BITS}" in 6) _OFFSET=67108864 ;; 7) _OFFSET=33554432 ;; 8) _OFFSET=16777216 ;; - 9) _OFFSET=8388608 ;; - 10) _OFFSET=4194304 ;; + 9) _OFFSET=8388608 ;; + 10) _OFFSET=4194304 ;; 11) _OFFSET=2097152 ;; 12) _OFFSET=1048576 ;; 13) _OFFSET=524288 ;; - 14) _OFFSET=262144 ;; - 15) _OFFSET=131072 ;; - 16) _OFFSET=65536 ;; + 14) _OFFSET=262144 ;; + 15) _OFFSET=131072 ;; + 16) _OFFSET=65536 ;; 17) _OFFSET=32768 ;; 18) _OFFSET=16384 ;; 19) _OFFSET=8192 ;; - 20) _OFFSET=4096 ;; - 21) _OFFSET=2048 ;; + 20) _OFFSET=4096 ;; + 21) _OFFSET=2048 ;; 22) _OFFSET=1024 ;; - 23) _OFFSET=512 ;; + 23) _OFFSET=512 ;; 24) _OFFSET=256 ;; 25) _OFFSET=128 ;; 26) _OFFSET=64 ;; @@ -691,11 +691,11 @@ return ${_RC} # ----------------------------------------------------------------------------- # @(#) FUNCTION: data_date2epoch() # DOES: converts a given date into UNIX epoch seconds -# EXPECTS: date formatted as individual parameters (in UTC time): +# EXPECTS: date formatted as individual parameters (in UTC time): # $1 : YYYY # $2 : MM # $3 : DD -# $4 : HH +# $4 : HH # $5 : MM # $6 : SS # OUTPUTS: UNIX epoch seconds [number] @@ -711,25 +711,25 @@ typeset _DAY="${3}" typeset _HOUR="${4}" typeset _MINUTE="${5}" typeset _SECOND="${6}" -typeset _DAYS_ACC -typeset _YEAR_DAY -typeset _EPOCH +typeset _DAYS_ACC +typeset _YEAR_DAY +typeset _EPOCH typeset _LEAP_YEARS set -A _DAYS_ACC 0 0 31 59 90 120 151 181 212 243 273 304 334 365 # calculate day of year (counting from 0) -_YEAR_DAY=$(( (${_DAY} - 1) + ${_DAYS_ACC[${_MONTH}]} )) +_YEAR_DAY=$(( (_DAY - 1) + _DAYS_ACC[_MONTH] )) # calculate number of leap years -_LEAP_YEARS=$(( (${_YEAR} - 1968) / 4 )) -_LEAP_YEARS=$(( ${_LEAP_YEARS} - ${_YEAR} / 100 + ${_YEAR} / 400 + 15 )) +_LEAP_YEARS=$(( (_YEAR - 1968) / 4 )) +_LEAP_YEARS=$(( _LEAP_YEARS - _YEAR / 100 + _YEAR / 400 + 15 )) # adjust if we are still in Jan/Feb of leap year -[[ $((${_YEAR} % 4)) = 0 && ${_MONTH} < 3 ]] && _LEAP_YEARS=$(( ${_LEAP_YEARS} - 1 )) +[[ $((_YEAR % 4)) = 0 && ${_MONTH} -lt 3 ]] && _LEAP_YEARS=$(( _LEAP_YEARS - 1 )) # calculate the time since epoch -_EPOCH=$(( ((${_YEAR} - 1970) * 365 + ${_YEAR_DAY} + ${_LEAP_YEARS}) * 86400 - + ${_HOUR} * 3600 + ${_MINUTE} * 60 + ${_SECOND} )) +_EPOCH=$(( ((_YEAR - 1970) * 365 + _YEAR_DAY + _LEAP_YEARS) * 86400 + + _HOUR * 3600 + _MINUTE * 60 + _SECOND )) print ${_EPOCH} } @@ -759,10 +759,10 @@ then print "${_UNIX_EPOCH}" return 1 else - print "${_CONVERT_DATE}" - fi + print "${_CONVERT_DATE}" + fi else - print "${CONVERT_DATE}" + print "${_CONVERT_DATE}" fi return 0 diff --git a/sources/lib/core/include_os.sh b/sources/lib/core/include_os.sh index bc0682a..6180f5e 100644 --- a/sources/lib/core/include_os.sh +++ b/sources/lib/core/include_os.sh @@ -101,6 +101,7 @@ then LINUX_INIT="systemd" elif [[ -r /usr/share/upstart ]] then + # shellcheck disable=SC2034 LINUX_INIT="upstart" fi diff --git a/sources/lib/core/notify_eif.sh b/sources/lib/core/notify_eif.sh index 7b8d06e..067c26b 100644 --- a/sources/lib/core/notify_eif.sh +++ b/sources/lib/core/notify_eif.sh @@ -33,7 +33,7 @@ function notify_eif { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/core/providers/$0.conf" -typeset _VERSION="2018-05-12" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -53,7 +53,7 @@ typeset _SLEEP_PID=0 typeset _CHILD_RC=0 # handle config file -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 @@ -79,7 +79,7 @@ then fi # send EIF -if [[ -x ${EIF_BIN} ]] +if [[ -x ${_EIF_BIN} ]] then # set trap on SIGUSR1 trap "handle_timeout" USR1 @@ -95,7 +95,7 @@ then _SLEEP_PID=$! # do POSTEIFMSG in the background - ${EIF_BIN} -f ${EIF_ETC} -r ${EIF_SEVERITY} -m "${_EIF_MESSAGE}" \ + ${_EIF_BIN} -f ${_EIF_ETC} -r ${_EIF_SEVERITY} -m "${_EIF_MESSAGE}" \ hostname=${HOST_NAME} sub_origin=part1 ${_EIF_CLASS} POST & CHILD_PID=$! log "spawning child process with time-out of ${_TIME_OUT} secs for EIF notify [PID=${CHILD_PID}]" diff --git a/sources/lib/core/notify_mail.sh b/sources/lib/core/notify_mail.sh index d3d00f6..f69a1a1 100644 --- a/sources/lib/core/notify_mail.sh +++ b/sources/lib/core/notify_mail.sh @@ -30,7 +30,7 @@ function notify_mail { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,9 +44,7 @@ typeset _MAIL_FAIL_ID="$2" typeset _HC_BODY="" typeset _HC_STDOUT_LOG_SHORT="" typeset _HC_STDERR_LOG_SHORT="" -typeset _HC_MSG_ENTRY="" typeset _MAIL_MSG_STC="" -typeset _MAIL_MSG_TIME="" typeset _MAIL_MSG_TEXT="" typeset _MAIL_INFO_TPL="${CONFIG_DIR}/core/templates/mail_info.tpl" typeset _MAIL_HEADER_TPL="${CONFIG_DIR}/core/templates/mail_header.tpl" @@ -67,10 +65,13 @@ typeset _TMP1_MAIL_FILE="${TMP_DIR}/.${SCRIPT_NAME}.mail.tmp1.$$" typeset _TMP2_MAIL_FILE="${TMP_DIR}/.${SCRIPT_NAME}.mail.tmp2.$$" typeset _NOW="$(date '+%d-%h-%Y %H:%M:%S')" typeset _SUBJ_MSG="[${HOST_NAME}] HC ${_MAIL_HC} failed (${_NOW})" +# shellcheck disable=SC2034 typeset _FROM_MSG="${EXEC_USER}@${HOST_NAME}" -typeset _dummy="" # set local trap for cleanup +# shellcheck disable=SC2064 +trap "[[ -f ${_TMP1_MAIL_FILE} ]] && rm -f ${_TMP1_MAIL_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_MAIL_FILE} ]] && rm -f ${_TMP2_MAIL_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_MAIL_FILE} ]] && rm -f ${_TMP1_MAIL_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_MAIL_FILE} ]] && rm -f ${_TMP2_MAIL_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 # set short paths for STDOUT/STDERR logs @@ -133,7 +134,7 @@ $(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_HEADER_TPL}) __EOT" >>${_TMP1_MAIL_FILE} # create body part (from $HC_MSG_VAR) -print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _MAIL_MSG_STC _MAIL_MSG_TIME _MAIL_MSG_TEXT _MAIL_MSG_CUR_VAL _MAIL_MSG_EXP_VAL +print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _MAIL_MSG_STC _ _MAIL_MSG_TEXT _MAIL_MSG_CUR_VAL _MAIL_MSG_EXP_VAL do # magically unquote if needed if [[ -n "${_MAIL_MSG_TEXT}" ]] @@ -159,7 +160,7 @@ do then _MAIL_MSG_EXP_VAL=$(data_magic_unquote "${_MAIL_MSG_EXP_VAL}") fi - fi + fi if (( _MAIL_MSG_STC > 0 )) then _HC_BODY=$(printf "%s\n%s\n" "${_HC_BODY}" "${_MAIL_MSG_TEXT}") @@ -177,18 +178,22 @@ __EOT" >>${_TMP1_MAIL_FILE} _MAIL_STDOUT_LOG="${EVENTS_DIR}/${DIR_PREFIX}/${_MAIL_FAIL_ID}/${_HC_STDOUT_LOG_SHORT%.*}" if [[ -s "${_MAIL_STDOUT_LOG}" ]] then + # shellcheck disable=SC2034 _MAIL_STDOUT_MSG="${_MAIL_STDOUT_LOG}" _MAIL_ATTACH_BIT="-a ${_MAIL_STDOUT_LOG}" else + # shellcheck disable=SC2034 _MAIL_STDOUT_MSG="no log file available" fi # HC STDERR? (drop the .$$ bit) _MAIL_STDERR_LOG="${EVENTS_DIR}/${DIR_PREFIX}/${_MAIL_FAIL_ID}/${_HC_STDERR_LOG_SHORT%.*}" if [[ -s "${_MAIL_STDERR_LOG}" ]] then + # shellcheck disable=SC2034 _MAIL_STDERR_MSG="${_MAIL_STDERR_LOG}" _MAIL_ATTACH_BIT="${_MAIL_ATTACH_BIT} -a ${_MAIL_STDERR_LOG}" else + # shellcheck disable=SC2034 _MAIL_STDERR_MSG="no log file available" fi @@ -235,7 +240,7 @@ fi # clean up temporary files [[ -f ${_TMP1_MAIL_FILE} ]] && rm -f ${_TMP1_MAIL_FILE} >/dev/null 2>&1 [[ -f ${_TMP2_MAIL_FILE} ]] && rm -f ${_TMP2_MAIL_FILE} >/dev/null 2>&1 - + return 0 } diff --git a/sources/lib/core/notify_sms.sh b/sources/lib/core/notify_sms.sh index 01ce71c..7f1ec39 100644 --- a/sources/lib/core/notify_sms.sh +++ b/sources/lib/core/notify_sms.sh @@ -31,7 +31,7 @@ function notify_sms { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/core/providers/$0.conf" -typeset _VERSION="2018-05-14" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -48,10 +48,10 @@ typeset _CURL_BIN="" typeset _SMS_PROVIDERS="" typeset _SMS_KAPOW_SEND_URL="" typeset _SMS_KAPOW_USER="" -typeset _SMS_KAPOW_PASSWORD="" +typeset _SMS_KAPOW_PASS="" # handle config file -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 @@ -84,8 +84,8 @@ then then warn "no value set for 'SMS_KAPOW_USER' in ${_CONFIG_FILE}" return 1 - fi - _SMS_KAPOW_PASS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'SMS_KAPOW_PASS') + fi + _SMS_KAPOW_PASS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'SMS_KAPOW_PASS') if [[ -z "${_SMS_KAPOW_PASS}" ]] then warn "no value set for 'SMS_KAPOW_PASS' in ${_CONFIG_FILE}" @@ -108,7 +108,7 @@ case "${ARG_SMS_PROVIDER}" in then ${_CURL_BIN} -s --url "${_SMS_KAPOW_SEND_URL}?username=${_SMS_KAPOW_USER}&password=${_SMS_KAPOW_PASS}&mobile=${ARG_SMS_TO}&sms=${_SMS_TEXT}" >/dev/null 2>&1 else - ${_CURL_BIN} --url "${_SMS_KAPOW_SEND_URL}?username=${_SMS_KAPOW_USER}&password=${_SMS_KAPOW_PASS}&mobile=${ARG_SMS_TO}&sms=${_SMS_TEXT}" + ${_CURL_BIN} --url "${_SMS_KAPOW_SEND_URL}?username=${_SMS_KAPOW_USER}&password=${_SMS_KAPOW_PASS}&mobile=${ARG_SMS_TO}&sms=${_SMS_TEXT}" fi else die "unable to send SMS - curl is not installed here" diff --git a/sources/lib/core/report_std.sh b/sources/lib/core/report_std.sh index 3423270..5d0668a 100644 --- a/sources/lib/core/report_std.sh +++ b/sources/lib/core/report_std.sh @@ -30,7 +30,7 @@ function report_std { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-05-27" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -49,7 +49,6 @@ typeset _HC_LAST_FAIL_ID="-" typeset _ID_NEEDLE="" typeset _CHECK_FILE="" typeset _LOG_STASH="" -typeset _REPORT_LINE="" typeset _SORT_CMD="" # which files do we need to examine @@ -65,6 +64,7 @@ fi if (( ARG_LAST != 0 )) then printf "\n| %-30s | %-20s | %-14s | %-4s\n" "HC" "Timestamp" "FAIL ID" "STC (combined value)" + # shellcheck disable=SC2183 printf "%100s\n" | tr ' ' - # loop over all HCs list_hc "list" | while read -r _HC_LAST @@ -136,6 +136,7 @@ else then printf "\n| %-20s | %-14s | %-30s | %-s\n" \ "Timestamp" "FAIL ID" "HC" "Message" + # shellcheck disable=SC2183 printf "%120s\n" | tr ' ' - # print failed events @@ -169,6 +170,7 @@ else ' 2>/dev/null _DIR_PREFIX="$(expr substr ${ARG_FAIL_ID} 1 4)-$(expr substr ${ARG_FAIL_ID} 5 2)" + # shellcheck disable=SC2183 printf "%37sSTDOUT%37s\n" | tr ' ' -; # display non-empty STDOUT file(s) if [[ -n "$(du -a ${EVENTS_DIR}/${_DIR_PREFIX}/${ARG_FAIL_ID}/*.stdout.log 2>/dev/null | awk '$1*512 > 0 {print $2}')" ]] @@ -178,6 +180,7 @@ else printf "%-s\n" "No STDOUT found" fi + # shellcheck disable=SC2183 printf "%37sSTDERR%37s\n" | tr ' ' -; # display non-empty STDERR file(s) if [[ -n "$(du -a ${EVENTS_DIR}/${_DIR_PREFIX}/${ARG_FAIL_ID}/*.stderr.log 2>/dev/null | awk '$1*512 > 0 {print $2}')" ]] @@ -187,6 +190,7 @@ else printf "%-s\n" "No STDERR found" fi + # shellcheck disable=SC2183 printf "%80s\n" | tr ' ' - fi else diff --git a/sources/lib/platform/aix/check_aix_errpt.sh b/sources/lib/platform/aix/check_aix_errpt.sh index 7c7aab1..cc46fe5 100644 --- a/sources/lib/platform/aix/check_aix_errpt.sh +++ b/sources/lib/platform/aix/check_aix_errpt.sh @@ -25,6 +25,7 @@ # @(#) 2013-05-15: initial version [Patrick Van der Veken] # @(#) 2013-05-29: small fix errpt last check time [Patrick Van der Veken] # @(#) 2013-06-24: big fix errpt last check time [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_aix_errpt { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2013-06-24" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,7 +48,6 @@ typeset _STC=0 typeset _LAST_TIME_CHECK="" typeset _LAST_TIME_FILE="" typeset _LABEL="" -typeset _IDENTIFIER="" typeset _NEW_CHECK_TIME="" # handle arguments (originally comma-separated) @@ -56,7 +56,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -66,7 +66,7 @@ if [[ -r ${_LAST_TIME_FILE} ]] then if [[ -s ${_LAST_TIME_FILE} ]] then - _LAST_TIME_CHECK="<${_LAST_TIME_FILE})" + _LAST_TIME_CHECK="<${_LAST_TIME_FILE})" else warn "$0: no last known check date/time" fi @@ -100,12 +100,12 @@ fi # but we can live it :-)) _NEW_CHECK_TIME="$(errpt 2>/dev/null | head -n 2 | tail -n 1 | awk '{print $2}')" # blank result indicates either no errpt entries or exist the time call failed -if [[ -n "${_NEW_CHECK_TIME}" ]] +if [[ -n "${_NEW_CHECK_TIME}" ]] then print "${_NEW_CHECK_TIME}" >${_LAST_TIME_FILE} (( $? == 0)) || warn "$0: unable to write last check time to ${_LAST_TIME_FILE}" else - warn "$0: no last check time received from errpt (no entries)" + warn "$0: no last check time received from errpt (no entries)" fi # handle results diff --git a/sources/lib/platform/aix/check_aix_file_age.sh b/sources/lib/platform/aix/check_aix_file_age.sh index e97577d..c1e5008 100644 --- a/sources/lib/platform/aix/check_aix_file_age.sh +++ b/sources/lib/platform/aix/check_aix_file_age.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2013-05-27: initial version [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_aix_file_age { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2013-05-27" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,7 +45,7 @@ typeset _ARG="" typeset _MSG="" typeset _STC=0 typeset _ENTRY="" -typeset _AGE_CHECK=="" +typeset _AGE_CHECK="" typeset _FILE_PATH="" typeset _FILE_AGE="" typeset _FILE_NAME="" @@ -56,57 +57,57 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # handle configuration file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi - + # perform check grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _ENTRY do # field split _FILE_PATH="$(print ${_ENTRY%%;*})" _FILE_AGE="$(print ${_ENTRY##*;})" - + # split file/dir - _FILE_NAME="$(print ${_FILE_PATH##*/})" - _FILE_DIR="$(print ${_FILE_PATH%/*})" - + _FILE_NAME="$(print ${_FILE_PATH##*/})" + _FILE_DIR="$(print ${_FILE_PATH%/*})" + # check config - if [ \( -z "${_FILE_PATH}" \) -a \( -z "${_FILE_AGE}" \) ] + if [[ -z "${_FILE_PATH}" ]] && [[ -z "${_FILE_AGE}" ]] then warn "missing values in configuration file at ${_CONFIG_FILE}" - return 1 + return 1 fi case "${_FILE_AGE}" in +([0-9])*(.)*([0-9])) # numeric, OK ;; - *) + *) # not numeric warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}" - return 1 + return 1 ;; esac - + # perform check if [[ ! -r "${_FILE_PATH}" ]] then _MSG="unable to read or access requested file at ${_FILE_PATH}" - _STC=1 + _STC=1 else _AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -mmin -"${_FILE_AGE}") if (( $? != 0 )) then warn "unable to execute file age test for ${_FILE_PATH}" - return 1 + return 1 fi if [[ -z "${_AGE_CHECK}" ]] then @@ -116,7 +117,7 @@ do _MSG="file age of ${_FILE_AGE} has not expired on ${_FILE_PATH}" fi fi - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 diff --git a/sources/lib/platform/aix/check_aix_file_change.sh b/sources/lib/platform/aix/check_aix_file_change.sh index 888698e..3a4fb4c 100644 --- a/sources/lib/platform/aix/check_aix_file_change.sh +++ b/sources/lib/platform/aix/check_aix_file_change.sh @@ -24,6 +24,7 @@ # # @(#) HISTORY: # @(#) 2017-05-18: initial version [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_aix_file_change { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2017-05-18" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,7 +45,6 @@ typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 -typeset _STC_COUNT=0 typeset _DO_META_CHECK=0 typeset _CFG_STATE_FILE="" typeset _STATE_FILE="" @@ -65,11 +65,13 @@ typeset _TMP_EXCL_FILE="${TMP_DIR}/.$0.tmp_excl.$$" set -o noglob # no file globbing # set local trap for clean-up +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; [[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; @@ -133,6 +135,7 @@ fi # check state file & TMP_FILEs [[ -r ${_STATE_FILE} ]] || { + # shellcheck disable=SC2188 >${_STATE_FILE} (( $? > 0 )) && { warn "failed to create new state file at ${_STATE_FILE}" @@ -140,21 +143,25 @@ fi } log "created new state file at ${_STATE_FILE}" } +# shellcheck disable=SC2188 >${_TMP_INCL_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP_INCL_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP_EXCL_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP_EXCL_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP1_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP1_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP2_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP2_FILE}" @@ -163,7 +170,7 @@ fi # build list of configured objects: inclusion grep -i '^incl:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _INCL_OBJECT + while IFS=':' read _ _INCL_OBJECT do # check for meta & globbing characters (*?[]{}|) if (( _DO_META_CHECK == 1 )) @@ -187,7 +194,7 @@ done # build list of configured objects: exclusion grep -i '^excl:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _EXCL_OBJECT + while IFS=':' read _ _EXCL_OBJECT do # check for meta & globbing characters (*?[]{}|) if (( _DO_META_CHECK == 1 )) @@ -337,12 +344,6 @@ then } fi -# clean up temporary files -[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 -[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1 -[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1 -[[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/hp-ux/check_hpux_drd_status.sh b/sources/lib/platform/hp-ux/check_hpux_drd_status.sh index 3cae0da..846c60f 100644 --- a/sources/lib/platform/hp-ux/check_hpux_drd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_drd_status.sh @@ -27,6 +27,7 @@ # @(#) 2018-05-11: initial version [Patrick Van der Veken] # @(#) 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] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +38,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-18" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,7 +48,6 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" -typeset _STC=0 typeset _RC=0 typeset _CHECK_CLONE="" typeset _CHECK_SYNC="" @@ -126,8 +126,7 @@ fi if (( _RC == 0 )) && (( $(grep -c -E -e ".*Information succeeded.*" ${HC_STDOUT_LOG} 2>/dev/null) > 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')") - _NOW_EPOCH=$(data_date2epoch $(date '+%Y %m %d %H %M %S')) + _NOW_EPOCH=$(data_date2epoch "$(date '+%Y')" "$(date '+%m')" "$(date '+%d')" "$(date '+%H')" "$(date '+%M')" "$(date '+%S')") # get devices _ORIGINAL_DISK=$(data_strip_space "$(grep "Original Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')") diff --git a/sources/lib/platform/hp-ux/check_hpux_file_age.sh b/sources/lib/platform/hp-ux/check_hpux_file_age.sh index 99f1dde..601915d 100644 --- a/sources/lib/platform/hp-ux/check_hpux_file_age.sh +++ b/sources/lib/platform/hp-ux/check_hpux_file_age.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2013-05-27: initial version [Patrick Van der Veken] # @(#) 2013-05-29: added local trap for cleanup [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_hpux_file_age { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2013-05-29" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,15 +48,15 @@ typeset _STC=0 typeset _REF_FILE="${TMP_DIR}/.$0.ref.$$" typeset _DO_REF=0 typeset _ENTRY="" -typeset _REF_TIME="" -typeset _AGE_CHECK=="" typeset _FILE_PATH="" typeset _FILE_AGE="" typeset _FILE_NAME="" typeset _FILE_DIR="" # set local trap for cleanup +# shellcheck disable=SC2064 trap "[[ -f ${_REF_FILE} ]] && rm -f ${_REF_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_REF_FILE} ]] && rm -f ${_REF_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -88,7 +89,7 @@ do _FILE_DIR=$(print "${_FILE_PATH%/*}") # check config - if [ \( -z "${_FILE_PATH}" \) -a \( -z "${_FILE_AGE}" \) ] + if [[ -z "${_FILE_PATH}" ]] && [[ -z "${_FILE_AGE}" ]] then warn "missing values in configuration file at ${_CONFIG_FILE}" return 1 diff --git a/sources/lib/platform/hp-ux/check_hpux_file_change.sh b/sources/lib/platform/hp-ux/check_hpux_file_change.sh index 5ceb672..b876147 100644 --- a/sources/lib/platform/hp-ux/check_hpux_file_change.sh +++ b/sources/lib/platform/hp-ux/check_hpux_file_change.sh @@ -24,6 +24,7 @@ # # @(#) HISTORY: # @(#) 2017-05-18: initial version [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_hpux_file_change { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2017-05-18" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,7 +45,6 @@ typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 -typeset _STC_COUNT=0 typeset _DO_META_CHECK=0 typeset _CFG_STATE_FILE="" typeset _STATE_FILE="" @@ -65,11 +65,13 @@ typeset _TMP_EXCL_FILE="${TMP_DIR}/.$0.tmp_excl.$$" set -o noglob # no file globbing # set local trap for clean-up +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; [[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; @@ -133,6 +135,7 @@ fi # check state file & TMP_FILEs [[ -r ${_STATE_FILE} ]] || { + # shellcheck disable=SC2188 >${_STATE_FILE} (( $? > 0 )) && { warn "failed to create new state file at ${_STATE_FILE}" @@ -140,21 +143,25 @@ fi } log "created new state file at ${_STATE_FILE}" } +# shellcheck disable=SC2188 >${_TMP_INCL_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP_INCL_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP_EXCL_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP_EXCL_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP1_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP1_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP2_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP2_FILE}" @@ -163,7 +170,7 @@ fi # build list of configured objects: inclusion grep -i '^incl:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _INCL_OBJECT + while IFS=':' read _ _INCL_OBJECT do # check for meta & globbing characters (*?[]{}|) if (( _DO_META_CHECK == 1 )) @@ -187,7 +194,7 @@ done # build list of configured objects: exclusion grep -i '^excl:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _EXCL_OBJECT + while IFS=':' read _ _EXCL_OBJECT do # check for meta & globbing characters (*?[]{}|) if (( _DO_META_CHECK == 1 )) @@ -337,12 +344,6 @@ then } fi -# clean up temporary files -[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 -[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1 -[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1 -[[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/hp-ux/check_hpux_fs_mounts_options.sh b/sources/lib/platform/hp-ux/check_hpux_fs_mounts_options.sh index f8e87af..90e95ba 100644 --- a/sources/lib/platform/hp-ux/check_hpux_fs_mounts_options.sh +++ b/sources/lib/platform/hp-ux/check_hpux_fs_mounts_options.sh @@ -25,6 +25,7 @@ # @(#) 2016-04-04: original version [Patrick Van der Veken] # @(#) 2016-12-02: add support for ignore_missing_fs option [Patrick Van der Veken] # @(#) 2017-07-31: added support for current/expected value output [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_hpux_fs_mounts_options { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2017-07-31" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -48,7 +49,6 @@ typeset _STC=0 typeset _CONFIG_FS="" typeset _CONFIG_OPTS="" typeset _CURR_OPTS="" -typeset _DUMMY="" typeset _IGNORE_FS="" typeset _IS_ACTIVE=0 typeset _FS_ENTRY="" @@ -86,7 +86,7 @@ mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} # check for each configured file system grep -i '^fs:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _CONFIG_FS _CONFIG_OPTS + while IFS=':' read _ _CONFIG_FS _CONFIG_OPTS do # check for active FS _IS_ACTIVE=$(grep -c -E -e "^${_CONFIG_FS}[ \t].*" ${HC_STDOUT_LOG} 2>/dev/null) diff --git a/sources/lib/platform/hp-ux/check_hpux_guid_status.sh b/sources/lib/platform/hp-ux/check_hpux_guid_status.sh index 95eff47..1eaaa9e 100644 --- a/sources/lib/platform/hp-ux/check_hpux_guid_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_guid_status.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2017-05-18: initial version [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -31,7 +32,7 @@ function check_hpux_guid_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2017-05-18" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -51,7 +52,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -63,7 +64,7 @@ then if [[ -n "${_GUID_PID}" ]] then # get PID list without heading - (( $(UNIX95= ps -o pid= -p ${_GUID_PID}| wc -l) == 0 )) && _STC=1 + (( $(UNIX95='' ps -o pid= -p ${_GUID_PID}| wc -l) == 0 )) && _STC=1 else # not running _RC=1 diff --git a/sources/lib/platform/hp-ux/check_hpux_hpvm_vpar_status.sh b/sources/lib/platform/hp-ux/check_hpux_hpvm_vpar_status.sh index 3e18d5e..ed4e376 100644 --- a/sources/lib/platform/hp-ux/check_hpux_hpvm_vpar_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_hpvm_vpar_status.sh @@ -25,6 +25,7 @@ # @(#) 2017-06-01: initial version [Patrick Van der Veken] # @(#) 2017-06-08: return 1 on error [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_hpux_hpvm_vpar_status # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _HPVMSTATUS_BIN="/opt/hpvm/bin/hpvmstatus" -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -63,7 +64,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -81,22 +82,22 @@ ${_HPVMSTATUS_BIN} -M >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} # dump debug info (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 -} +} # check configuration values grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _PAR_ENTRY do # field split _PAR_ID=$(print "${_PAR_ENTRY}" | cut -f1 -d';') - _PAR_CFG_STATUS=$(data_lc $(print "${_PAR_ENTRY}" | cut -f2 -d';')) - _PAR_CFG_BOOT=$(data_lc $(print "${_PAR_ENTRY}" | cut -f3 -d';')) - + _PAR_CFG_STATUS=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f2 -d';')") + _PAR_CFG_BOOT=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f3 -d';')") + # check configuration case "${_PAR_ID}" in +([0-9])*(.)*([0-9])) # numeric, OK ;; - *) + *) # not numeric warn "invalid partition ID '${_PAR_ID}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" return 1 @@ -105,57 +106,57 @@ do case "${_PAR_CFG_STATUS}" in on|off) ;; - *) + *) warn "invalid partition status '${_PAR_CFG_STATUS}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" - return 1 + return 1 ;; - esac + esac case "${_PAR_CFG_BOOT}" in auto|manual) ;; - *) + *) warn "invalid partition boot value '${_PAR_CFG_BOOT}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" - return 1 + return 1 ;; esac _LINE_COUNT=$(( _LINE_COUNT + 1 )) done - + # perform checks grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _PAR_ENTRY do # field split _PAR_ID=$(print "${_PAR_ENTRY}" | cut -f1 -d';') - _PAR_CFG_STATUS=$(data_lc $(print "${_PAR_ENTRY}" | cut -f2 -d';')) - _PAR_CFG_BOOT=$(data_lc $(print "${_PAR_ENTRY}" | cut -f3 -d';')) - + _PAR_CFG_STATUS=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f2 -d';')") + _PAR_CFG_BOOT=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f3 -d';')") + # check run-time values (we need to make the needle sufficiently less greedy) _PAR_MATCH=$(grep -i "^.*:.*:${_PAR_ID}::Integrity" ${HC_STDOUT_LOG} 2>/dev/null) if [[ -n "${_PAR_MATCH}" ]] then # field split - _PAR_RUN_STATUS=$(data_lc $(print "${_PAR_MATCH}" | cut -f11 -d':')) - _PAR_RUN_BOOT=$(data_lc $(print "${_PAR_MATCH}" | cut -f12 -d':')) - + _PAR_RUN_STATUS=$(data_lc "$(print \"${_PAR_MATCH}\" | cut -f11 -d':')") + _PAR_RUN_BOOT=$(data_lc "$(print \"${_PAR_MATCH}\" | cut -f12 -d':')") + if [[ "${_PAR_RUN_STATUS}" = "${_PAR_CFG_STATUS}" ]] then _MSG="partition ${_PAR_ID} has a correct status [${_PAR_RUN_STATUS}]" _STC=0 else - _MSG="partition ${_PAR_ID} has a wrong status [${_PAR_RUN_STATUS}]" + _MSG="partition ${_PAR_ID} has a wrong status [${_PAR_RUN_STATUS}]" _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" "${_PAR_RUN_STATUS}" "${_PAR_CFG_STATUS}" - + log_hc "$0" ${_STC} "${_MSG}" "${_PAR_RUN_STATUS}" "${_PAR_CFG_STATUS}" + if [[ "${_PAR_RUN_BOOT}" = "${_PAR_CFG_BOOT}" ]] then _MSG="partition ${_PAR_ID} has a correct boot flag [${_PAR_RUN_BOOT}]" _STC=0 else - _MSG="partition ${_PAR_ID} has a wrong boot flag [${_PAR_RUN_BOOT}]" - _STC=1 + _MSG="partition ${_PAR_ID} has a wrong boot flag [${_PAR_RUN_BOOT}]" + _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" "${_PAR_RUN_BOOT}" "${_PAR_CFG_BOOT}" + log_hc "$0" ${_STC} "${_MSG}" "${_PAR_RUN_BOOT}" "${_PAR_CFG_BOOT}" else warn "could not determine status for partition ${_PAR_ID} from command output {${_HPVMSTATUS_BIN}}" _RC=1 diff --git a/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh b/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh index 382a201..12fc7f8 100644 --- a/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2017-04-23: initial version [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_hpux_httpd_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _HTTPD_PID_FILE="/var/run/httpd/httpd.pid" -typeset _VERSION="2017-04-23" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -41,7 +42,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" -typeset _HTTPD_CHECKCONF_BIN="" +typeset _HTTPD_BIN="" typeset _HTTPD_PID="" typeset _MSG="" typeset _STC=0 @@ -65,7 +66,7 @@ then if [[ -n "${_HTTPD_PID}" ]] then # get PID list without heading - (( $(UNIX95= ps -o pid= -p ${_HTTPD_PID}| wc -l) == 0 )) && _STC=1 + (( $(UNIX95='' ps -o pid= -p ${_HTTPD_PID}| wc -l) == 0 )) && _STC=1 else # not running _RC=1 diff --git a/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh b/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh index c6de787..828f535 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh @@ -26,6 +26,7 @@ # @(#) 2016-05-26: added a simple exclusion list for hosts as configurable # @(#) parameter [Patrick Van der Veken] # @(#) 2016-06-03: small fix [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +38,7 @@ function check_hpux_ignite_backup typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" # backup DONE identifier typeset _IGNITE_NEEDLE="^DONE" -typeset _VERSION="2016-06-03" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -92,7 +93,16 @@ _EXCLUDE_HOSTS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'exc if [[ -d /var/opt/ignite/clients ]] then _OLD_PWD="$(pwd)" + # shellcheck disable=SC2164 cd /var/opt/ignite/clients + if (( $? > 0 )) + then + _MSG="unable to run command: cd /var/opt/ignite/clients" + log_hc "$0" 1 "${_MSG}" + # dump debug info + (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 + fi # check backup states find * -prune -type l | while read _IGNITE_HOST @@ -168,7 +178,16 @@ then _STC=0 done + # shellcheck disable=SC2164 cd "${_OLD_PWD}" + if (( $? > 0 )) + then + _MSG="unable to run command: cd /var/opt/ignite/clients" + log_hc "$0" 1 "${_MSG}" + # dump debug info + (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 + fi else _MSG="Host is not an Ignite/UX server" log_hc "$0" ${_STC} "${_MSG}" @@ -187,7 +206,7 @@ CONFIG : $3 with: backup_age= PURPOSE : Checks the state and age of saved Ignite-UX client backups (should only be run only on the Ignite-UX server). Backups with warnings are considered - to OK. Backups older than $backup_age will not pass the health check. + to OK. Backups older than \$backup_age will not pass the health check. EOT diff --git a/sources/lib/platform/hp-ux/check_hpux_ioscan.sh b/sources/lib/platform/hp-ux/check_hpux_ioscan.sh index d3632cc..765f227 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ioscan.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ioscan.sh @@ -29,6 +29,7 @@ # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] # @(#) 2018-05-11: small optimizations [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -40,7 +41,7 @@ function check_hpux_ioscan typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _IOSCAN_BIN="/usr/sbin/ioscan" typeset _IOSCAN_OPTS="-Fn" -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-08-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -67,13 +68,13 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # handle configuration file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 @@ -86,7 +87,7 @@ then _IOSCAN_CLASSES="ctl|diag|disk|ext_bus|fc|fcp|i2o|ipmi|lan|lvm|olar|vm" else # convert commas and strip quotes - _IOSCAN_CLASSES=$(data_comma2pipe $(data_dequote "${_CLASS_LINE}")) + _IOSCAN_CLASSES=$(data_comma2pipe "$(data_dequote \"${_CLASS_LINE}\")") fi _KERNEL_MODE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'kernel_mode') if [[ -z "${_KERNEL_MODE}" ]] @@ -126,32 +127,32 @@ else fi log "executing ioscan with options: ${_IOSCAN_OPTS}" ${_IOSCAN_BIN} ${_IOSCAN_OPTS} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} - if (( $? != 0 )) + if (( $? != 0 )) then _MSG="unable to run command: {${_IOSCAN_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs - return 0 + return 1 fi fi - + # check for requested device classes grep -E -e ".*:.*:.*:.*:.*:.*:.*:.*:${_IOSCAN_CLASSES}:.*" ${HC_STDOUT_LOG} 2>/dev/null |\ while read _IOSCAN_LINE do # possible states are: CLAIMED, UNCLAIMED, DIFF_HW, NO_HW, ERROR, SCAN - _HW_CLASS="$(print ${_IOSCAN_LINE} | cut -f9 -d':')" - _HW_PATH="$(print ${_IOSCAN_LINE} | cut -f11 -d':')" + _HW_CLASS="$(print ${_IOSCAN_LINE} | cut -f9 -d':')" + _HW_PATH="$(print ${_IOSCAN_LINE} | cut -f11 -d':')" _HW_STATE="$(print ${_IOSCAN_LINE} | cut -f16 -d':')" - + case "${_HW_STATE}" in NO_HW) _MSG="detected NO_HW for device on path '${_HW_PATH}', class '${_HW_CLASS}'" _STC=1 _STC_COUNT=$(( _STC_COUNT + 1 )) ;; - ERROR) + ERROR) _MSG="detected ERROR for device on HW path '${_HW_PATH}', class '${_HW_CLASS}'" _STC=1 _STC_COUNT=$(( _STC_COUNT + 1 )) @@ -160,7 +161,7 @@ do # everything else is considered non-fatal (do not report) continue esac - + log_hc "$0" ${_STC} "${_MSG}" _STC=0 done diff --git a/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh b/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh index 2c7f244..98f4a28 100644 --- a/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh +++ b/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh @@ -25,6 +25,7 @@ # @(#) 2017-12-22: original version [Patrick Van der Veken] # @(#) 2018-01-05: added validation on config values [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_hpux_kernel_params # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _KCTUNE_BIN="/usr/sbin/kctune" -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -51,7 +52,6 @@ typeset _CONFIG_VALUE="" typeset _CURR_VALUE="" typeset _EXPR_VALUE="" typeset _REPORTED_VALUE="" -typeset _DUMMY="" typeset _FOUND_PARAM=0 typeset _LINE_COUNT=1 @@ -92,7 +92,7 @@ fi # check configuration values grep -i '^param:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _PARAM_NAME _CONFIG_VALUE + while IFS=':' read _ _PARAM_NAME _CONFIG_VALUE do # check for empties if [[ -z "${_PARAM_NAME}" || -z "${_CONFIG_VALUE}" ]] @@ -112,7 +112,7 @@ done # perform checks grep -i '^param:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _PARAM_NAME _CONFIG_VALUE + while IFS=':' read _ _PARAM_NAME _CONFIG_VALUE do # check for actual values and expression values _CURR_VALUE=$(grep -E -e "^${_PARAM_NAME}[ \t].*" ${HC_STDOUT_LOG} 2>/dev/null | awk '{ print $2 }') diff --git a/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh b/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh index 4ed2717..c925301 100644 --- a/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh +++ b/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh @@ -26,6 +26,7 @@ # @(#) 2018-01-08: extra config checks [Patrick Van der Veken] # @(#) 2018-01-09: bug fix [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -36,7 +37,7 @@ function check_hpux_kernel_usage # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _KCUSAGE_BIN="/usr/sbin/kcusage" -typeset _VERSION="2018-05-20" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -58,7 +59,6 @@ typeset _CURR_VALUE="" typeset _FOUND_PARAM=0 typeset _KCUSAGE_LINE="" typeset _LINE_COUNT=1 -typeset _DUMMY="" # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -82,7 +82,7 @@ _MAX_KCUSAGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'max_k if [[ -z "${_MAX_KCUSAGE}" ]] then # default - _IGNORE_FS=90 + _MAX_KCUSAGE=90 fi _EXCLUDED_PARAMS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'exclude_params') if [[ -n "${_EXCLUDED_PARAMS}" ]] @@ -109,7 +109,7 @@ fi # check configuration values grep -i '^param:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _PARAM_NAME _CONFIG_VALUE + while IFS=':' read _ _PARAM_NAME _CONFIG_VALUE do # check for empties if [[ -z "${_PARAM_NAME}" || -z "${_CONFIG_VALUE}" ]] @@ -134,10 +134,10 @@ do return 1 fi ;; - *) + *) # not numeric warn "invalid threshold value '${_CONFIG_VALUE}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" - return 1 + return 1 ;; esac _LINE_COUNT=$(( _LINE_COUNT + 1 )) @@ -145,7 +145,7 @@ done # 1) perform checks (first the invidually configured ones) grep -i '^param:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _PARAM_NAME _CONFIG_VALUE + while IFS=':' read _ _PARAM_NAME _CONFIG_VALUE do # check for actual values and ceilings _CURR_VALUE=$(grep -E -e "^${_PARAM_NAME}[ \t].*" ${HC_STDOUT_LOG} 2>/dev/null | awk '{ print $2 }') @@ -196,7 +196,7 @@ do else _MSG="${_PARAM_NAME} is below the general threshold (${_CHECK_VALUE}% <= ${_MAX_KCUSAGE}%)" fi - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" "${_CHECK_VALUE}" "${_MAX_KCUSAGE}" _STC=0 diff --git a/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh b/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh index 429ea30..e3d81b9 100644 --- a/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh +++ b/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh @@ -51,13 +51,12 @@ typeset _STC=0 typeset _LOG_HEALTHY=0 typeset _TMP1_FILE="${TMP_DIR}/.$0.ioscan_tmp.$$" typeset _TMP2_FILE="${TMP_DIR}/.$0.scsimgr_tmp.$$" -typeset _IOSCAN_LINE="" -typeset _SCSIMGR_LINE="" typeset _HW_PATH="" typeset _ACTIVE_PATH_COUNT="" typeset _ALL_PATH_COUNT="" typeset _FAILED_PATH_COUNT="" typeset _STANDBY_PATH_COUNT="" +typeset _WWID="" # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -84,9 +83,11 @@ else fi # set local trap for cleanup +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 @@ -104,11 +105,13 @@ then fi # check TMP_FILEs +# shellcheck disable=SC2188 >${_TMP1_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP1_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP2_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP2_FILE}" diff --git a/sources/lib/platform/hp-ux/check_hpux_named_status.sh b/sources/lib/platform/hp-ux/check_hpux_named_status.sh index 6a0a044..ade75bc 100644 --- a/sources/lib/platform/hp-ux/check_hpux_named_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_named_status.sh @@ -53,7 +53,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -65,7 +65,7 @@ then if [[ -n "${_NAMED_PID}" ]] then # get PID list without heading - (( $(UNIX95= ps -o pid= -p ${_NAMED_PID}| wc -l) == 0 )) && _STC=1 + (( $(UNIX95='' ps -o pid= -p ${_NAMED_PID}| wc -l) == 0 )) && _STC=1 else # not running _RC=1 diff --git a/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh b/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh index cdc1c92..17bcd90 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2016-12-01: initial version [Patrick Van der Veken] # @(#) 2016-12-29: added threshold & config file [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #------------------------------------------------------------------------------ @@ -33,7 +34,7 @@ function check_hpux_ntp_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2016-12-29" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _NTPQ_BIN="/usr/sbin/ntpq" # ------------------------- CONFIGURATION ends here --------------------------- @@ -55,13 +56,13 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # handle config file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 @@ -75,7 +76,7 @@ then fi # check & get NTP status -if [[ ! -x ${_NTPQ_BIN} ]] +if [[ ! -x ${_NTPQ_BIN} ]] then warn "${_NTPQ_BIN} is not installed here" return 1 @@ -116,16 +117,16 @@ then if (( $(awk -v c="${_CURR_OFFSET}" -v m="${_MAX_OFFSET}" 'BEGIN { print (c>m) }') != 0 )) then _MSG="NTP offset of ${_CURR_OFFSET} is bigger than the configured maximum of ${_MAX_OFFSET}" - _STC=1 + _STC=1 else - _MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range" + _MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range" fi - log_hc "$0" ${_STC} "${_MSG}" + log_hc "$0" ${_STC} "${_MSG}" ;; - *) + *) # not numeric - warn "invalid offset value of ${_CURR_OFFSET} found for ${NTP_PEER}?" - return 1 + warn "invalid offset value of ${_CURR_OFFSET} found for ${_NTP_PEER}?" + return 1 ;; esac fi diff --git a/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh b/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh index 64cfb8b..71b0b38 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh @@ -27,6 +27,7 @@ # @(#) 2018-07-10: added log_healthy hc_arg [Patrick Van der Veken] # @(#) 2018-08-30: added config file + check list for daemons [Patrick Van der Veken] # @(#) 2018-10-22: small fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -36,7 +37,7 @@ function check_hpux_ovpa_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-10-22" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _OVPA_BIN="/opt/perf/bin/perfstat" # ------------------------- CONFIGURATION ends here --------------------------- @@ -90,7 +91,7 @@ then esac else # convert commas and strip quotes - _OVPA_DAEMONS=$(data_comma2space $(data_dequote "${_OVPA_DAEMONS}")) + _OVPA_DAEMONS=$(data_comma2space "$(data_dequote \"${_OVPA_DAEMONS}\")") fi log "will check daemons: ${_OVPA_DAEMONS}" _CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') diff --git a/sources/lib/platform/hp-ux/check_hpux_patch_version.sh b/sources/lib/platform/hp-ux/check_hpux_patch_version.sh index 29e5c42..873d31a 100644 --- a/sources/lib/platform/hp-ux/check_hpux_patch_version.sh +++ b/sources/lib/platform/hp-ux/check_hpux_patch_version.sh @@ -26,6 +26,7 @@ # @(#) 2018-05-11: initial version [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-22: added check on fileset state [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -39,7 +40,7 @@ typeset _SWLIST_BIN="/usr/sbin/swlist" typeset _SWLIST_OPTS="" typeset _SHOW_PATCHES_BIN="/usr/contrib/bin/show_patches" typeset _SHOW_PATCHES_OPTS="" -typeset _VERSION="2018-10-22" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -49,7 +50,6 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" -typeset _STC=0 typeset _CFG_HEALTHY="" typeset _LOG_HEALTHY=0 typeset _OE_VERSION="" @@ -83,7 +83,7 @@ _PATCH_LINE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'requir if [[ -n "${_PATCH_LINE}" ]] then # convert commas and strip quotes - _PATCHES=$(data_comma2space $(data_dequote "${_PATCH_LINE}")) + _PATCHES=$(data_comma2space "$(data_dequote \"${_PATCH_LINE}\")") fi if [[ -z "${_CHECK_FILESETS}" ]] then diff --git a/sources/lib/platform/hp-ux/check_hpux_sg_cluster_config.sh b/sources/lib/platform/hp-ux/check_hpux_sg_cluster_config.sh index 2f7f19d..1cd2823 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sg_cluster_config.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sg_cluster_config.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2016-03-08: initial version [Patrick Van der Veken] # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_hpux_sg_cluster_config { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2016-12-01" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SG_DAEMON="/usr/lbin/cmcld" # rubbish that cmgetconf outputs to STDOUT instead of STDERR @@ -58,7 +59,9 @@ typeset _CLUSTER_PARAM="" typeset _CLUSTER_VALUE="" # set local trap for cleanup +# shellcheck disable=SC2064 trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -165,9 +168,6 @@ do done <${_CLUSTER_CFG_FILE}.${_CLUSTER_INSTANCE} done -# remove working files -rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/hp-ux/check_hpux_sg_cluster_status.sh b/sources/lib/platform/hp-ux/check_hpux_sg_cluster_status.sh index 327aa32..4164269 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sg_cluster_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sg_cluster_status.sh @@ -26,6 +26,7 @@ # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] # @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_hpux_sg_cluster_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2017-05-07" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SG_DAEMON="/usr/lbin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- @@ -50,7 +51,6 @@ typeset _STC=0 typeset _SG_ENTRY="" typeset _SG_MATCH="" typeset _SG_CFG_PARAM="" -typeset _SG_RUN_PARAM="" typeset _SG_CFG_VALUE="" typeset _SG_RUN_VALUE="" diff --git a/sources/lib/platform/hp-ux/check_hpux_sg_package_config.sh b/sources/lib/platform/hp-ux/check_hpux_sg_package_config.sh index 20bcd80..1726b7d 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sg_package_config.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sg_package_config.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2016-03-08: initial version [Patrick Van der Veken] # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_hpux_sg_package_config { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2016-12-01" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SG_DAEMON="/usr/lbin/cmcld" # rubbish that cmgetconf outputs to STDOUT instead of STDERR @@ -68,7 +69,9 @@ do done # set local trap for cleanup +# shellcheck disable=SC2064 trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 # handle configuration file @@ -165,9 +168,6 @@ do done <${_PKG_CFG_FILE}.${_PKG_INSTANCE} done -# remove working files -rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/hp-ux/check_hpux_sg_package_status.sh b/sources/lib/platform/hp-ux/check_hpux_sg_package_status.sh index 6b4c4c2..0882ab2 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sg_package_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sg_package_status.sh @@ -26,6 +26,7 @@ # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] # @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_hpux_sg_package_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2017-07-05" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SG_DAEMON="/usr/lbin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- @@ -51,7 +52,6 @@ typeset _SG_ENTRY="" typeset _SG_MATCH="" typeset _SG_PACKAGE="" typeset _SG_CFG_PARAM="" -typeset _SG_RUN_PARAM="" typeset _SG_CFG_VALUE="" typeset _SG_RUN_VALUE="" diff --git a/sources/lib/platform/hp-ux/check_hpux_sg_qs_status.sh b/sources/lib/platform/hp-ux/check_hpux_sg_qs_status.sh index 07cf7cf..1422761 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sg_qs_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sg_qs_status.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2017-05-01: initial version [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -31,7 +32,7 @@ function check_hpux_sg_qs_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2017-05-01" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _QS_BIN="/usr/lbin/qsc" typeset _QS_AUTH_FILE="/etc/cmcluster/qs_authfile" @@ -44,7 +45,6 @@ typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 -typeset _RC=0 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -52,12 +52,12 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # check QS presence -if [[ ! -x ${_QS_BIN} ]] +if [[ ! -x ${_QS_BIN} ]] then warn "${_QS_BIN} is not installed here" return 1 diff --git a/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh b/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh index 457c39e..8728df0 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2017-04-01: initial version [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_hpux_sshd_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _SSHD_PID_FILE="/var/run/sshd/sshd.pid" -typeset _VERSION="2017-04-01" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -52,7 +53,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -64,7 +65,7 @@ then if [[ -n "${_SSHD_PID}" ]] then # get PID list without heading - (( $(UNIX95= ps -o pid= -p ${_SSHD_PID}| wc -l) == 0 )) && _STC=1 + (( $(UNIX95='' ps -o pid= -p ${_SSHD_PID}| wc -l) == 0 )) && _STC=1 else # not running _RC=1 diff --git a/sources/lib/platform/hp-ux/check_hpux_syslog.sh b/sources/lib/platform/hp-ux/check_hpux_syslog.sh index 9d30c8f..2a93f2b 100644 --- a/sources/lib/platform/hp-ux/check_hpux_syslog.sh +++ b/sources/lib/platform/hp-ux/check_hpux_syslog.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2016-06-20: initial version [Patrick Van der Veken] # @(#) 2017-05-18: do not update the state file with --no-log [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_hpux_syslog # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _STATE_FILE="${STATE_PERM_DIR}/discovered.syslog" -typeset _VERSION="2017-05-18" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -62,7 +63,9 @@ do done # set local trap for cleanup +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 # handle configuration file @@ -144,9 +147,6 @@ fi # handle results log_hc "$0" ${_STC} "${_MSG}" -# clean up temporary files -[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_burp_backup.sh b/sources/lib/platform/linux/check_linux_burp_backup.sh index 71a2bd8..1e6144c 100644 --- a/sources/lib/platform/linux/check_linux_burp_backup.sh +++ b/sources/lib/platform/linux/check_linux_burp_backup.sh @@ -27,6 +27,7 @@ # @(#) 2016-12-01: initial version [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-08-25: support for burp v2 [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -38,7 +39,7 @@ function check_linux_burp_backup typeset _BURP_SERVER_CONFIG_FILE="/etc/burp/burp-server.conf" typeset _BURP_CLIENT_CONFIG_FILE="/etc/burp/burp.conf" typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-08-25" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -156,7 +157,7 @@ do typeset _MIN_BACKUP_TIME="" typeset _STC=0 - if [[ -n "{_BURP_CLIENT}" ]] && [[ -n "{_BURP_WARNINGS}" ]] && [[ -n "${_BURP_AGE}" ]] + if [[ -n "${_BURP_CLIENT}" ]] && [[ -n "${_BURP_WARNINGS}" ]] && [[ -n "${_BURP_AGE}" ]] then # convert backup aging (UNIX seconds) case "${_BURP_AGE}" in diff --git a/sources/lib/platform/linux/check_linux_file_age.sh b/sources/lib/platform/linux/check_linux_file_age.sh index acf3561..228752c 100644 --- a/sources/lib/platform/linux/check_linux_file_age.sh +++ b/sources/lib/platform/linux/check_linux_file_age.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2013-05-27: initial version [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_linux_file_age { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -45,7 +46,7 @@ typeset _ARG="" typeset _MSG="" typeset _STC=0 typeset _ENTRY="" -typeset _AGE_CHECK=="" +typeset _AGE_CHECK="" typeset _FILE_PATH="" typeset _FILE_AGE="" typeset _FILE_NAME="" @@ -57,57 +58,57 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # handle configuration file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi - + # perform check grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _ENTRY do # field split _FILE_PATH=$(print "${_ENTRY%%;*}") _FILE_AGE=$(print "${_ENTRY##*;}") - + # split file/dir - _FILE_NAME=$(print "${_FILE_PATH##*/}") - _FILE_DIR=$(print "${_FILE_PATH%/*}") - + _FILE_NAME=$(print "${_FILE_PATH##*/}") + _FILE_DIR=$(print "${_FILE_PATH%/*}") + # check config - if [ \( -z "${_FILE_PATH}" \) -a \( -z "${_FILE_AGE}" \) ] + if [[ -z "${_FILE_PATH}" ]] && [[ -z "${_FILE_AGE}" ]] then warn "missing values in configuration file at ${_CONFIG_FILE}" - return 1 + return 1 fi case "${_FILE_AGE}" in +([0-9])*(.)*([0-9])) # numeric, OK ;; - *) + *) # not numeric warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}" - return 1 + return 1 ;; esac - + # perform check if [[ ! -r "${_FILE_PATH}" ]] then _MSG="unable to read or access requested file at ${_FILE_PATH}" - _STC=1 + _STC=1 else _AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -mmin -"${_FILE_AGE}" 2>/dev/null) if (( $? != 0 )) then warn "unable to execute file age test for ${_FILE_PATH}" - return 1 + return 1 fi if [[ -z "${_AGE_CHECK}" ]] then @@ -117,7 +118,7 @@ do _MSG="file age of ${_FILE_AGE} has not expired on ${_FILE_PATH}" fi fi - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 @@ -136,7 +137,7 @@ CONFIG : $3 with: ; PURPOSE : Checks whether given files have been changed in the last n minutes (requires GNU find) - + EOT return 0 diff --git a/sources/lib/platform/linux/check_linux_file_change.sh b/sources/lib/platform/linux/check_linux_file_change.sh index d20016a..37c2756 100644 --- a/sources/lib/platform/linux/check_linux_file_change.sh +++ b/sources/lib/platform/linux/check_linux_file_change.sh @@ -25,6 +25,7 @@ # @(#) HISTORY: # @(#) 2017-05-18: initial version [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_linux_file_change { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -45,7 +46,6 @@ typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 -typeset _STC_COUNT=0 typeset _DO_META_CHECK=0 typeset _CFG_STATE_FILE="" typeset _STATE_FILE="" @@ -66,11 +66,13 @@ typeset _TMP_EXCL_FILE="${TMP_DIR}/.$0.tmp_excl.$$" set -o noglob # no file globbing # set local trap for clean-up +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; [[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; @@ -134,6 +136,7 @@ fi # check state file & TMP_FILEs [[ -r ${_STATE_FILE} ]] || { + # shellcheck disable=SC2188 >${_STATE_FILE} (( $? > 0 )) && { warn "failed to create new state file at ${_STATE_FILE}" @@ -141,21 +144,25 @@ fi } log "created new state file at ${_STATE_FILE}" } +# shellcheck disable=SC2188 >${_TMP_INCL_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP_INCL_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP_EXCL_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP_EXCL_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP1_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP1_FILE}" return 1 } +# shellcheck disable=SC2188 >${_TMP2_FILE} (( $? > 0 )) && { warn "failed to create temporary file at ${_TMP2_FILE}" @@ -164,7 +171,7 @@ fi # build list of configured objects: inclusion grep -i '^incl:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _INCL_OBJECT + while IFS=':' read _ _INCL_OBJECT do # check for meta & globbing characters (*?[]{}|) if (( _DO_META_CHECK == 1 )) @@ -188,7 +195,7 @@ done # build list of configured objects: exclusion grep -i '^excl:' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=':' read _DUMMY _EXCL_OBJECT + while IFS=':' read _ _EXCL_OBJECT do # check for meta & globbing characters (*?[]{}|) if (( _DO_META_CHECK == 1 )) @@ -338,12 +345,6 @@ then } fi -# clean up temporary files -[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 -[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1 -[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1 -[[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_hpacucli.sh b/sources/lib/platform/linux/check_linux_hpacucli.sh index 75622c3..7342eec 100644 --- a/sources/lib/platform/linux/check_linux_hpacucli.sh +++ b/sources/lib/platform/linux/check_linux_hpacucli.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2013-09-09: initial version [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_linux_hpacucli { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -43,7 +44,6 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" -typeset _STC=0 typeset _STC_COUNT=0 typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$" typeset _HPACUCLI_BIN="" @@ -57,7 +57,9 @@ typeset _DO_ACU_LOGL=1 typeset _DO_CHECK=0 # set local trap for cleanup +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -262,9 +264,6 @@ then log_hc "$0" 0 "${_MSG}" fi -# remove temporary file -[[ -f ${_TMP_FILE} ]] & rm -f ${_TMP_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_hpasmcli.sh b/sources/lib/platform/linux/check_linux_hpasmcli.sh index 8402792..e73f1fe 100644 --- a/sources/lib/platform/linux/check_linux_hpasmcli.sh +++ b/sources/lib/platform/linux/check_linux_hpasmcli.sh @@ -25,6 +25,7 @@ # @(#) 2013-09-07: initial version [Patrick Van der Veken] # @(#) 2017-04-06: bugfix in temperature checking [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_linux_hpasmcli { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,7 +45,6 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" -typeset _STC=0 typeset _STC_COUNT=0 typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$" typeset _HPASMCLI_BIN="" @@ -62,7 +62,9 @@ typeset _THRES_VALUE="" typeset _TEMP_UNIT="" # set local trap for cleanup +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -273,9 +275,6 @@ then log_hc "$0" 0 "${_MSG}" fi -# remove temporary file -[[ -f ${_TMP_FILE} ]] & rm -f ${_TMP_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_hplog.sh b/sources/lib/platform/linux/check_linux_hplog.sh index 2c029d8..ae038f9 100644 --- a/sources/lib/platform/linux/check_linux_hplog.sh +++ b/sources/lib/platform/linux/check_linux_hplog.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2017-04-22: initial version [Patrick Van der Veken] # @(#) 2018-05-21: added dump_logs() & STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_linux_hplog # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _STATE_FILE="${STATE_PERM_DIR}/discovered.hplog" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -55,9 +56,11 @@ typeset _SEVERITY_ENTRY="" typeset _EVENT_ENTRY="" # set local trap for cleanup +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1 return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1 return 1" 1 2 3 15 @@ -159,10 +162,6 @@ else fi log_hc "$0" ${_STC} "${_MSG}" -# clean up temporary files -[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 -[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_hpssacli.sh b/sources/lib/platform/linux/check_linux_hpssacli.sh index 5fad0c2..abf36dc 100644 --- a/sources/lib/platform/linux/check_linux_hpssacli.sh +++ b/sources/lib/platform/linux/check_linux_hpssacli.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2016-04-01: initial version [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_linux_hpssacli { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -43,7 +44,6 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" -typeset _STC=0 typeset _STC_COUNT=0 typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$" typeset _HPSSACLI_BIN="" @@ -57,7 +57,9 @@ typeset _DO_SSA_LOGL=1 typeset _DO_CHECK=0 # set local trap for cleanup +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -262,9 +264,6 @@ then log_hc "$0" 0 "${_MSG}" fi -# remove temporary file -[[ -f ${_TMP_FILE} ]] & rm -f ${_TMP_FILE} >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_ntp_status.sh b/sources/lib/platform/linux/check_linux_ntp_status.sh index c101160..fe33b16 100644 --- a/sources/lib/platform/linux/check_linux_ntp_status.sh +++ b/sources/lib/platform/linux/check_linux_ntp_status.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2018-03-20: initial version [Patrick Van der Veken] # @(#) 2018-05-21: STDERR + other small fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #------------------------------------------------------------------------------ @@ -35,7 +36,7 @@ function check_linux_ntp_status typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _NTPD_INIT_SCRIPT="/etc/init.d/ntpd" typeset _NTPD_SYSTEMD_SERVICE="ntpd.service" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _NTPQ_BIN="/usr/sbin/ntpq" # ------------------------- CONFIGURATION ends here --------------------------- @@ -57,13 +58,13 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # handle config file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 @@ -78,6 +79,7 @@ fi #------------------------------------------------------------------------------ # check ntp service +# 1) try using the init ways linux_get_init case "${LINUX_INIT}" in 'systemd') @@ -105,6 +107,12 @@ case "${LINUX_INIT}" in ;; esac +# 2) try the pgrep way (note: old pgreps do not support '-c') +if (( _RC != 0 )) +then + (( $(pgrep -u root ntpd 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1 +fi + # evaluate results case ${_STC} in 0) @@ -122,7 +130,7 @@ log_hc "$0" ${_STC} "${_MSG}" #------------------------------------------------------------------------------ # check ntpq results _STC=0 -if [[ ! -x ${_NTPQ_BIN} ]] +if [[ ! -x ${_NTPQ_BIN} ]] then warn "${_NTPQ_BIN} is not installed here" return 1 @@ -159,16 +167,16 @@ then if (( $(awk -v c="${_CURR_OFFSET}" -v m="${_MAX_OFFSET}" 'BEGIN { print (c>m) }' 2>/dev/null) != 0 )) then _MSG="NTP offset of ${_CURR_OFFSET} is bigger than the configured maximum of ${_MAX_OFFSET}" - _STC=1 + _STC=1 else - _MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range" + _MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range" fi - log_hc "$0" ${_STC} "${_MSG}" + log_hc "$0" ${_STC} "${_MSG}" ;; - *) + *) # not numeric - warn "invalid offset value of ${_CURR_OFFSET} found for ${NTP_PEER}?" - return 1 + warn "invalid offset value of ${_CURR_OFFSET} found for ${_NTP_PEER}?" + return 1 ;; esac fi diff --git a/sources/lib/platform/linux/check_linux_process_limits.sh b/sources/lib/platform/linux/check_linux_process_limits.sh index d44e750..fa2bd7d 100644 --- a/sources/lib/platform/linux/check_linux_process_limits.sh +++ b/sources/lib/platform/linux/check_linux_process_limits.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2018-07-10: original version [Patrick Van der Veken] # @(#) 2018-07-12: better log_healthy handling [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_linux_process_limits { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-07-12" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -43,8 +44,6 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" -typeset _STC=0 -typeset _DUMMY="" typeset _LINE_COUNT=1 typeset _CFG_HEALTHY="" typeset _LOG_HEALTHY=0 @@ -66,7 +65,9 @@ typeset _USER_PS_PID="" typeset _USER_PS_COMM="" # set local trap for cleanup +# shellcheck disable=SC2064 trap "rm -f ${_INSTANCE_RUN_FILE}.* >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "rm -f ${_INSTANCE_RUN_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -114,7 +115,7 @@ fi # check PROCESS stanzas grep -i '^process' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=';' read _DUMMY _PROCESS _PROCESS_LIMIT _PROCESS_SOFT_THRESHOLD _PROCESS_HARD_THRESHOLD + while IFS=';' read _ _PROCESS _PROCESS_LIMIT _PROCESS_SOFT_THRESHOLD _PROCESS_HARD_THRESHOLD do # check for empties if [[ -z "${_PROCESS}" || -z "${_PROCESS_LIMIT}" ]] @@ -124,7 +125,7 @@ do fi if [[ -n "${_PROCESS_SOFT_THRESHOLD}" ]] then - $(data_is_numeric ${_PROCESS_SOFT_THRESHOLD}) + data_is_numeric ${_PROCESS_SOFT_THRESHOLD} if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -133,7 +134,7 @@ do fi if [[ -n "${_PROCESS_HARD_THRESHOLD}" ]] then - $(data_is_numeric ${_PROCESS_HARD_THRESHOLD}) + data_is_numeric ${_PROCESS_HARD_THRESHOLD} if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -178,7 +179,7 @@ done # check USER stanzas _LINE_COUNT=0 grep -i '^user' ${_CONFIG_FILE} 2>/dev/null |\ - while IFS=';' read _DUMMY _USER _USER_LIMIT _USER_SOFT_THRESHOLD _USER_HARD_THRESHOLD + while IFS=';' read _ _USER _USER_LIMIT _USER_SOFT_THRESHOLD _USER_HARD_THRESHOLD do # check for empties if [[ -z "${_USER}" || -z "${_USER_LIMIT}" ]] @@ -188,7 +189,7 @@ do fi if [[ -n "${_USER_SOFT_THRESHOLD}" ]] then - $(data_is_numeric ${_USER_SOFT_THRESHOLD}) + data_is_numeric ${_USER_SOFT_THRESHOLD} if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -197,7 +198,7 @@ do fi if [[ -n "${_USER_HARD_THRESHOLD}" ]] then - $(data_is_numeric ${_USER_HARD_THRESHOLD}) + data_is_numeric ${_USER_HARD_THRESHOLD} if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" diff --git a/sources/lib/platform/linux/check_linux_sg_cluster_config.sh b/sources/lib/platform/linux/check_linux_sg_cluster_config.sh index 8d160e2..d6a12c7 100644 --- a/sources/lib/platform/linux/check_linux_sg_cluster_config.sh +++ b/sources/lib/platform/linux/check_linux_sg_cluster_config.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2017-04-01: initial version [Patrick Van der Veken] # @(#) 2018-05-21: added dump_logs() & other fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_linux_sg_cluster_config { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" # rubbish that cmgetconf outputs to STDOUT instead of STDERR @@ -59,7 +60,9 @@ typeset _CLUSTER_PARAM="" typeset _CLUSTER_VALUE="" # set local trap for cleanup +# shellcheck disable=SC2064 trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -168,9 +171,6 @@ do done <${_CLUSTER_CFG_FILE}.${_CLUSTER_INSTANCE} done -# remove working files -rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_sg_cluster_status.sh b/sources/lib/platform/linux/check_linux_sg_cluster_status.sh index 0bbe16b..27afb28 100644 --- a/sources/lib/platform/linux/check_linux_sg_cluster_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_cluster_status.sh @@ -26,6 +26,7 @@ # @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_linux_sg_cluster_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- @@ -51,7 +52,6 @@ typeset _STC=0 typeset _SG_ENTRY="" typeset _SG_MATCH="" typeset _SG_CFG_PARAM="" -typeset _SG_RUN_PARAM="" typeset _SG_CFG_VALUE="" typeset _SG_RUN_VALUE="" @@ -61,20 +61,20 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # handle configuration file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi # check & get serviceguard status -if [[ ! -x ${_SG_DAEMON} ]] +if [[ ! -x ${_SG_DAEMON} ]] then warn "${_SG_DAEMON} is not installed here" return 1 @@ -103,14 +103,14 @@ do if [[ -n "${_SG_MATCH}" ]] then _SG_RUN_VALUE=$(print "${_SG_MATCH}" | cut -f2 -d'=' 2>/dev/null) # field 2 - + if [[ "${_SG_CFG_VALUE}" = "${_SG_RUN_VALUE}" ]] then _MSG="cluster parameter ${_SG_CFG_PARAM} has a correct value [${_SG_RUN_VALUE}]" _STC=0 else - _MSG="cluster parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]" - _STC=1 + _MSG="cluster parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]" + _STC=1 fi log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" else diff --git a/sources/lib/platform/linux/check_linux_sg_package_config.sh b/sources/lib/platform/linux/check_linux_sg_package_config.sh index 11bdee1..888ffc4 100644 --- a/sources/lib/platform/linux/check_linux_sg_package_config.sh +++ b/sources/lib/platform/linux/check_linux_sg_package_config.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2017-04-01: initial version [Patrick Van der Veken] # @(#) 2018-05-21: added dump_logs() & other fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_linux_sg_package_config { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" # rubbish that cmgetconf outputs to STDOUT instead of STDERR @@ -59,7 +60,9 @@ typeset _PKG_PARAM="" typeset _PKG_VALUE="" # set local trap for cleanup +# shellcheck disable=SC2064 trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 0" 0 +# shellcheck disable=SC2064 trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 # handle arguments (originally comma-separated) @@ -168,9 +171,6 @@ do done <${_PKG_CFG_FILE}.${_PKG_INSTANCE} done -# remove working files -rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1 - return 0 } diff --git a/sources/lib/platform/linux/check_linux_sg_package_status.sh b/sources/lib/platform/linux/check_linux_sg_package_status.sh index dfc8a1a..6f47492 100644 --- a/sources/lib/platform/linux/check_linux_sg_package_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_package_status.sh @@ -26,6 +26,7 @@ # @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_linux_sg_package_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- @@ -52,7 +53,6 @@ typeset _SG_ENTRY="" typeset _SG_MATCH="" typeset _SG_PACKAGE="" typeset _SG_CFG_PARAM="" -typeset _SG_RUN_PARAM="" typeset _SG_CFG_VALUE="" typeset _SG_RUN_VALUE="" @@ -62,20 +62,20 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # handle configuration file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" -if [[ ! -r ${_CONFIG_FILE} ]] +if [[ ! -r ${_CONFIG_FILE} ]] then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi # check & get serviceguard status -if [[ ! -x ${_SG_DAEMON} ]] +if [[ ! -x ${_SG_DAEMON} ]] then warn "${_SG_DAEMON} is not installed here" return 1 @@ -86,7 +86,7 @@ else log_hc "$0" 1 "${_MSG}" # dump debug info (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs - return 0 + return 0 } fi @@ -104,14 +104,14 @@ do if [[ -n "${_SG_MATCH}" ]] then _SG_RUN_VALUE=$(print "${_SG_MATCH}" | cut -f3- -d':' 2>/dev/null | cut -f2 -d'=' 2>/dev/null) # field3-,2 - + if [[ "${_SG_CFG_VALUE}" = "${_SG_RUN_VALUE}" ]] then _MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a correct value [${_SG_RUN_VALUE}]" _STC=0 else - _MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]" - _STC=1 + _MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]" + _STC=1 fi log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" else diff --git a/sources/lib/platform/linux/check_linux_sg_qs_status.sh b/sources/lib/platform/linux/check_linux_sg_qs_status.sh index 8f05b9d..c0f2110 100644 --- a/sources/lib/platform/linux/check_linux_sg_qs_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_qs_status.sh @@ -32,7 +32,7 @@ function check_linux_sg_qs_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _QS_BIN="/opt/qs/bin/qsc" typeset _QS_AUTH_FILE="/opt/qs/conf/qs_authfile" @@ -45,7 +45,6 @@ typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 -typeset _RC=0 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -53,12 +52,12 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # check QS presence -if [[ ! -x ${_QS_BIN} ]] +if [[ ! -x ${_QS_BIN} ]] then warn "${_QS_BIN} is not installed here" return 1 diff --git a/sources/lib/platform/linux/check_linux_vz_ct_status.sh b/sources/lib/platform/linux/check_linux_vz_ct_status.sh index 520e178..bfff7da 100644 --- a/sources/lib/platform/linux/check_linux_vz_ct_status.sh +++ b/sources/lib/platform/linux/check_linux_vz_ct_status.sh @@ -28,6 +28,7 @@ # @(#) 2018-04-30: fixes on variable names Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] +# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -38,7 +39,7 @@ function check_linux_vz_ct_status # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _VZLIST_BIN="/usr/sbin/vzlist" -typeset _VERSION="2018-05-21" # YYYY-MM-DD +typeset _VERSION="2018-10-28" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -66,7 +67,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -92,15 +93,15 @@ grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _CT_ENTRY do # field split _CT_ID="$(print ${_CT_ENTRY} | cut -f1 -d';')" - _CT_CFG_STATUS=$(data_lc $(print "${_CT_ENTRY}" | cut -f2 -d';' 2>/dev/null)) - _CT_CFG_BOOT=$(data_lc $(print "${_CT_ENTRY}" | cut -f3 -d';' 2>/dev/null)) - + _CT_CFG_STATUS=$(data_lc "$(print \"${_CT_ENTRY}\" | cut -f2 -d';' 2>/dev/null)") + _CT_CFG_BOOT=$(data_lc "$(print \"${_CT_ENTRY}\" | cut -f3 -d';' 2>/dev/null)") + # check config case "${_CT_ID}" in +([0-9])*(.)*([0-9])) # numeric, OK ;; - *) + *) # not numeric warn "invalid container ID '${_CT_ID}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" return 1 @@ -109,23 +110,23 @@ do case "${_CT_CFG_STATUS}" in running|stopped) ;; - *) + *) warn "invalid container status '${_CT_CFG_STATUS}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" - return 1 + return 1 ;; - esac + esac case "${_CT_CFG_BOOT}" in yes|no) ;; - *) + *) warn "invalid container boot value '${_CT_CFG_BOOT}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" - return 1 + return 1 ;; esac _LINE_COUNT=$(( _LINE_COUNT + 1 )) done - + # perform checks grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _CT_ENTRY do @@ -133,34 +134,34 @@ do _CT_ID="$(print ${_CT_ENTRY} | cut -f1 -d';')" _CT_CFG_STATUS="$(print ${_CT_ENTRY} | cut -f2 -d';')" _CT_CFG_BOOT="$(print ${_CT_ENTRY} | cut -f3 -d';')" - + # check run-time values _CT_MATCH=$(grep -i "^[[:space:]]*${_CT_ID}" ${HC_STDOUT_LOG} 2>/dev/null) if [[ -n "${_CT_MATCH}" ]] then # field split - _CT_RUN_STATUS=$(data_lc $(print "${_CT_MATCH}" | tr -s ' ' ';' 2>/dev/null | cut -f3 -d';' 2>/dev/null)) - _CT_RUN_BOOT=$(data_lc $(print "${_CT_MATCH}" | tr -s ' ' ';' 2>/dev/null | cut -f4 -d';' 2>/dev/null)) - + _CT_RUN_STATUS=$(data_lc "$(print \"${_CT_MATCH}\" | tr -s ' ' ';' 2>/dev/null | cut -f3 -d';' 2>/dev/null)") + _CT_RUN_BOOT=$(data_lc "$(print \"${_CT_MATCH}\" | tr -s ' ' ';' 2>/dev/null | cut -f4 -d';' 2>/dev/null)") + if [[ "${_CT_RUN_STATUS}" = "${_CT_CFG_STATUS}" ]] then _MSG="container ${_CT_ID} has a correct status [${_CT_RUN_STATUS}]" _STC=0 else - _MSG="container ${_CT_ID} has a wrong status [${_CT_RUN_STATUS}]" - _STC=1 + _MSG="container ${_CT_ID} has a wrong status [${_CT_RUN_STATUS}]" + _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" "${_CT_RUN_STATUS}" "${_CT_CFG_STATUS}" - + log_hc "$0" ${_STC} "${_MSG}" "${_CT_RUN_STATUS}" "${_CT_CFG_STATUS}" + if [[ "${_CT_RUN_BOOT}" = "${_CT_CFG_BOOT}" ]] then _MSG="container ${_CT_ID} has a correct boot flag [${_CT_RUN_BOOT}]" _STC=0 else - _MSG="container ${_CT_ID} has a wrong boot flag [${_CT_RUN_BOOT}]" - _STC=1 + _MSG="container ${_CT_ID} has a wrong boot flag [${_CT_RUN_BOOT}]" + _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" "${_CT_RUN_BOOT}" "${_CT_CFG_BOOT}" + log_hc "$0" ${_STC} "${_MSG}" "${_CT_RUN_BOOT}" "${_CT_CFG_BOOT}" else warn "could not determine status for container ${_CT_ID} from command output {${_VZLIST_BIN}}" _RC=1