diff --git a/etc/opt/hc/core/check_health.conf.dist b/etc/opt/hc/core/check_health.conf.dist index 92617b6..361b65c 100644 --- a/etc/opt/hc/core/check_health.conf.dist +++ b/etc/opt/hc/core/check_health.conf.dist @@ -10,6 +10,17 @@ # maximum timeout for HC calls/plugins (seconds) [default: 60] HC_TIME_OUT=60 +# enable/disable logging of passed health checks (warning: this may rapidly grow the HC log) +# see also: '--log-healthy' command-line parameter +# 'log_healthy' setting in HC plugin configuration file(s) +# [values: Yes|No] +HC_LOG_HEALTHY="No" + +# enable/disable healing logic if available in HC plugin(s) +# see also: '--no-fix' command-line parameter +# [values: Yes|No] +HC_WILL_FIX="Yes" + #****************************************************************************** # End of FILE diff --git a/opt/hc/bin/check_health.sh b/opt/hc/bin/check_health.sh index 6df0e0c..2662951 100755 --- a/opt/hc/bin/check_health.sh +++ b/opt/hc/bin/check_health.sh @@ -38,7 +38,7 @@ # ------------------------- CONFIGURATION starts here ------------------------- # define the version (YYYY-MM-DD) -typeset -r SCRIPT_VERSION="2019-07-16" +typeset -r SCRIPT_VERSION="2019-10-24" # location of parent directory containing KSH functions/HC plugins typeset -r FPATH_PARENT="/opt/hc/lib" # location of custom HC configuration files @@ -94,6 +94,7 @@ typeset HC_RUN="" typeset HC_FAIL_ID="" # shellcheck disable=SC2034 typeset HC_FILE_LINE="" +typeset HC_LOG_HEALTHY="" typeset HC_NOW="" typeset HC_TIME_OUT=60 typeset HC_MIN_TIME_OUT=30 @@ -101,6 +102,7 @@ typeset HC_MIN_TIME_OUT=30 typeset HC_MSG_VAR="" typeset HC_STDOUT_LOG="" typeset HC_STDERR_LOG="" +typeset HC_WILL_FIX="" # shellcheck disable=SC2034 typeset LINUX_DISTRO="" # shellcheck disable=SC2034 @@ -613,10 +615,11 @@ Parameters: --list-core : show the available core plugins (mail,SMS,...) --list-include : show the available includes/libraries --log-healthy : log/show also passed health checks. By default this is off when the plugin support this feature. - (can be overridden by --no-log to disable all logging) + (overrides \$HC_LOG_HEALTHY and can itself be overridden by --no-log to disable all logging) --mail-to : list of e-mail address(es) to which an e-mail alert will be send to [requires mail core plugin] --newer : show the (failed) events for each HC that are newer than the given date --no-fix : do not apply fix/healing logic for failed health checks (if available) + (overrides \$HC_WILL_FIX) --no-lock : disable locking to allow concurrent script executions --no-log : do not log any messages to the script log file or health check results. --no-monitor : do not stop the execution of a HC after \$HC_TIME_OUT seconds @@ -630,7 +633,7 @@ Parameters: --sms-provider : name of a supported SMS provider (see \$SMS_PROVIDERS) [requires SMS core plugin] --sms-to : name of person or group to which a sms alert will be send to [requires SMS core plugin] --timeout : maximum runtime of a HC plugin in seconds (overrides \$HC_TIME_OUT) ---today : show today's (failed) events (HC and their combined STC value) +--today : show (failed) events of today (HC and their combined STC value) --version : show the timestamp of the script. --with-history : also include events that have been archived already (reporting) --with-rc : define RC handling (plugin) when --flip-rc is used @@ -743,6 +746,24 @@ else . "${CONFIG_FILE}" fi +# reconcile global settings w/ cmd-line parameters +if (( ARG_LOG_HEALTHY == 0 )) +then + case "${HC_LOG_HEALTHY}" in + yes|YES|Yes) + ARG_LOG_HEALTHY=1 + ;; + esac +fi +if (( ARG_NO_FIX == 0 )) +then + case "${HC_WILL_FIX}" in + no|NO|No) + ARG_NO_FIX=1 + ;; + esac +fi + return 0 } diff --git a/opt/hc/lib/platform/linux/check_linux_autofs.sh b/opt/hc/lib/platform/linux/check_linux_autofs.sh index 7c617d9..c1e180a 100644 --- a/opt/hc/lib/platform/linux/check_linux_autofs.sh +++ b/opt/hc/lib/platform/linux/check_linux_autofs.sh @@ -33,7 +33,7 @@ function check_linux_autofs { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-07-14" # YYYY-MM-DD +typeset _VERSION="2019-10-24" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # shellcheck disable=SC2034 typeset _HC_CAN_FIX=1 # plugin has fix/healing logic? @@ -136,6 +136,13 @@ fi # check if autofs is enabled log "checking if autofs daemon is enabled" _HAS_SERVICE=$(linux_has_service "autofs") +(( $? > 0)) && { + _MSG="error in function {linux_has_service}" + log_hc "$0" 1 "${_MSG}" + # dump debug info + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 +} if (( _HAS_SERVICE == 2 )) then _MSG="autofs service is enabled" @@ -147,6 +154,13 @@ then # check if autofs is running log "checking if autofs daemon is active" _IS_ACTIVE=$(linux_runs_service autofs) + (( $? > 0)) && { + _MSG="error in function {linux_runs_service }" + log_hc "$0" 1 "${_MSG}" + # dump debug info + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 + } if (( _IS_ACTIVE > 0 )) then _MSG="autofs daemon is running" @@ -170,9 +184,23 @@ then sleep ${_SLEEP_TIME} _RETRY_COUNT=$(( _RETRY_COUNT + 1 )) _IS_ACTIVE=$(linux_runs_service "autofs") + (( $? > 0)) && { + _MSG="error in function {linux_runs_service }" + log_hc "$0" 1 "${_MSG}" + # dump debug info + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 + } done # check again if autofs is running _IS_ACTIVE=$(linux_runs_service "autofs") + (( $? > 0)) && { + _MSG="error in function {linux_runs_service }" + log_hc "$0" 1 "${_MSG}" + # dump debug info + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 + } if (( _IS_ACTIVE > 0 )) then _MSG="autofs daemon is running"