From ba8f336945da98dac272dddd75a32622dda27060 Mon Sep 17 00:00:00 2001 From: patvdv Date: Sun, 4 Nov 2018 19:57:20 +0100 Subject: [PATCH] Code cleanup --- sources/bin/check_health.sh | 46 +++--- sources/lib/core/display_csv.sh | 2 +- sources/lib/core/display_init.sh | 2 +- sources/lib/core/display_json.sh | 2 +- sources/lib/core/display_terse.sh | 2 +- sources/lib/core/display_zenoss.sh | 2 +- sources/lib/core/include_core.sh | 136 +++++++++--------- sources/lib/core/include_data.sh | 68 ++++----- sources/lib/core/include_os.sh | 20 +-- sources/lib/core/notify_eif.sh | 4 +- sources/lib/core/notify_mail.sh | 2 +- sources/lib/core/notify_sms.sh | 2 +- sources/lib/core/report_std.sh | 12 +- sources/lib/platform/aix/check_aix_errpt.sh | 2 +- .../lib/platform/aix/check_aix_file_age.sh | 4 +- .../lib/platform/aix/check_aix_file_change.sh | 6 +- .../lib/platform/aix/check_aix_fs_mounts.sh | 8 +- sources/lib/platform/aix/check_aix_lppchk.sh | 4 +- sources/lib/platform/aix/check_aix_paths.sh | 6 +- .../platform/aix/check_aix_root_crontab.sh | 12 +- .../lib/platform/aix/check_aix_subsystems.sh | 10 +- .../lib/platform/aix/check_aix_sysbackup.sh | 32 ++--- .../lib/platform/aix/check_aix_topasrec.sh | 8 +- .../lib/platform/hp-ux/check_hpux_autopath.sh | 16 +-- .../platform/hp-ux/check_hpux_cdsf_cluster.sh | 4 +- .../platform/hp-ux/check_hpux_drd_status.sh | 4 +- .../lib/platform/hp-ux/check_hpux_file_age.sh | 8 +- .../platform/hp-ux/check_hpux_file_change.sh | 6 +- .../platform/hp-ux/check_hpux_fs_mounts.sh | 10 +- .../hp-ux/check_hpux_fs_mounts_options.sh | 2 +- .../platform/hp-ux/check_hpux_guid_status.sh | 4 +- .../hp-ux/check_hpux_hpvm_vpar_status.sh | 6 +- .../platform/hp-ux/check_hpux_httpd_status.sh | 4 +- .../hp-ux/check_hpux_ignite_backup.sh | 6 +- .../lib/platform/hp-ux/check_hpux_ioscan.sh | 6 +- .../hp-ux/check_hpux_kernel_params.sh | 6 +- .../platform/hp-ux/check_hpux_kernel_usage.sh | 8 +- .../lib/platform/hp-ux/check_hpux_lunpaths.sh | 12 +- .../platform/hp-ux/check_hpux_named_status.sh | 4 +- .../platform/hp-ux/check_hpux_ntp_status.sh | 2 +- .../platform/hp-ux/check_hpux_ovpa_status.sh | 2 +- .../hp-ux/check_hpux_patch_version.sh | 8 +- .../hp-ux/check_hpux_postfix_status.sh | 4 +- .../platform/hp-ux/check_hpux_root_crontab.sh | 14 +- .../platform/hp-ux/check_hpux_sfm_status.sh | 10 +- .../hp-ux/check_hpux_sg_cluster_config.sh | 2 +- .../hp-ux/check_hpux_sg_cluster_status.sh | 6 +- .../hp-ux/check_hpux_sg_package_config.sh | 2 +- .../hp-ux/check_hpux_sg_package_status.sh | 6 +- .../platform/hp-ux/check_hpux_sg_qs_status.sh | 2 +- .../platform/hp-ux/check_hpux_sshd_status.sh | 4 +- .../lib/platform/hp-ux/check_hpux_syslog.sh | 4 +- .../hp-ux/check_hpux_vg_minor_number.sh | 10 +- .../platform/linux/check_linux_burp_backup.sh | 4 +- .../platform/linux/check_linux_burp_status.sh | 6 +- .../platform/linux/check_linux_file_age.sh | 4 +- .../platform/linux/check_linux_file_change.sh | 6 +- .../platform/linux/check_linux_fs_mounts.sh | 8 +- .../platform/linux/check_linux_hpacucli.sh | 20 +-- .../platform/linux/check_linux_hpasmcli.sh | 22 +-- .../lib/platform/linux/check_linux_hplog.sh | 6 +- .../platform/linux/check_linux_hpssacli.sh | 20 +-- .../linux/check_linux_httpd_status.sh | 8 +- .../linux/check_linux_named_status.sh | 6 +- .../platform/linux/check_linux_ntp_status.sh | 8 +- .../linux/check_linux_postfix_status.sh | 8 +- .../linux/check_linux_process_limits.sh | 22 +-- .../linux/check_linux_root_crontab.sh | 14 +- .../linux/check_linux_samba_status.sh | 6 +- .../linux/check_linux_sg_cluster_config.sh | 4 +- .../linux/check_linux_sg_cluster_status.sh | 6 +- .../linux/check_linux_sg_package_config.sh | 4 +- .../linux/check_linux_sg_package_status.sh | 6 +- .../linux/check_linux_sg_qs_status.sh | 2 +- .../linux/check_linux_shorewall_status.sh | 6 +- .../platform/linux/check_linux_sshd_status.sh | 6 +- .../linux/check_linux_vz_ct_status.sh | 6 +- .../linux/check_linux_winbind_status.sh | 6 +- 78 files changed, 395 insertions(+), 393 deletions(-) diff --git a/sources/bin/check_health.sh b/sources/bin/check_health.sh index 2458d10..60c7015 100644 --- a/sources/bin/check_health.sh +++ b/sources/bin/check_health.sh @@ -58,7 +58,7 @@ typeset -r SCRIPT_DIR=$(dirname "$0") 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 +typeset -r HC_MSG_FILE="${TMP_DIR}/.${SCRIPT_NAME}.hc.msg.$$" # plugin messages file # shellcheck disable=SC2034 typeset -r LOG_SEP="|" # single character only # shellcheck disable=SC2034 @@ -155,7 +155,7 @@ set +o bgnice # REQUIRES: n/a function build_fpath { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset FPATH_DIR="" # do not use a while-do loop here because mksh/pdksh does not pass updated @@ -181,7 +181,7 @@ return 0 # REQUIRES: n/a function check_config { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" # EXEC_USER if [[ -z "${EXEC_USER}" ]] @@ -224,7 +224,7 @@ return 0 # REQUIRES: n/a function check_core { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" # check and include core helper libs if [[ -r ${FPATH_PARENT}/core/include_core.sh && -h ${FPATH_PARENT}/core/include_core ]] @@ -290,8 +290,8 @@ return 0 # REQUIRES: n/a function check_lock_dir { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" -if (( ARG_LOCK != 0 )) +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +if (( ARG_LOCK > 0 )) then mkdir ${LOCK_DIR} >/dev/null || { print -u2 "ERROR: unable to acquire lock ${LOCK_DIR}" @@ -306,7 +306,7 @@ then } print $$ >${LOCK_DIR}/.pid else - (( ARG_DEBUG != 0 )) && print "DEBUG: locking has been disabled" + (( ARG_DEBUG > 0 )) && print "DEBUG: locking has been disabled" fi return 0 @@ -320,7 +320,7 @@ return 0 # REQUIRES: n/a function check_params { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" # --debug-level if (( ARG_DEBUG_LEVEL > 2 )) @@ -345,7 +345,7 @@ then fi fi # --flip-rc -if (( ARG_FLIP_RC != 0 )) +if (( ARG_FLIP_RC > 0 )) then # do not allow flip RC for multiple checks if [[ "${ARG_HC}" = *,* ]] # use =, ksh88 @@ -435,7 +435,7 @@ then exit 1 fi # check log location -if (( ARG_LOG != 0 )) +if (( ARG_LOG > 0 )) then if [[ ! -d "${LOG_DIR}" ]] || [[ ! -w "${LOG_DIR}" ]] then @@ -455,13 +455,13 @@ return 0 # REQUIRES: $OS_NAME function check_platform { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset HC_PLATFORM="${1}" typeset RC=0 if [[ "${OS_NAME}" != @(${HC_PLATFORM}) ]] then - (( ARG_DEBUG != 0 )) && warn "platform ${HC_PLATFORM} does not match ${OS_NAME}" + (( ARG_DEBUG > 0 )) && warn "platform ${HC_PLATFORM} does not match ${OS_NAME}" RC=1 fi @@ -476,7 +476,7 @@ return ${RC} # REQUIRES: n/a function check_user { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset WHOAMI="" # avoid sub-shell for mksh/pdksh @@ -501,15 +501,15 @@ function check_shell { case "${KSH_VERSION}" in *MIRBSD*|*PD*|*LEGACY*) - (( ARG_DEBUG != 0 )) && debug "running ksh: ${KSH_VERSION}" + (( ARG_DEBUG > 0 )) && debug "running ksh: ${KSH_VERSION}" ;; *) if [[ -z "${ERRNO}" ]] then # shellcheck disable=SC2154 - (( ARG_DEBUG != 0 )) && print "running ksh: ${.sh.version}" + (( ARG_DEBUG > 0 )) && print "running ksh: ${.sh.version}" else - (( ARG_DEBUG != 0 )) && print "running ksh: ksh88 or older" + (( ARG_DEBUG > 0 )) && print "running ksh: ksh88 or older" fi ;; esac @@ -607,7 +607,7 @@ return 0 # REQUIRES: log() function do_cleanup { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" log "performing cleanup ..." # remove temporary files @@ -637,7 +637,7 @@ return 0 # REQUIRES: n/a function fix_symlinks { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset FDIR="" typeset FFILE="" typeset FSYML="" @@ -686,7 +686,7 @@ return 0 # REQUIRES: die() function read_config { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" if [[ -z "${CONFIG_FILE}" ]] || [[ -z "${CONFIG_FILE}" ]] then @@ -1052,7 +1052,7 @@ check_user trap 'do_cleanup; exit 1' HUP INT QUIT TERM # set debugging options -if (( ARG_DEBUG != 0 )) +if (( ARG_DEBUG > 0 )) then case ${ARG_DEBUG_LEVEL} in 0) @@ -1068,10 +1068,11 @@ then DEBUG_OPTS='-vx' ;; esac +set "${DEBUG_OPTS}" fi log "*** start of ${SCRIPT_NAME} [${CMD_LINE}] ***" -(( ARG_LOG != 0 )) && log "logging takes places in ${LOG_FILE}" +(( ARG_LOG > 0 )) && log "logging takes places in ${LOG_FILE}" # check/create lock file & write PID file (only for --run/--archive/--fix-logs) (( ARG_ACTION == 4 || ARG_ACTION == 11 || ARG_ACTION == 12 )) && check_lock_dir @@ -1154,6 +1155,7 @@ case ${ARG_ACTION} in print "${ARG_HC}" | tr ',' '\n' | grep -v '^$' | while read -r HC_RUN do # re-initialize messages stash (log of failed checks) + # shellcheck disable=SC2034 HC_MSG_VAR="" : >${HC_MSG_FILE} 2>/dev/null if (( $? > 0 )) @@ -1261,7 +1263,7 @@ case ${ARG_ACTION} in EXIT_CODE=${RUN_RC} kill -s TERM ${SLEEP_PID} >/dev/null 2>&1 # process return codes - if (( RUN_RC != 0 )) + if (( RUN_RC > 0 )) then # call for display_init with extra code 'ERROR' if (( DO_DISPLAY_INIT == 1 )) diff --git a/sources/lib/core/display_csv.sh b/sources/lib/core/display_csv.sh index 6c04809..b6cbc9c 100644 --- a/sources/lib/core/display_csv.sh +++ b/sources/lib/core/display_csv.sh @@ -36,7 +36,7 @@ typeset _DISPLAY_SEP=";" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" diff --git a/sources/lib/core/display_init.sh b/sources/lib/core/display_init.sh index b63c363..7a2f79c 100644 --- a/sources/lib/core/display_init.sh +++ b/sources/lib/core/display_init.sh @@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" diff --git a/sources/lib/core/display_json.sh b/sources/lib/core/display_json.sh index c928408..4407f01 100644 --- a/sources/lib/core/display_json.sh +++ b/sources/lib/core/display_json.sh @@ -35,7 +35,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" diff --git a/sources/lib/core/display_terse.sh b/sources/lib/core/display_terse.sh index c88196c..7fe9a12 100644 --- a/sources/lib/core/display_terse.sh +++ b/sources/lib/core/display_terse.sh @@ -35,7 +35,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" diff --git a/sources/lib/core/display_zenoss.sh b/sources/lib/core/display_zenoss.sh index 1af688e..be31f2b 100644 --- a/sources/lib/core/display_zenoss.sh +++ b/sources/lib/core/display_zenoss.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DISPLAY_HC="$1" diff --git a/sources/lib/core/include_core.sh b/sources/lib/core/include_core.sh index 09b0915..959815b 100644 --- a/sources/lib/core/include_core.sh +++ b/sources/lib/core/include_core.sh @@ -31,7 +31,7 @@ # REQUIRES: ${HC_LOG} function archive_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset HC_NAME="${1}" typeset ARCHIVE_FILE="" typeset ARCHIVE_RC=0 @@ -108,7 +108,7 @@ return ${ARCHIVE_RC} # REQUIRES: n/a function count_log_errors { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset LOG_STASH="${1}" typeset ERROR_COUNT=0 @@ -152,13 +152,13 @@ return 0 # REQUIRES: n/a function die { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset NOW="$(date '+%d-%h-%Y %H:%M:%S')" typeset LOG_LINE="" if [[ -n "${1}" ]] then - if (( ARG_LOG != 0 )) + if (( ARG_LOG > 0 )) then print - "$*" | while read -r LOG_LINE do @@ -186,7 +186,7 @@ exit 1 # REQUIRES: die() function discover_core { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset NOTIFY_OPTS="" # init global flags for core plugins (no typeset!) @@ -236,75 +236,75 @@ do case "${FFILE}" in *display_csv.sh) HAS_DISPLAY_CSV=1 - (( ARG_DEBUG != 0 )) && debug "display_csv plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_csv plugin is available" ;; *display_init.sh) HAS_DISPLAY_INIT=1 - (( ARG_DEBUG != 0 )) && debug "display_init plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_init plugin is available" ;; *display_json.sh) HAS_DISPLAY_JSON=1 - (( ARG_DEBUG != 0 )) && debug "display_json plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_json plugin is available" ;; *display_terse.sh) HAS_DISPLAY_TERSE=1 - (( ARG_DEBUG != 0 )) && debug "display_terse plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_terse plugin is available" ;; *display_zenoss.sh) HAS_DISPLAY_ZENOSS=1 - (( ARG_DEBUG != 0 )) && debug "display_zenoss plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_zenoss plugin is available" ;; *display_custom1.sh) HAS_DISPLAY_CUSTOM1=1 - (( ARG_DEBUG != 0 )) && debug "display_custom1 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom1 plugin is available" ;; *display_custom2.sh) HAS_DISPLAY_CUSTOM2=1 - (( ARG_DEBUG != 0 )) && debug "display_custom2 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom2 plugin is available" ;; *display_custom3.sh) HAS_DISPLAY_CUSTOM3=1 - (( ARG_DEBUG != 0 )) && debug "display_custom3 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom3 plugin is available" ;; *display_custom4.sh) HAS_DISPLAY_CUSTOM4=1 - (( ARG_DEBUG != 0 )) && debug "display_custom4 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom4 plugin is available" ;; *display_custom5.sh) HAS_DISPLAY_CUSTOM5=1 - (( ARG_DEBUG != 0 )) && debug "display_custom5 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom5 plugin is available" ;; *display_custom6.sh) HAS_DISPLAY_CUSTOM6=1 - (( ARG_DEBUG != 0 )) && debug "display_custom6 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom6 plugin is available" ;; *display_custom7.sh) HAS_DISPLAY_CUSTOM7=1 - (( ARG_DEBUG != 0 )) && debug "display_custom7 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom7 plugin is available" ;; *display_custom8.sh) HAS_DISPLAY_CUSTOM8=1 - (( ARG_DEBUG != 0 )) && debug "display_custom8 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom8 plugin is available" ;; *display_custom9.sh) HAS_DISPLAY_CUSTOM9=1 - (( ARG_DEBUG != 0 )) && debug "display_custom9 plugin is available" + (( ARG_DEBUG > 0 )) && debug "display_custom9 plugin is available" ;; *notify_mail.sh) HAS_NOTIFY_MAIL=1 - (( ARG_DEBUG != 0 )) && debug "notify_mail plugin is available" + (( ARG_DEBUG > 0 )) && debug "notify_mail plugin is available" ;; *notify_sms.sh) HAS_NOTIFY_SMS=1 - (( ARG_DEBUG != 0 )) && debug "notify_sms plugin is available" + (( ARG_DEBUG > 0 )) && debug "notify_sms plugin is available" ;; *notify_eif.sh) HAS_NOTIFY_EIF=1 - (( ARG_DEBUG != 0 )) && debug "notify_eif plugin is available" + (( ARG_DEBUG > 0 )) && debug "notify_eif plugin is available" ;; *report_std.sh) HAS_REPORT_STD=1 - (( ARG_DEBUG != 0 )) && debug "report_std plugin is available" + (( ARG_DEBUG > 0 )) && debug "report_std plugin is available" ;; esac done @@ -489,7 +489,7 @@ if [[ -n "${ARG_MAIL_TO}" ]] && (( DO_NOTIFY_MAIL == 0 )) then die "you cannot specify '--mail-to' without '--notify=mail'" fi -if (( DO_NOTIFY_MAIL != 0 )) && [[ -z "${ARG_MAIL_TO}" ]] +if (( DO_NOTIFY_MAIL > 0 )) && [[ -z "${ARG_MAIL_TO}" ]] then die "you cannot specify '--notify=mail' without '--mail-to'" fi @@ -502,64 +502,64 @@ if [[ -n "${ARG_SMS_PROVIDER}" ]] && (( DO_NOTIFY_SMS == 0 )) then die "you cannot specify '--sms-provider' without '--notify=sms'" fi -if (( DO_NOTIFY_SMS != 0 )) && [[ -z "${ARG_SMS_TO}" ]] +if (( DO_NOTIFY_SMS > 0 )) && [[ -z "${ARG_SMS_TO}" ]] then die "you cannot specify '--notify=sms' without '--sms-to'" fi -if (( DO_NOTIFY_SMS != 0 )) && [[ -z "${ARG_SMS_PROVIDER}" ]] +if (( DO_NOTIFY_SMS > 0 )) && [[ -z "${ARG_SMS_PROVIDER}" ]] then die "you cannot specify '--notify=sms' without '--sms-provider'" fi # --report/--detail/--id/--reverse/--last/--today/--with-history -if (( DO_REPORT_STD != 0 )) +if (( DO_REPORT_STD > 0 )) then - if (( ARG_DETAIL != 0 )) && [[ -z "${ARG_FAIL_ID}" ]] + if (( ARG_DETAIL > 0 )) && [[ -z "${ARG_FAIL_ID}" ]] then die "you must specify an unique value for '--id' when using '--detail'" fi - if (( ARG_LAST != 0 )) && (( ARG_TODAY != 0 )) + if (( ARG_LAST > 0 )) && (( ARG_TODAY > 0 )) then die "you cannot specify '--last' with '--today'" fi - if (( ARG_LAST != 0 )) && (( ARG_DETAIL != 0 )) + if (( ARG_LAST > 0 )) && (( ARG_DETAIL > 0 )) then die "you cannot specify '--last' with '--detail'" fi - if (( ARG_LAST != 0 )) && (( ARG_REVERSE != 0 )) + if (( ARG_LAST > 0 )) && (( ARG_REVERSE > 0 )) then die "you cannot specify '--last' with '--detail'" fi - if (( ARG_LAST != 0 )) && [[ -n "${ARG_FAIL_ID}" ]] + if (( ARG_LAST > 0 )) && [[ -n "${ARG_FAIL_ID}" ]] then die "you cannot specify '--last' with '--id'" fi - if (( ARG_TODAY != 0 )) && (( ARG_DETAIL != 0 )) + if (( ARG_TODAY > 0 )) && (( ARG_DETAIL > 0 )) then die "you cannot specify '--today' with '--detail'" fi - if (( ARG_TODAY != 0 )) && (( ARG_REVERSE != 0 )) + if (( ARG_TODAY > 0 )) && (( ARG_REVERSE > 0 )) then die "you cannot specify '--today' with '--detail'" fi - if (( ARG_TODAY != 0 )) && [[ -n "${ARG_FAIL_ID}" ]] + if (( ARG_TODAY > 0 )) && [[ -n "${ARG_FAIL_ID}" ]] then die "you cannot specify '--today' with '--id'" fi # switch on history for --last & --today - if (( ARG_LAST != 0 )) || (( ARG_TODAY != 0 )) + if (( ARG_LAST > 0 )) || (( ARG_TODAY > 0 )) then ARG_HISTORY=1 fi fi -if (( DO_REPORT_STD == 0 )) && (( ARG_LAST != 0 )) +if (( DO_REPORT_STD == 0 )) && (( ARG_LAST > 0 )) then die "you cannot specify '--last' without '--report'" fi -if (( DO_REPORT_STD == 0 )) && (( ARG_REVERSE != 0 )) +if (( DO_REPORT_STD == 0 )) && (( ARG_REVERSE > 0 )) then die "you cannot specify '--reverse' without '--report'" fi -if (( DO_REPORT_STD == 0 )) && (( ARG_DETAIL != 0 )) +if (( DO_REPORT_STD == 0 )) && (( ARG_DETAIL > 0 )) then die "you cannot specify '--detail' without '--report'" fi @@ -595,7 +595,7 @@ return 0 # REQUIRES: n/a function exists_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset EXISTS_HC="${1}" typeset FDIR="" typeset EXISTS_RC=0 @@ -622,7 +622,7 @@ return ${EXISTS_RC} # REQUIRES: n/a function find_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset FIND_HC="${1}" typeset FDIR="" @@ -645,7 +645,7 @@ return 0 # the rewrite operation!! function fix_logs { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset FIX_FILE="" typeset FIX_RC=0 typeset LOG_STASH="" @@ -656,7 +656,7 @@ typeset TMP_COUNT=0 typeset SAVE_TMP_FILE="${TMP_DIR}/.$0.save.log.$$" typeset TMP_FILE="${TMP_DIR}/.$0.tmp.log.$$" -if (( ARG_HISTORY != 0 )) +if (( ARG_HISTORY > 0 )) then set +f # file globbing must be on LOG_STASH="${HC_LOG} ${ARCHIVE_DIR}/hc.*.log" @@ -812,7 +812,7 @@ return ${FIX_RC} # REQUIRES: die(), display_*(), notify_*(), warn() function handle_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset HC_NAME="${1}" typeset HC_STDOUT_LOG_SHORT="" typeset HC_STDERR_LOG_SHORT="" @@ -831,7 +831,7 @@ then HC_MSG_VAR=$(<${HC_MSG_FILE}) # DEBUG: dump TMP file - if (( ARG_DEBUG != 0 )) + if (( ARG_DEBUG > 0 )) then debug "begin dumping plugin messages file (${HC_MSG_FILE})" print "${HC_MSG_VAR}" @@ -840,7 +840,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}" + (( 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" else # nothing to do @@ -978,7 +978,7 @@ then fi else # default STDOUT - if (( ARG_VERBOSE != 0 )) + if (( ARG_VERBOSE > 0 )) then print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read ONE_MSG_STC ONE_MSG_TIME ONE_MSG_TEXT ONE_MSG_CUR_VAL ONE_MSG_EXP_VAL do @@ -1008,7 +1008,7 @@ then fi fi printf "%s" "INFO: ${HC_NAME} [STC=${ONE_MSG_STC}]: ${ONE_MSG_TEXT}" - if (( ONE_MSG_STC != 0 )) + if (( ONE_MSG_STC > 0 )) then printf " %s\n" "[FAIL_ID=${HC_FAIL_ID}]" else @@ -1020,7 +1020,7 @@ then fi # log & notify routines -if (( ARG_LOG != 0 )) +if (( ARG_LOG > 0 )) then # log routine (combined STC=0 or <>0) print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read ONE_MSG_STC ONE_MSG_TIME ONE_MSG_TEXT ONE_MSG_CUR_VAL ONE_MSG_EXP_VAL @@ -1143,7 +1143,7 @@ fi # REQUIRES: warn() function handle_timeout { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( 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 @@ -1160,7 +1160,7 @@ return 0 # REQUIRES: die() function init_check_host { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset HC_EXEC="" typeset DISPLAY_STYLE="" @@ -1290,20 +1290,20 @@ return 0 # REQUIRES: die() function init_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset HC_PLATFORMS="${2}" typeset HC_VERSION="${3}" typeset HC_OK=0 # check platform (don't use a pattern comparison here (~! mksh/pdksh)) HC_OK=$(print "${HC_PLATFORMS}" | grep -c "${OS_NAME}" 2>/dev/null) -(( HC_OK != 0 )) || die "may only run on platform(s): ${HC_PLATFORMS}" +(( HC_OK > 0 )) || die "may only run on platform(s): ${HC_PLATFORMS}" # check version of HC plugin case "${HC_VERSION}" in [0-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]) # OK - (( ARG_DEBUG != 0 )) && debug "HC plugin ${1} has version ${HC_VERSION}" + (( ARG_DEBUG > 0 )) && debug "HC plugin ${1} has version ${HC_VERSION}" ;; *) die "version of the HC plugin ${1} is not in YYYY-MM-DD format (${HC_VERSION})" @@ -1321,7 +1321,7 @@ return 0 # REQUIRES: n/a function is_scheduled { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset CRON_HC="${1}" typeset CRON_COUNT=0 typeset CRON_SYS_LOCATIONS='/etc/crontab /etc/cron.d/*' @@ -1359,7 +1359,7 @@ return ${CRON_COUNT} # REQUIRES: n/a function list_core { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset FACTION="${1}" typeset FCONFIG="" typeset FDIR="" @@ -1392,7 +1392,7 @@ do FVERSION=$(grep '^typeset _VERSION=' "${FFILE}" 2>&1 | tr -d '\"' | tr -d ' \t' | cut -f1 -d'#' | cut -f2 -d'=') # look for configuration file string HAS_FCONFIG=$(grep -c '^typeset _CONFIG_FILE=' "${FFILE}" 2>&1) - if (( HAS_FCONFIG != 0 )) + if (( HAS_FCONFIG > 0 )) then FCONFIG="Yes" else @@ -1450,7 +1450,7 @@ return 0 # REQUIRES: is_scheduled() function list_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset FACTION="${1}" typeset FNEEDLE="${2}" typeset FCONFIG="" @@ -1492,7 +1492,7 @@ do FVERSION=$(grep '^typeset _VERSION=' "${FFILE}" 2>&1 | tr -d '\"' | tr -d ' \t' | cut -f1 -d'#' | cut -f2 -d'=') # look for configuration file string HAS_FCONFIG=$(grep -c '^typeset _CONFIG_FILE=' "${FFILE}" 2>&1) - if (( HAS_FCONFIG != 0 )) + if (( HAS_FCONFIG > 0 )) then FCONFIG="Yes" # *.conf.dist first @@ -1619,20 +1619,20 @@ return 0 # REQUIRES: n/a function log { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset NOW="$(date '+%d-%h-%Y %H:%M:%S')" typeset LOG_LINE="" if [[ -n "${1}" ]] then - if (( ARG_LOG != 0 )) + if (( ARG_LOG > 0 )) then print - "$*" | while read -r LOG_LINE do print "${NOW}: INFO: [$$]:" "${LOG_LINE}" >>${LOG_FILE} done fi - if (( ARG_VERBOSE != 0 )) + if (( ARG_VERBOSE > 0 )) then print - "$*" | while read -r LOG_LINE do @@ -1654,7 +1654,7 @@ return 0 # REQUIRES: n/a function log_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset HC_NAME="${1}" typeset HC_STC=${2} typeset HC_NOW="$(date '+%Y-%m-%d %H:%M:%S' 2>/dev/null)" @@ -1708,7 +1708,7 @@ return 0 # REQUIRES: n/a function show_statistics { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _ARCHIVE_FILE="" # current events @@ -1806,7 +1806,7 @@ return 0 # REQUIRES: n/a function stat_hc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset STAT_HC="${1}" typeset STAT_RC=1 # default: enabled @@ -1823,20 +1823,20 @@ return ${STAT_RC} # REQUIRES: n/a function warn { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset NOW="$(date '+%d-%h-%Y %H:%M:%S')" typeset LOG_LINE="" if [[ -n "${1}" ]] then - if (( ARG_LOG != 0 )) + if (( ARG_LOG > 0 )) then print - "$*" | while read -r LOG_LINE do print "${NOW}: WARN: [$$]:" "${LOG_LINE}" >>${LOG_FILE} done fi - if (( ARG_VERBOSE != 0 )) + if (( ARG_VERBOSE > 0 )) then print - "$*" | while read -r LOG_LINE do diff --git a/sources/lib/core/include_data.sh b/sources/lib/core/include_data.sh index 46240cb..a54b2c7 100644 --- a/sources/lib/core/include_data.sh +++ b/sources/lib/core/include_data.sh @@ -32,7 +32,7 @@ # REQUIRES: n/a function data_get_lvalue_from_config { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _PARAMETER="${1}" typeset _LVALUE="" typeset _RC=0 @@ -58,7 +58,7 @@ return ${_RC} # REQUIRES: n/a function data_chop { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1%?}" 2>/dev/null @@ -74,7 +74,7 @@ return 0 # REQUIRES: n/a function data_contains_string { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _HAYSTACK="${1}" typeset _NEEDLE="${2}" @@ -94,7 +94,7 @@ return ${_RC} # REQUIRES: n/a function data_magic_quote { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _SEP="${2:-%}" typeset _MAGIC="${MAGIC:-!_!}" @@ -112,7 +112,7 @@ return 0 # REQUIRES: n/a function data_magic_unquote { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _SEP="${2:-%}" typeset _MAGIC="${MAGIC:-!_!}" @@ -130,7 +130,7 @@ return 0 # REQUIRES: n/a function data_escape_csv { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | sed 's#\([;]\)#\\\1#g' 2>/dev/null @@ -146,7 +146,7 @@ return 0 # REQUIRES: n/a function data_escape_json { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _NEEDLE='[\"]' print -R "${1}" 2>/dev/null | sed 's#\(["\]\)#\\\1#g' 2>/dev/null @@ -163,7 +163,7 @@ return 0 # REQUIRES: n/a function data_decomma { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr -d ',' 2>/dev/null @@ -179,7 +179,7 @@ return 0 # REQUIRES: n/a function data_decomma_last { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1%*,}" 2>/dev/null @@ -195,7 +195,7 @@ return 0 # REQUIRES: n/a function data_decomma_first { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1#,*}" 2>/dev/null @@ -211,7 +211,7 @@ return 0 # REQUIRES: n/a function data_dequote { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr -d '\"' 2>/dev/null | tr -d "'" 2>/dev/null @@ -227,7 +227,7 @@ return 0 # REQUIRES: n/a function data_comma2space { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr ',' ' ' 2>/dev/null @@ -243,7 +243,7 @@ return 0 # REQUIRES: n/a function data_comma2pipe { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr ',' '|' 2>/dev/null @@ -259,7 +259,7 @@ return 0 # REQUIRES: n/a function data_comma2newline { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr ',' '\n' 2>/dev/null @@ -275,7 +275,7 @@ return 0 # REQUIRES: n/a function data_newline2comma { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr '\n' ',' 2>/dev/null @@ -291,7 +291,7 @@ return 0 # REQUIRES: n/a function data_newline2hash { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr '\r' '#' 2>/dev/null @@ -307,7 +307,7 @@ return 0 # REQUIRES: n/a function data_space2comma { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr -s ' ' 2>/dev/null | tr ' ' ',' 2>/dev/null @@ -323,7 +323,7 @@ return 0 # REQUIRES: n/a function data_pipe2comma { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr -s '|' 2>/dev/null | tr ' '|',' 2>/dev/null @@ -339,7 +339,7 @@ return 0 # REQUIRES: n/a function data_space2hash { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr -s ' ' 2>/dev/null | tr ' ' '#' 2>/dev/null @@ -355,7 +355,7 @@ return 0 # REQUIRES: n/a function data_strip_newline { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr -d '\n' 2>/dev/null | tr -d '\r' 2>/dev/null @@ -371,7 +371,7 @@ return 0 # REQUIRES: n/a function data_strip_space { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr -d '[:space:]' 2>/dev/null @@ -387,7 +387,7 @@ return 0 # REQUIRES: n/a function data_strip_leading_space { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" | sed 's/^[[:blank:]]*//' 2>/dev/null @@ -403,7 +403,7 @@ return 0 # REQUIRES: n/a function data_strip_trailing_space { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" | sed 's/[[:blank:]]*$//' 2>/dev/null @@ -419,7 +419,7 @@ return 0 # REQUIRES: n/a function data_strip_outer_space { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//' 2>/dev/null @@ -435,7 +435,7 @@ return 0 # REQUIRES: n/a function data_lc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr '[:upper:]' '[:lower:]' 2>/dev/null @@ -451,7 +451,7 @@ return 0 # REQUIRES: n/a function data_uc { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" print -R "${1}" 2>/dev/null | tr '[:lower:]' '[:upper:]' 2>/dev/null @@ -467,7 +467,7 @@ return 0 # REQUIRES: n/a function data_is_numeric { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" case "${1}" in +([0-9])*(.)*([0-9])) @@ -492,7 +492,7 @@ return 0 # REFERENCE: added from http://www.shelldorado.com/scripts/cmds/urlencode function data_encode_url { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _EncodeEOL=0 LANG=C awk ' @@ -546,7 +546,7 @@ return 0 # REFERENCE: https://raw.githubusercontent.com/dualbus/tutorial_nmap/master/iprange function data_dot2ip { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _DOT="${1}" typeset _IP=0 typeset _OLD_IFS="${IFS}" @@ -575,7 +575,7 @@ return 0 # REFERENCE: https://raw.githubusercontent.com/dualbus/tutorial_nmap/master/iprange function data_ip2dot { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _IP="${1}" typeset _W="" typeset _X="" @@ -602,7 +602,7 @@ return 0 # REFERENCE: https://raw.githubusercontent.com/dualbus/tutorial_nmap/master/iprange function data_bits2mask { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _BITS=${1} typeset _MAX=4294967296 typeset _OFFSET=0 @@ -658,7 +658,7 @@ return 0 # REFERENCE: https://raw.githubusercontent.com/dualbus/tutorial_nmap/master/iprange function data_mask2bits { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _MASK="${1}" typeset -i _I=32 @@ -679,7 +679,7 @@ return 0 # REQUIRES: n/a function data_is_ipv4 { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _IP="${1}" typeset _RC=0 @@ -704,7 +704,7 @@ return ${_RC} # REFERENCE: https://groups.google.com/forum/#!topic/comp.unix.shell/aPoPzFWP2Og function data_date2epoch { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _YEAR="${1}" typeset _MONTH="${2}" typeset _DAY="${3}" diff --git a/sources/lib/core/include_os.sh b/sources/lib/core/include_os.sh index 6180f5e..e81f268 100644 --- a/sources/lib/core/include_os.sh +++ b/sources/lib/core/include_os.sh @@ -31,11 +31,11 @@ # REQUIRES: n/a function linux_get_distro { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" # linux only check_platform 'Linux' || { - (( ARG_DEBUG != 0 )) && debug "may only run on platform(s): Linux" + (( ARG_DEBUG > 0 )) && debug "may only run on platform(s): Linux" return 1 } @@ -86,11 +86,11 @@ return 0 # REQUIRES: n/a function linux_get_init { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" # linux only check_platform 'Linux' || { - (( ARG_DEBUG != 0 )) && debug "may only run on platform(s): Linux" + (( ARG_DEBUG > 0 )) && debug "may only run on platform(s): Linux" return 1 } @@ -117,7 +117,7 @@ return 0 # REQUIRES: n/a function linux_has_crm { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _CRM_BIN="" typeset _HAS_CRM=0 @@ -134,7 +134,7 @@ then crm status >/dev/null 2>/dev/null (( $? == 0 )) && _HAS_CRM=1 else - (( ARG_DEBUG != 0 )) && debug "corosync (crm) is not active here" + (( ARG_DEBUG > 0 )) && debug "corosync (crm) is not active here" return 1 fi @@ -152,7 +152,7 @@ return 0 # REQUIRES: n/a function linux_has_docker { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _DOCKER_BIN="" typeset _HAS_DOCKER=0 @@ -169,7 +169,7 @@ then docker ps >/dev/null 2>/dev/null (( $? == 0 )) && _HAS_DOCKER=1 else - (( ARG_DEBUG != 0 )) && debug "docker is not active here" + (( ARG_DEBUG > 0 )) && debug "docker is not active here" return 1 fi @@ -187,7 +187,7 @@ return 0 # REQUIRES: n/a function linux_has_nm { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" typeset _NMCLI_BIN="" typeset _HAS_NM=0 @@ -203,7 +203,7 @@ then # check for active _HAS_NM=$(nmcli networking 2>/dev/null | grep -c -i "enabled") else - (( ARG_DEBUG != 0 )) && debug "NetworkManager is not active here" + (( ARG_DEBUG > 0 )) && debug "NetworkManager is not active here" return 1 fi diff --git a/sources/lib/core/notify_eif.sh b/sources/lib/core/notify_eif.sh index 067c26b..1c19249 100644 --- a/sources/lib/core/notify_eif.sh +++ b/sources/lib/core/notify_eif.sh @@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _EIF_MESSAGE="$1 alert with ID ${HC_FAIL_ID}" @@ -105,7 +105,7 @@ then _CHILD_RC=$? kill -s TERM ${_SLEEP_PID} >/dev/null 2>&1 # process return codes - if (( _CHILD_RC != 0 )) + if (( _CHILD_RC > 0 )) then warn "problem in sending alert via EIF [RC=${_CHILD_RC}]" else diff --git a/sources/lib/core/notify_mail.sh b/sources/lib/core/notify_mail.sh index f69a1a1..34f201e 100644 --- a/sources/lib/core/notify_mail.sh +++ b/sources/lib/core/notify_mail.sh @@ -35,7 +35,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _MAIL_HC="$1" diff --git a/sources/lib/core/notify_sms.sh b/sources/lib/core/notify_sms.sh index 7f1ec39..7201c85 100644 --- a/sources/lib/core/notify_sms.sh +++ b/sources/lib/core/notify_sms.sh @@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _SMS_HC="$1" diff --git a/sources/lib/core/report_std.sh b/sources/lib/core/report_std.sh index 5d0668a..43cbedc 100644 --- a/sources/lib/core/report_std.sh +++ b/sources/lib/core/report_std.sh @@ -35,7 +35,7 @@ typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _DIR_PREFIX="" @@ -52,7 +52,7 @@ typeset _LOG_STASH="" typeset _SORT_CMD="" # which files do we need to examine -if (( ARG_HISTORY != 0 )) +if (( ARG_HISTORY > 0 )) then set +f # file globbing must be on _LOG_STASH="${HC_LOG} ${ARCHIVE_DIR}/hc.*.log" @@ -61,7 +61,7 @@ else fi # --last report -if (( ARG_LAST != 0 )) +if (( ARG_LAST > 0 )) then printf "\n| %-30s | %-20s | %-14s | %-4s\n" "HC" "Timestamp" "FAIL ID" "STC (combined value)" # shellcheck disable=SC2183 @@ -113,14 +113,14 @@ then else _ID_NEEDLE="[0-9][0-9]*" [[ -n "${ARG_FAIL_ID}" ]] && _ID_NEEDLE="${ARG_FAIL_ID}" - (( ARG_TODAY != 0 )) && _ID_NEEDLE="$(date '+%Y%m%d')" # refers to timestamp of HC FAIL_ID + (( ARG_TODAY > 0 )) && _ID_NEEDLE="$(date '+%Y%m%d')" # refers to timestamp of HC FAIL_ID # check fail count (look for unique IDs in the 5th field of the HC log) _FAIL_COUNT=$(cut -f5 -d"${LOG_SEP}" ${_LOG_STASH} 2>/dev/null | grep -E -e "${_ID_NEEDLE}" | uniq | wc -l) - if (( _FAIL_COUNT != 0 )) + if (( _FAIL_COUNT > 0 )) then # check for detail or not? - if (( ARG_DETAIL != 0 )) && (( _FAIL_COUNT != 1 )) + if (( ARG_DETAIL > 0 )) && (( _FAIL_COUNT > 1 )) then ARG_LOG=1 die "you must specify a unique FAIL_ID value" fi diff --git a/sources/lib/platform/aix/check_aix_errpt.sh b/sources/lib/platform/aix/check_aix_errpt.sh index cc46fe5..bb1430d 100644 --- a/sources/lib/platform/aix/check_aix_errpt.sh +++ b/sources/lib/platform/aix/check_aix_errpt.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" diff --git a/sources/lib/platform/aix/check_aix_file_age.sh b/sources/lib/platform/aix/check_aix_file_age.sh index c1e5008..0f4f247 100644 --- a/sources/lib/platform/aix/check_aix_file_age.sh +++ b/sources/lib/platform/aix/check_aix_file_age.sh @@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -104,7 +104,7 @@ do _STC=1 else _AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -mmin -"${_FILE_AGE}") - if (( $? != 0 )) + if (( $? > 0 )) then warn "unable to execute file age test for ${_FILE_PATH}" return 1 diff --git a/sources/lib/platform/aix/check_aix_file_change.sh b/sources/lib/platform/aix/check_aix_file_change.sh index 2c5a77c..00e503f 100644 --- a/sources/lib/platform/aix/check_aix_file_change.sh +++ b/sources/lib/platform/aix/check_aix_file_change.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -297,7 +297,7 @@ do fi # bounce failures back and jump to next file - if (( _STC != 0 )) + if (( _STC > 0 )) then log_hc "$0" ${_STC} "${_MSG}" continue @@ -327,7 +327,7 @@ do done <${_TMP1_FILE} # update state file (also if TMP2_FILE is empty) -if (( ARG_LOG != 0 )) +if (( ARG_LOG > 0 )) then [[ -s ${_TMP2_FILE} ]] || { warn "no files found to check, zeroing new state file" diff --git a/sources/lib/platform/aix/check_aix_fs_mounts.sh b/sources/lib/platform/aix/check_aix_fs_mounts.sh index 6d64ca7..11d8423 100644 --- a/sources/lib/platform/aix/check_aix_fs_mounts.sh +++ b/sources/lib/platform/aix/check_aix_fs_mounts.sh @@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -51,7 +51,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -79,9 +79,9 @@ do ;; *) _MSG="${_FS} is multiple times mounted?" - ;; + ;; esac - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 diff --git a/sources/lib/platform/aix/check_aix_lppchk.sh b/sources/lib/platform/aix/check_aix_lppchk.sh index 081e6a2..3896806 100644 --- a/sources/lib/platform/aix/check_aix_lppchk.sh +++ b/sources/lib/platform/aix/check_aix_lppchk.sh @@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -49,7 +49,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done diff --git a/sources/lib/platform/aix/check_aix_paths.sh b/sources/lib/platform/aix/check_aix_paths.sh index 5274989..8acec8b 100644 --- a/sources/lib/platform/aix/check_aix_paths.sh +++ b/sources/lib/platform/aix/check_aix_paths.sh @@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -50,7 +50,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -69,7 +69,7 @@ case ${_PATH} in _STC=1 ;; esac - + # handle results log_hc "$0" ${_STC} "${_MSG}" diff --git a/sources/lib/platform/aix/check_aix_root_crontab.sh b/sources/lib/platform/aix/check_aix_root_crontab.sh index ae14ce4..3f3852b 100644 --- a/sources/lib/platform/aix/check_aix_root_crontab.sh +++ b/sources/lib/platform/aix/check_aix_root_crontab.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -52,14 +52,14 @@ 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 @@ -77,15 +77,15 @@ do 0) _MSG="'${_CRON_ENTRY}' is not configured in cron" _STC=1 - ;; + ;; 1) _MSG="'${_CRON_ENTRY}' is configured in cron" ;; +([0-9])*([0-9])) _MSG="'${_CRON_ENTRY}' is configured multiple times in cron" - ;; + ;; esac - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 diff --git a/sources/lib/platform/aix/check_aix_subsystems.sh b/sources/lib/platform/aix/check_aix_subsystems.sh index f2cb6e2..3062652 100644 --- a/sources/lib/platform/aix/check_aix_subsystems.sh +++ b/sources/lib/platform/aix/check_aix_subsystems.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -51,14 +51,14 @@ 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 @@ -82,9 +82,9 @@ do ;; *) _MSG="${_SUBSYS} is not on file" - ;; + ;; esac - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 diff --git a/sources/lib/platform/aix/check_aix_sysbackup.sh b/sources/lib/platform/aix/check_aix_sysbackup.sh index 501b4fe..7715218 100644 --- a/sources/lib/platform/aix/check_aix_sysbackup.sh +++ b/sources/lib/platform/aix/check_aix_sysbackup.sh @@ -17,7 +17,7 @@ # DOCUMENTATION (MAIN) # ----------------------------------------------------------------------------- # @(#) MAIN: check_aix_sysbackup -# DOES: see _show_usage() +# DOES: see _show_usage() # EXPECTS: see _show_usage() # REQUIRES: data_space2comma(), init_hc(), log_hc() # @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -59,13 +59,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 @@ -93,7 +93,7 @@ case "${_BACKUP_AGE}" in +([0-9])*(.)*([0-9])) # numeric, OK ;; - *) + *) # not numeric, set default _BACKUP_AGE=14 ;; @@ -118,21 +118,21 @@ do # save log print "=== ${_BACKUP_HOST} ===" >>${HC_STDOUT_LOG} cat ${_BACKUP_LOG} >>${HC_STDOUT_LOG} - ;; + ;; *) _MSG="sysbackup status for ${_BACKUP_HOST}: failed" _STC=1 print "=== ${_BACKUP_HOST} ===" >>${HC_STDOUT_LOG} cat ${_BACKUP_LOG} >>${HC_STDOUT_LOG} - ;; + ;; esac else # don't flag this as erroneous, we could drop into this fork for - # VIO servers for example without mksysb but having backupios instead + # VIO servers for example without mksysb but having backupios instead # caveat emptor: also means that hosts *without* backup go undetected continue fi - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 @@ -148,25 +148,25 @@ do if (( _COUNT == 0 )) then _MSG="sysbackup age for ${_BACKUP_HOST}: <=${_BACKUP_AGE} days" - _STC=0 + _STC=0 else _MSG="sysbackup age for ${_BACKUP_HOST}: >${_BACKUP_AGE} days" _STC=1 print "=== ${_BACKUP_HOST} ===" >>${HC_STDOUT_LOG} - print "age: $(ls -l ${_BACKUP_LOG})" >>${HC_STDOUT_LOG} + print "age: $(ls -l ${_BACKUP_LOG})" >>${HC_STDOUT_LOG} fi else # don't flag this as erroneous, we could drop into this fork for - # VIO servers for example without mksysb but having backupios instead + # VIO servers for example without mksysb but having backupios instead # caveat emptor: also means that hosts *without* backup go undetected continue fi - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 done - + return 0 } @@ -180,9 +180,9 @@ CONFIG : $3 with: backup_path= mksysb_log= backup_age= -PURPOSE : Checks the state of saved mksysb client backups (should typically be +PURPOSE : Checks the state of saved mksysb client backups (should typically be run only on the NIM master or server that is acting as mksysb repo, - do NOT run on a typical client LPAR) + do NOT run on a typical client LPAR) EOT diff --git a/sources/lib/platform/aix/check_aix_topasrec.sh b/sources/lib/platform/aix/check_aix_topasrec.sh index 03e440c..dfb6e03 100644 --- a/sources/lib/platform/aix/check_aix_topasrec.sh +++ b/sources/lib/platform/aix/check_aix_topasrec.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -52,7 +52,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -64,11 +64,11 @@ topasrec -l >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} _TOPAS=$(grep -c "bin" ${HC_STDOUT_LOG} 2>/dev/null) _NMON=$(grep -c "nmon" ${HC_STDOUT_LOG} 2>/dev/null) _MSG="process checks: nmon=${_NMON}; topasrec=${_TOPAS}" -if (( _NMON != 1 || _TOPAS != 1 )) +if (( _NMON > 1 || _TOPAS > 1 )) then _STC=1 fi - + # handle results log_hc "$0" ${_STC} "${_MSG}" diff --git a/sources/lib/platform/hp-ux/check_hpux_autopath.sh b/sources/lib/platform/hp-ux/check_hpux_autopath.sh index 54162ba..cbfe942 100644 --- a/sources/lib/platform/hp-ux/check_hpux_autopath.sh +++ b/sources/lib/platform/hp-ux/check_hpux_autopath.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -55,12 +55,12 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # check autopath presence -if [[ ! -x ${_AUTOPATH_BIN} ]] +if [[ ! -x ${_AUTOPATH_BIN} ]] then warn "${_AUTOPATH_BIN} is not installed here" return 1 @@ -69,23 +69,23 @@ fi # collect autopath info log "collecting autopath information, this may take a while ..." ${_AUTOPATH_BIN} display >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} -(( $? != 0 )) && { +(( $? > 0 )) && { _MSG="unable to run {${_AUTOPATH_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } - + # check for device failures grep -E -e "${_AUTOPATH_NEEDLE}" ${HC_STDOUT_LOG} 2>/dev/null |\ while read _AUTOPATH_LINE do - _DEVICE="$(print ${_AUTOPATH_LINE} | cut -f1 -d' ')" + _DEVICE="$(print ${_AUTOPATH_LINE} | cut -f1 -d' ')" _MSG="failed path for device '${_DEVICE}'" _STC=1 _STC_COUNT=$(( _STC_COUNT + 1 )) - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 diff --git a/sources/lib/platform/hp-ux/check_hpux_cdsf_cluster.sh b/sources/lib/platform/hp-ux/check_hpux_cdsf_cluster.sh index c125fc0..7b5464b 100644 --- a/sources/lib/platform/hp-ux/check_hpux_cdsf_cluster.sh +++ b/sources/lib/platform/hp-ux/check_hpux_cdsf_cluster.sh @@ -37,7 +37,7 @@ typeset _CDSF_BIN="/usr/sbin/io_cdsf_config" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -79,7 +79,7 @@ else # io_cdsf_config outputs on STDERR (run status & check) # stable cluster: RC=0 ${_CDSF_BIN} -s >${HC_STDOUT_LOG} 2>${HC_STDOUT_LOG} - (( $? != 0 )) && { + (( $? > 0 )) && { log_hc "$0" 1 "cDSF cluster has not yet been initialized or is not stable" 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 ca6d95b..9bc17f1 100644 --- a/sources/lib/platform/hp-ux/check_hpux_drd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_drd_status.sh @@ -44,7 +44,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -247,7 +247,7 @@ else _MSG="unable to run command: {${_DRD_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi 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 601915d..cdbbbed 100644 --- a/sources/lib/platform/hp-ux/check_hpux_file_age.sh +++ b/sources/lib/platform/hp-ux/check_hpux_file_age.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +>#!/usr/bin/env ksh #****************************************************************************** # @(#) check_hpux_file_age.sh #****************************************************************************** @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -109,13 +109,13 @@ do if (( _DO_REF == 0 )) then REF_TIME=$(perl -e "use POSIX;\$t=time-(${_FILE_AGE}*60);print(strftime '%m%d%H%M',localtime(\$t))") - if (( $? != 0 )) + if (( $? > 0 )) then warn "failed to query reference time (Perl)" return 1 fi touch -amt "${REF_TIME}" ${_REF_FILE} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} - if (( $? != 0 )) + if (( $? > 0 )) then warn "failed to create reference time ${TMP_DIR}" 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 6ae35af..74c389e 100644 --- a/sources/lib/platform/hp-ux/check_hpux_file_change.sh +++ b/sources/lib/platform/hp-ux/check_hpux_file_change.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -297,7 +297,7 @@ do fi # bounce failures back and jump to next file - if (( _STC != 0 )) + if (( _STC > 0 )) then log_hc "$0" ${_STC} "${_MSG}" continue @@ -327,7 +327,7 @@ do done <${_TMP1_FILE} # update state file (also if TMP2_FILE is empty) -if (( ARG_LOG != 0 )) +if (( ARG_LOG > 0 )) then [[ -s ${_TMP2_FILE} ]] || { warn "no files found to check, zeroing new state file" diff --git a/sources/lib/platform/hp-ux/check_hpux_fs_mounts.sh b/sources/lib/platform/hp-ux/check_hpux_fs_mounts.sh index fab6bc5..0b8263d 100644 --- a/sources/lib/platform/hp-ux/check_hpux_fs_mounts.sh +++ b/sources/lib/platform/hp-ux/check_hpux_fs_mounts.sh @@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -53,7 +53,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -78,16 +78,16 @@ do ;; *) _MSG="${_FS} is multiple times mounted?" - ;; + ;; esac - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 done # add /etc/fstab to STDOUT log -cat /etc/fstab >>${HC_STDOUT_LOG} +cat /etc/fstab >>${HC_STDOUT_LOG} 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 90e95ba..54d6bfb 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 @@ -40,7 +40,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" 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 1eaaa9e..136c6de 100644 --- a/sources/lib/platform/hp-ux/check_hpux_guid_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_guid_status.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -74,7 +74,7 @@ else fi # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then # we need guidkeyd & guidd (( $(pgrep -P 1 -u root guidd 2>>${HC_STDERR_LOG} | wc -l) == 0 )) && _STC=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 ed4e376..8288c97 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 @@ -41,7 +41,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -76,11 +76,11 @@ then fi ${_HPVMSTATUS_BIN} -M >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} -(( $? != 0 )) && { +(( $? > 0 )) && { _MSG="unable to run command: {${_HPVMSTATUS_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } 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 12fc7f8..15697c6 100644 --- a/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh @@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -76,7 +76,7 @@ else fi # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -u root httpd 2>>${HC_STDERR_LOG} | wc -l) == 0 )) && _STC=1 fi 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 828f535..8861f5f 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh @@ -43,7 +43,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -100,7 +100,7 @@ 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 + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi @@ -185,7 +185,7 @@ 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 + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi else diff --git a/sources/lib/platform/hp-ux/check_hpux_ioscan.sh b/sources/lib/platform/hp-ux/check_hpux_ioscan.sh index 765f227..e03bc10 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ioscan.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ioscan.sh @@ -46,7 +46,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -127,12 +127,12 @@ 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 + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi fi 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 98f4a28..e9c417e 100644 --- a/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh +++ b/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh @@ -41,7 +41,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -80,12 +80,12 @@ then return 1 else ${_KCTUNE_BIN} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} - if (( $? != 0 )) + if (( $? > 0 )) then _MSG="unable to gather kctune information" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 fi fi 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 c925301..6285499 100644 --- a/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh +++ b/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh @@ -42,7 +42,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -97,11 +97,11 @@ then return 1 else ${_KCUSAGE_BIN} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} - if (( $? != 0 )) + if (( $? > 0 )) then _MSG="unable to gather kcusage information" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs log_hc "$0" 1 "${_MSG}" return 0 fi @@ -176,7 +176,7 @@ do # parameter excluded? if (( $(print "${_EXCLUDED_PARAMS}" | tr ',' '\n' | grep -c -E -e "${_PARAM_NAME}") != 0 )) then - (( ARG_DEBUG != 0 )) && debug "excluding kernel parameter ${_PARAM_NAME} ..." + (( ARG_DEBUG > 0 )) && debug "excluding kernel parameter ${_PARAM_NAME} ..." continue fi diff --git a/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh b/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh index a9b2e5c..03eba63 100644 --- a/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh +++ b/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh @@ -42,7 +42,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -117,7 +117,7 @@ fi } # get all disk LUNs -(( ARG_DEBUG != 0 )) && debug "collecting ioscan information" +(( ARG_DEBUG > 0 )) && debug "collecting ioscan information" print "=== ioscan ===" >>${HC_STDOUT_LOG} ${_IOSCAN_BIN} ${_IOSCAN_OPTS} >${_TMP1_FILE} 2>>${HC_STDERR_LOG} if (( $? > 0 )) @@ -125,24 +125,24 @@ then _MSG="unable to gather ioscan information" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi # collect scsimgr info for all LUNs -(( ARG_DEBUG != 0 )) && debug "collecting scsimgr information" +(( ARG_DEBUG > 0 )) && debug "collecting scsimgr information" ${_SCSIMGR_BIN} ${_SCSIMGR_OPTS} >${_TMP2_FILE} 2>>${HC_STDERR_LOG} if (( $? > 0 )) then _MSG="unable to gather scsimgr information" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi # parse ioscan + scsimgr results (WWID is the glue) -(( ARG_DEBUG != 0 )) && debug "glueing ioscan & scsimgr information together" +(( ARG_DEBUG > 0 )) && debug "glueing ioscan & scsimgr information together" awk 'BEGIN { wwid = ""; active_paths = ""; all_paths = ""; failed_paths = ""; standby_paths = ""; } { 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 ade75bc..0bae5bc 100644 --- a/sources/lib/platform/hp-ux/check_hpux_named_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_named_status.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _NAMED_CHECKCONF_BIN="" typeset _NAMED_PID="" @@ -75,7 +75,7 @@ else fi # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -u root named 2>>${HC_STDERR_LOG} | wc -l) == 0 )) && _STC=1 fi 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 fe40fee..257e76e 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh @@ -41,7 +41,7 @@ typeset _NTPQ_BIN="/usr/sbin/ntpq" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" 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 71b0b38..5159473 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh @@ -43,7 +43,7 @@ typeset _OVPA_BIN="/opt/perf/bin/perfstat" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" 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 cca62d8..7f3ea86 100644 --- a/sources/lib/platform/hp-ux/check_hpux_patch_version.sh +++ b/sources/lib/platform/hp-ux/check_hpux_patch_version.sh @@ -45,7 +45,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -163,7 +163,7 @@ then _MSG="unable to run command: {${_SWLIST_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi else @@ -209,7 +209,7 @@ then _MSG="unable to run command: {${_SHOW_PATCHES_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi else @@ -241,7 +241,7 @@ then _MSG="unable to run command: {${_SWLIST_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi fi diff --git a/sources/lib/platform/hp-ux/check_hpux_postfix_status.sh b/sources/lib/platform/hp-ux/check_hpux_postfix_status.sh index 29cb6f4..9761e03 100644 --- a/sources/lib/platform/hp-ux/check_hpux_postfix_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_postfix_status.sh @@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -50,7 +50,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done diff --git a/sources/lib/platform/hp-ux/check_hpux_root_crontab.sh b/sources/lib/platform/hp-ux/check_hpux_root_crontab.sh index b423807..772233e 100644 --- a/sources/lib/platform/hp-ux/check_hpux_root_crontab.sh +++ b/sources/lib/platform/hp-ux/check_hpux_root_crontab.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -52,13 +52,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 @@ -76,20 +76,20 @@ do 0) _MSG="'${_CRON_ENTRY}' is not configured in cron" _STC=1 - ;; + ;; 1) _MSG="'${_CRON_ENTRY}' is configured in cron" ;; +([0-9])*([0-9])) _MSG="'${_CRON_ENTRY}' is configured multiple times in cron" - ;; + ;; esac - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 done - + return 0 } diff --git a/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh b/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh index 789e81e..92da2d6 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh @@ -41,7 +41,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -238,7 +238,7 @@ then # save cimprovider OUTPUT print "${_CHECK_CIM_OUTPUT}" >>${HC_STDOUT_LOG} # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 else # find module @@ -310,7 +310,7 @@ then _MSG="unable to execute {${_SFMCONFIG_BIN} -t -a}, cimserver is probably not running" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 else # wait for test event to showing @@ -326,7 +326,7 @@ then # save evweb OUTPUT print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 else if [[ -n "${_CHECK_EVWEB_OUTPUT}" ]] @@ -361,7 +361,7 @@ then # save evweb OUTPUT print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 else _CFG_EVENTS_SEVERITY=$(data_lc "${_CFG_EVENTS_SEVERITY}") 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 1cd2823..533700a 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 @@ -42,7 +42,7 @@ typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" 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 4164269..c291e97 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 @@ -42,7 +42,7 @@ typeset _SG_DAEMON="/usr/lbin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -79,11 +79,11 @@ then return 1 else cmviewcl -v -f line 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG} - (( $? != 0 )) && { + (( $? > 0 )) && { _MSG="unable to run command: {cmviewcl}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } fi 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 1726b7d..500bfbd 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 @@ -42,7 +42,7 @@ typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" 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 0882ab2..cda3fea 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 @@ -42,7 +42,7 @@ typeset _SG_DAEMON="/usr/lbin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -80,11 +80,11 @@ then return 1 else cmviewcl -v -f line -l package 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG} - (( $? != 0)) && { + (( $? > 0)) && { _MSG="unable to run command: {cmviewcl}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } fi 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 1422761..2d84686 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 @@ -39,7 +39,7 @@ typeset _QS_AUTH_FILE="/etc/cmcluster/qs_authfile" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" 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 8728df0..087e650 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh @@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -75,7 +75,7 @@ else fi # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -P 1 -u root sshd 2>>${HC_STDERR_LOG} | wc -l) == 0 )) && _STC=1 fi diff --git a/sources/lib/platform/hp-ux/check_hpux_syslog.sh b/sources/lib/platform/hp-ux/check_hpux_syslog.sh index 2a93f2b..311a84a 100644 --- a/sources/lib/platform/hp-ux/check_hpux_syslog.sh +++ b/sources/lib/platform/hp-ux/check_hpux_syslog.sh @@ -40,7 +40,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -132,7 +132,7 @@ then warn "failed to sort temporary state file" return 1 } - if (( ARG_LOG != 0 )) + if (( ARG_LOG > 0 )) then mv ${_TMP_FILE} ${_STATE_FILE} >/dev/null 2>&1 (( $? > 0 )) && { diff --git a/sources/lib/platform/hp-ux/check_hpux_vg_minor_number.sh b/sources/lib/platform/hp-ux/check_hpux_vg_minor_number.sh index 4d0c9a7..c6e3e77 100644 --- a/sources/lib/platform/hp-ux/check_hpux_vg_minor_number.sh +++ b/sources/lib/platform/hp-ux/check_hpux_vg_minor_number.sh @@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -52,13 +52,13 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done # get list of major and minor numbers for vgs vgdisplay -F | cut -f1 -d':' | cut -f2 -d'=' | while read _VG -do +do ls -l ${_VG}/group >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} done @@ -70,13 +70,13 @@ then do _MSG="MAJ/MIN numbers combination '${_VG_DUPE}' is not unique" _STC=1 - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" done else _MSG="no VGs with duplicate MAJ/MIN numbers detected" - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" fi diff --git a/sources/lib/platform/linux/check_linux_burp_backup.sh b/sources/lib/platform/linux/check_linux_burp_backup.sh index 1e6144c..f70c8ac 100644 --- a/sources/lib/platform/linux/check_linux_burp_backup.sh +++ b/sources/lib/platform/linux/check_linux_burp_backup.sh @@ -44,7 +44,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -101,7 +101,7 @@ fi # burp v1 or v2? _BURP_VERSION="$(${_BURP_BIN} -v 2>/dev/null)" -(( ARG_DEBUG != 0 )) && debug "burp version: ${_BURP_VERSION}" +(( ARG_DEBUG > 0 )) && debug "burp version: ${_BURP_VERSION}" case "${_BURP_VERSION}" in burp-2*) # check for burp server diff --git a/sources/lib/platform/linux/check_linux_burp_status.sh b/sources/lib/platform/linux/check_linux_burp_status.sh index c183a2d..a0c8651 100644 --- a/sources/lib/platform/linux/check_linux_burp_status.sh +++ b/sources/lib/platform/linux/check_linux_burp_status.sh @@ -40,7 +40,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -54,7 +54,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -86,7 +86,7 @@ case "${LINUX_INIT}" in esac # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -u root burp 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1 fi diff --git a/sources/lib/platform/linux/check_linux_file_age.sh b/sources/lib/platform/linux/check_linux_file_age.sh index 228752c..7cab062 100644 --- a/sources/lib/platform/linux/check_linux_file_age.sh +++ b/sources/lib/platform/linux/check_linux_file_age.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -105,7 +105,7 @@ do _STC=1 else _AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -mmin -"${_FILE_AGE}" 2>/dev/null) - if (( $? != 0 )) + if (( $? > 0 )) then warn "unable to execute file age test for ${_FILE_PATH}" return 1 diff --git a/sources/lib/platform/linux/check_linux_file_change.sh b/sources/lib/platform/linux/check_linux_file_change.sh index eb9c313..0ac1edc 100644 --- a/sources/lib/platform/linux/check_linux_file_change.sh +++ b/sources/lib/platform/linux/check_linux_file_change.sh @@ -40,7 +40,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -298,7 +298,7 @@ do fi # bounce failures back and jump to next file - if (( _STC != 0 )) + if (( _STC > 0 )) then log_hc "$0" ${_STC} "${_MSG}" continue @@ -328,7 +328,7 @@ do done <${_TMP1_FILE} # update state file (also if TMP2_FILE is empty) -if (( ARG_LOG != 0 )) +if (( ARG_LOG > 0 )) then [[ -s ${_TMP2_FILE} ]] || { warn "no files found to check, zeroing new state file" diff --git a/sources/lib/platform/linux/check_linux_fs_mounts.sh b/sources/lib/platform/linux/check_linux_fs_mounts.sh index 953b421..1ef7f95 100644 --- a/sources/lib/platform/linux/check_linux_fs_mounts.sh +++ b/sources/lib/platform/linux/check_linux_fs_mounts.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -55,7 +55,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -82,9 +82,9 @@ do ;; *) _MSG="${_FS} is multiple times mounted?" - ;; + ;; esac - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 diff --git a/sources/lib/platform/linux/check_linux_hpacucli.sh b/sources/lib/platform/linux/check_linux_hpacucli.sh index 7342eec..acc1bdb 100644 --- a/sources/lib/platform/linux/check_linux_hpacucli.sh +++ b/sources/lib/platform/linux/check_linux_hpacucli.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -133,7 +133,7 @@ esac # check for dependencies: we need to do DO_ACU_CTRL to have the slot info for all # the other checks _DO_CHECK=$(( _DO_ACU_ENCL + _DO_ACU_PHYS + _DO_ACU_LOGL )) -if (( _DO_CHECK != 0 && _DO_ACU_CTRL == 0 )) +if (( _DO_CHECK > 0 && _DO_ACU_CTRL == 0 )) then log "switching setting 'do_acu_controller' to 1 to fetch slot info" _DO_ACU_CTRL=1 @@ -148,10 +148,10 @@ fi # --- perform checks --- # CONTROLLER(s) -if (( _DO_ACU_CTRL != 0 )) +if (( _DO_ACU_CTRL > 0 )) then ${_HPACUCLI_BIN} controller all show status >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && warn "'${_HPACUCLI_BIN} controller all show status' exited non-zero" + (( $? > 0 )) && warn "'${_HPACUCLI_BIN} controller all show status' exited non-zero" # look for failures grep -i -E -e "(nok|fail.*)" ${_TMP_FILE} 2>/dev/null |\ while read _ACU_LINE @@ -183,13 +183,13 @@ else fi # ENCLOSURE(s) -if (( _DO_ACU_ENCL != 0 )) +if (( _DO_ACU_ENCL > 0 )) then for _CTRL_SLOT in ${_SLOT_NUMS} do ${_HPACUCLI_BIN} controller slot=${_CTRL_SLOT} enclosure all show \ >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && \ + (( $? > 0 )) && \ warn "'${_HPACUCLI_BIN} controller slot=${_CTRL_SLOT} enclosure all show' exited non-zero" # look for failures grep -i -E -e "(nok|fail.*)" ${_TMP_FILE} 2>/dev/null |\ @@ -208,13 +208,13 @@ else fi # PHYSICAL DRIVE(s) -if (( _DO_ACU_PHYS != 0 )) +if (( _DO_ACU_PHYS > 0 )) then for _CTRL_SLOT in ${_SLOT_NUMS} do ${_HPACUCLI_BIN} controller slot=${_CTRL_SLOT} physicaldrive all show status \ >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && \ + (( $? > 0 )) && \ warn "'${_HPACUCLI_BIN} controller slot=${_CTRL_SLOT} physicaldrive all show status' exited non-zero" # look for failures grep -i -E -e "(nok|fail.*)" ${_TMP_FILE} 2>/dev/null |\ @@ -233,13 +233,13 @@ else fi # LOGICAL DRIVE(s) -if (( _DO_ACU_LOGL != 0 )) +if (( _DO_ACU_LOGL > 0 )) then for _CTRL_SLOT in ${_SLOT_NUMS} do ${_HPACUCLI_BIN} controller slot=${_CTRL_SLOT} logicaldrive all show status \ >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && \ + (( $? > 0 )) && \ warn "'${_HPACUCLI_BIN} controller slot=${_CTRL_SLOT}logicaldrive all show status' exited non-zero" # look for failures grep -i -E -e "(nok|fail)" ${_TMP_FILE} 2>/dev/null |\ diff --git a/sources/lib/platform/linux/check_linux_hpasmcli.sh b/sources/lib/platform/linux/check_linux_hpasmcli.sh index e73f1fe..db8c377 100644 --- a/sources/lib/platform/linux/check_linux_hpasmcli.sh +++ b/sources/lib/platform/linux/check_linux_hpasmcli.sh @@ -40,7 +40,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -156,10 +156,10 @@ fi # --- perform checks --- # SHOW FANS -if (( _DO_ASM_FANS != 0 )) +if (( _DO_ASM_FANS > 0 )) then ${_HPASMCLI_BIN} -s 'SHOW FANS' >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW FANS' exited non-zero" + (( $? > 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW FANS' exited non-zero" # look for failures grep -E -e '^#' ${_TMP_FILE} 2>/dev/null | grep -vi 'normal' 2>/dev/null |\ while read _ASM_LINE @@ -177,10 +177,10 @@ else fi # SHOW DIMM -if (( _DO_ASM_DIMM != 0 )) +if (( _DO_ASM_DIMM > 0 )) then ${_HPASMCLI_BIN} -s 'SHOW DIMM' >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW DIMM' exited non-zero" + (( $? > 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW DIMM' exited non-zero" # look for failures grep -i -E -e "(nok|fail)" ${_TMP_FILE} 2>/dev/null |\ while read _ASM_LINE @@ -197,10 +197,10 @@ else fi # SHOW POWERSUPPLY -if (( _DO_ASM_POWR != 0 )) +if (( _DO_ASM_POWR > 0 )) then ${_HPASMCLI_BIN} -s 'SHOW POWERSUPPLY' >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW POWERSUPPLY' exited non-zero" + (( $? > 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW POWERSUPPLY' exited non-zero" # look for failures grep -i -E -e "(nok|fail)" ${_TMP_FILE} 2>/dev/null |\ while read _ASM_LINE @@ -217,10 +217,10 @@ else fi # SHOW SERVER -if (( _DO_ASM_SRVR != 0 )) +if (( _DO_ASM_SRVR > 0 )) then ${_HPASMCLI_BIN} -s 'SHOW SERVER' >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW SERVER' exited non-zero" + (( $? > 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW SERVER' exited non-zero" # look for failures grep -i -E -e "(nok|fail)" ${_TMP_FILE} 2>/dev/null |\ while read _ASM_LINE @@ -237,10 +237,10 @@ else fi # SHOW TEMP -if (( _DO_ASM_TEMP != 0 )) +if (( _DO_ASM_TEMP > 0 )) then ${_HPASMCLI_BIN} -s 'SHOW TEMP' >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW TEMP' exited non-zero" + (( $? > 0 )) && warn "'${_HPASMCLI_BIN} -s SHOW TEMP' exited non-zero" # look for failures grep -E -e '^#' ${_TMP_FILE} 2>/dev/null |\ while read _ASM_LINE diff --git a/sources/lib/platform/linux/check_linux_hplog.sh b/sources/lib/platform/linux/check_linux_hplog.sh index ae038f9..6f1a460 100644 --- a/sources/lib/platform/linux/check_linux_hplog.sh +++ b/sources/lib/platform/linux/check_linux_hplog.sh @@ -40,7 +40,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -114,11 +114,11 @@ fi # get hplog output ${_HPLOG_BIN} -v >${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} -(( $? != 0 )) && { +(( $? > 0 )) && { _MSG="unable to run ${_HPLOG_BIN}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } diff --git a/sources/lib/platform/linux/check_linux_hpssacli.sh b/sources/lib/platform/linux/check_linux_hpssacli.sh index abf36dc..0f91548 100644 --- a/sources/lib/platform/linux/check_linux_hpssacli.sh +++ b/sources/lib/platform/linux/check_linux_hpssacli.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -133,7 +133,7 @@ esac # check for dependencies: we need to do DO_SSA_CTRL to have the slot info for all # the other checks _DO_CHECK=$(( _DO_SSA_ENCL + _DO_SSA_PHYS + _DO_SSA_LOGL )) -if (( _DO_CHECK != 0 && _DO_SSA_CTRL == 0 )) +if (( _DO_CHECK > 0 && _DO_SSA_CTRL == 0 )) then log "switching setting 'do_ssa_controller' to 1 to fetch slot info" _DO_SSA_CTRL=1 @@ -148,10 +148,10 @@ fi # --- perform checks --- # CONTROLLER(s) -if (( _DO_SSA_CTRL != 0 )) +if (( _DO_SSA_CTRL > 0 )) then ${_HPSSACLI_BIN} controller all show status >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && warn "'${_HPSSACLI_BIN} controller all show status' exited non-zero" + (( $? > 0 )) && warn "'${_HPSSACLI_BIN} controller all show status' exited non-zero" # look for failures grep -i -E -e "(nok|fail.*)" ${_TMP_FILE} 2>/dev/null |\ while read _SSA_LINE @@ -183,13 +183,13 @@ else fi # ENCLOSURE(s) -if (( _DO_SSA_ENCL != 0 )) +if (( _DO_SSA_ENCL > 0 )) then for _CTRL_SLOT in ${_SLOT_NUMS} do ${_HPSSACLI_BIN} controller slot=${_CTRL_SLOT} enclosure all show \ >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && \ + (( $? > 0 )) && \ warn "'${_HPSSACLI_BIN} controller slot=${_CTRL_SLOT} enclosure all show' exited non-zero" # look for failures grep -i -E -e "(nok|fail.*)" ${_TMP_FILE} 2>/dev/null |\ @@ -208,13 +208,13 @@ else fi # PHYSICAL DRIVE(s) -if (( _DO_SSA_PHYS != 0 )) +if (( _DO_SSA_PHYS > 0 )) then for _CTRL_SLOT in ${_SLOT_NUMS} do ${_HPSSACLI_BIN} controller slot=${_CTRL_SLOT} physicaldrive all show status \ >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && \ + (( $? > 0 )) && \ warn "'${_HPSSACLI_BIN} controller slot=${_CTRL_SLOT} physicaldrive all show status' exited non-zero" # look for failures grep -i -E -e "(nok|fail.*)" ${_TMP_FILE} 2>/dev/null |\ @@ -233,13 +233,13 @@ else fi # LOGICAL DRIVE(s) -if (( _DO_SSA_LOGL != 0 )) +if (( _DO_SSA_LOGL > 0 )) then for _CTRL_SLOT in ${_SLOT_NUMS} do ${_HPSSACLI_BIN} controller slot=${_CTRL_SLOT} logicaldrive all show status \ >${_TMP_FILE} 2>${_TMP_FILE} - (( $? != 0 )) && \ + (( $? > 0 )) && \ warn "'${_HPSSACLI_BIN} controller slot=${_CTRL_SLOT}logicaldrive all show status' exited non-zero" # look for failures grep -i -E -e "(nok|fail)" ${_TMP_FILE} 2>/dev/null |\ diff --git a/sources/lib/platform/linux/check_linux_httpd_status.sh b/sources/lib/platform/linux/check_linux_httpd_status.sh index 6f87429..d1d9401 100644 --- a/sources/lib/platform/linux/check_linux_httpd_status.sh +++ b/sources/lib/platform/linux/check_linux_httpd_status.sh @@ -41,7 +41,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -56,7 +56,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -90,7 +90,7 @@ case "${LINUX_INIT}" in esac # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -u root httpd 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1 fi @@ -136,7 +136,7 @@ cat <<- EOT NAME : $1 VERSION : $2 CONFIG : $3 -PURPOSE : Checks whether httpd (apache service) is running and whether the +PURPOSE : Checks whether httpd (apache service) is running and whether the httpd configuration files are syntactically correct EOT diff --git a/sources/lib/platform/linux/check_linux_named_status.sh b/sources/lib/platform/linux/check_linux_named_status.sh index 5a2adbd..aea5e86 100644 --- a/sources/lib/platform/linux/check_linux_named_status.sh +++ b/sources/lib/platform/linux/check_linux_named_status.sh @@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -55,7 +55,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -101,7 +101,7 @@ case "${LINUX_INIT}" in esac # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -u root named 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1 fi diff --git a/sources/lib/platform/linux/check_linux_ntp_status.sh b/sources/lib/platform/linux/check_linux_ntp_status.sh index 0c2fa77..47cb95d 100644 --- a/sources/lib/platform/linux/check_linux_ntp_status.sh +++ b/sources/lib/platform/linux/check_linux_ntp_status.sh @@ -47,7 +47,7 @@ typeset _NTPQ_BIN="/usr/sbin/ntpq" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -123,7 +123,7 @@ else _MSG="unable to find chronyd or ntpd" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi @@ -177,7 +177,7 @@ case "${LINUX_INIT}" in esac # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then if (( _USE_CHRONYD > 0 )) then @@ -227,7 +227,7 @@ then _MSG="unable to execute {${_CHRONYC_BIN}}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi diff --git a/sources/lib/platform/linux/check_linux_postfix_status.sh b/sources/lib/platform/linux/check_linux_postfix_status.sh index 18829ce..5d9ccf6 100644 --- a/sources/lib/platform/linux/check_linux_postfix_status.sh +++ b/sources/lib/platform/linux/check_linux_postfix_status.sh @@ -23,7 +23,7 @@ # # @(#) HISTORY: # @(#) 2016-12-01: initial version [Patrick Van der Veken] -# @(#) 2017-05-08: suppress errors on postfix call + fix fall-back +# @(#) 2017-05-08: suppress errors on postfix call + fix fall-back # @(#) for sysv->pgrep[Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # ----------------------------------------------------------------------------- @@ -41,7 +41,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -56,7 +56,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -89,7 +89,7 @@ case "${LINUX_INIT}" in esac # 2) try the postfix way -if (( _RC != 0 )) +if (( _RC > 0 )) then _POSTFIX_BIN="$(which postfix 2>>${HC_STDERR_LOG})" if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]] diff --git a/sources/lib/platform/linux/check_linux_process_limits.sh b/sources/lib/platform/linux/check_linux_process_limits.sh index fa2bd7d..4fced8a 100644 --- a/sources/lib/platform/linux/check_linux_process_limits.sh +++ b/sources/lib/platform/linux/check_linux_process_limits.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -146,7 +146,7 @@ do case "${_PROCESS_LIMIT}" in "Max open files") # collect ps info - (( ARG_DEBUG != 0 )) && debug "${_PROCESS_LIMIT}: collecting information for process class ${_PROCESS}" + (( ARG_DEBUG > 0 )) && debug "${_PROCESS_LIMIT}: collecting information for process class ${_PROCESS}" _PROCESS_PS=$(_get_psinfo_by_process "${_PROCESS}") if [[ -z "${_PROCESS_PS}" ]] then @@ -155,7 +155,7 @@ do fi print "${_PROCESS_PS}" | while read _PROCESS_PS_PID _PROCESS_PS_USER do - (( ARG_DEBUG != 0 )) && debug "${_PROCESS_LIMIT}: checking process ${_PROCESS_PS_PID}" + (( ARG_DEBUG > 0 )) && debug "${_PROCESS_LIMIT}: checking process ${_PROCESS_PS_PID}" # get current values and check thresholds _MAX_OPEN_FILES=$(_get_open_files ${_PROCESS_PS_PID}) # SOFT limit @@ -210,7 +210,7 @@ do case "${_USER_LIMIT}" in "Max open files") # collect ps info - (( ARG_DEBUG != 0 )) && debug "${_USER_LIMIT}: collecting information for user ${_USER}" + (( ARG_DEBUG > 0 )) && debug "${_USER_LIMIT}: collecting information for user ${_USER}" _USER_PS=$(_get_psinfo_by_user "${_USER}") if [[ -z "${_USER_PS}" ]] then @@ -219,7 +219,7 @@ do fi print "${_USER_PS}" | while read _USER_PS_PID _USER_PS_COMM do - (( ARG_DEBUG != 0 )) && debug "${_USER_LIMIT}: checking process ${_USER_PS_PID}" + (( ARG_DEBUG > 0 )) && debug "${_USER_LIMIT}: checking process ${_USER_PS_PID}" # get current values and check thresholds _MAX_OPEN_FILES=$(_get_open_files ${_USER_PS_PID}) # SOFT limit @@ -231,7 +231,7 @@ do done ;; "Max processes") - (( ARG_DEBUG != 0 )) && debug "${_USER_LIMIT}: collecting information for user ${_USER}" + (( ARG_DEBUG > 0 )) && debug "${_USER_LIMIT}: collecting information for user ${_USER}" _MAX_PROCESSES=$(_get_processes ${_USER}) # SOFT limit _check_limit "${_USER_LIMIT}" soft 0 ${_USER} "" ${_USER_SOFT_THRESHOLD} \ @@ -259,7 +259,7 @@ return 0 #1992 root function _get_psinfo_by_process { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} ps -C "${1}" -o pid:1,user:1 --no-headers 2>/dev/null @@ -272,7 +272,7 @@ return 0 #8539 pickup function _get_psinfo_by_user { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} ps -U "${1}" -o pid:1,comm:1 --no-headers 2>/dev/null @@ -293,7 +293,7 @@ typeset _LIMIT_COMMAND="" typeset _LIMIT_ENTRY="" typeset _LIMIT_FIELD=0 typeset _MSG_BIT="" -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} # check for empties (( _LIMIT_PID == 0 )) && _LIMIT_PID="N/A" @@ -370,7 +370,7 @@ return 0 # ----------------------------------------------------------------------------- function _get_open_files { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} ls -f /proc/${1}/fd/ 2>/dev/null | wc -l 2>/dev/null @@ -380,7 +380,7 @@ return 0 # ----------------------------------------------------------------------------- function _get_processes { -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} ps -U ${1} --no-headers 2>/dev/null | wc -l 2>/dev/null diff --git a/sources/lib/platform/linux/check_linux_root_crontab.sh b/sources/lib/platform/linux/check_linux_root_crontab.sh index f687a1e..c55e12d 100644 --- a/sources/lib/platform/linux/check_linux_root_crontab.sh +++ b/sources/lib/platform/linux/check_linux_root_crontab.sh @@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -54,13 +54,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 @@ -92,7 +92,7 @@ then fi done fi - + # perform check grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _CRON_ENTRY do @@ -102,15 +102,15 @@ do 0) _MSG="'${_CRON_ENTRY}' is not configured in cron" _STC=1 - ;; + ;; 1) _MSG="'${_CRON_ENTRY}' is configured in cron" ;; +([0-9])*([0-9])) _MSG="'${_CRON_ENTRY}' is configured multiple times in cron" - ;; + ;; esac - + # handle unit result log_hc "$0" ${_STC} "${_MSG}" _STC=0 diff --git a/sources/lib/platform/linux/check_linux_samba_status.sh b/sources/lib/platform/linux/check_linux_samba_status.sh index e3c2901..b9d571b 100644 --- a/sources/lib/platform/linux/check_linux_samba_status.sh +++ b/sources/lib/platform/linux/check_linux_samba_status.sh @@ -43,7 +43,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -57,7 +57,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -98,7 +98,7 @@ case "${LINUX_INIT}" in esac # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -u root nmbd 2>>${HC_STDERR_LOG}| wc -l 2>/dev/null) == 0 )) && _STC=1 (( $(pgrep -u root smbd 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=$(( _STC + 2 )) 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 d6a12c7..6b15512 100644 --- a/sources/lib/platform/linux/check_linux_sg_cluster_config.sh +++ b/sources/lib/platform/linux/check_linux_sg_cluster_config.sh @@ -42,7 +42,7 @@ typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} PATH=$PATH:/opt/cmcluster/bin init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") @@ -109,7 +109,7 @@ else _MSG="unable to gather cluster configuration" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } done 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 27afb28..b2d527e 100644 --- a/sources/lib/platform/linux/check_linux_sg_cluster_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_cluster_status.sh @@ -42,7 +42,7 @@ typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} PATH=$PATH:/opt/cmcluster/bin init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") @@ -80,11 +80,11 @@ then return 1 else cmviewcl -v -f line 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG} 2>/dev/null - (( $? != 0 )) && { + (( $? > 0 )) && { _MSG="unable to run command: {cmviewcl}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } fi 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 888ffc4..bb7de00 100644 --- a/sources/lib/platform/linux/check_linux_sg_package_config.sh +++ b/sources/lib/platform/linux/check_linux_sg_package_config.sh @@ -42,7 +42,7 @@ typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} PATH=$PATH:/opt/cmcluster/bin init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") @@ -109,7 +109,7 @@ else _MSG="unable to gather package configuration for at least one cluster package" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } done 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 6f47492..af88585 100644 --- a/sources/lib/platform/linux/check_linux_sg_package_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_package_status.sh @@ -42,7 +42,7 @@ typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} PATH=$PATH:/opt/cmcluster/bin init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") @@ -81,11 +81,11 @@ then return 1 else cmviewcl -v -f line -l package 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG} - (( $? != 0)) && { + (( $? > 0)) && { _MSG="unable to run command: {cmviewcl}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } fi 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 c0f2110..3805604 100644 --- a/sources/lib/platform/linux/check_linux_sg_qs_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_qs_status.sh @@ -39,7 +39,7 @@ typeset _QS_AUTH_FILE="/opt/qs/conf/qs_authfile" # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" diff --git a/sources/lib/platform/linux/check_linux_shorewall_status.sh b/sources/lib/platform/linux/check_linux_shorewall_status.sh index c11654c..7453302 100644 --- a/sources/lib/platform/linux/check_linux_shorewall_status.sh +++ b/sources/lib/platform/linux/check_linux_shorewall_status.sh @@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -50,7 +50,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -96,7 +96,7 @@ cat <<- EOT NAME : $1 VERSION : $2 CONFIG : $3 -PURPOSE : Checks whether shorewall (firewall) service is running and whether +PURPOSE : Checks whether shorewall (firewall) service is running and whether shorewall rules compile correctly EOT diff --git a/sources/lib/platform/linux/check_linux_sshd_status.sh b/sources/lib/platform/linux/check_linux_sshd_status.sh index 568057b..91698c7 100644 --- a/sources/lib/platform/linux/check_linux_sshd_status.sh +++ b/sources/lib/platform/linux/check_linux_sshd_status.sh @@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -55,7 +55,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -99,7 +99,7 @@ case "${LINUX_INIT}" in esac # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -P 1 -u root sshd 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1 fi 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 bfff7da..6db4d06 100644 --- a/sources/lib/platform/linux/check_linux_vz_ct_status.sh +++ b/sources/lib/platform/linux/check_linux_vz_ct_status.sh @@ -44,7 +44,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -80,11 +80,11 @@ fi # get container stati ${_VZLIST_BIN} -a -H -o ctid,status,onboot >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} -(( $? != 0 )) && { +(( $? > 0 )) && { _MSG="unable to run command: {vzlist}" log_hc "$0" 1 "${_MSG}" # dump debug info - (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 0 } diff --git a/sources/lib/platform/linux/check_linux_winbind_status.sh b/sources/lib/platform/linux/check_linux_winbind_status.sh index 1aded84..9c04865 100644 --- a/sources/lib/platform/linux/check_linux_winbind_status.sh +++ b/sources/lib/platform/linux/check_linux_winbind_status.sh @@ -41,7 +41,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- # set defaults -(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} +(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS} init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" @@ -55,7 +55,7 @@ do case "${_ARG}" in help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done @@ -87,7 +87,7 @@ case "${LINUX_INIT}" in esac # 2) try the pgrep way (note: old pgreps do not support '-c') -if (( _RC != 0 )) +if (( _RC > 0 )) then (( $(pgrep -u root winbind 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1 fi