From 347377d47574cf2a1ece3d07f1c0cd4718992e39 Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Wed, 11 Jul 2018 10:50:45 +0200 Subject: [PATCH] * Added log_healthy to check_hpux_ovpa_status plugin * Better log_healthy handling in check_linux_process_limits plugin * Fix for empty HC_MSG_FILE in handle_hc() --- sources/lib/core/include_core.sh | 5 ++- .../platform/hp-ux/check_hpux_ovpa_status.sh | 31 ++++++++++++--- .../linux/check_linux_process_limits.sh | 39 ++++++++++++------- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/sources/lib/core/include_core.sh b/sources/lib/core/include_core.sh index 0ea8dd2..7ac6b37 100644 --- a/sources/lib/core/include_core.sh +++ b/sources/lib/core/include_core.sh @@ -799,7 +799,7 @@ typeset HC_STDOUT_LOG_SHORT="" typeset HC_STDERR_LOG_SHORT="" typeset HC_MSG_ENTRY="" typeset HC_STC_RC=0 -typeset ONE_MSG_STC="" +typeset ONE_MSG_STC=0 typeset ONE_MSG_TIME="" typeset ONE_MSG_TEXT="" typeset ONE_MSG_CUR_VAL="" @@ -824,6 +824,9 @@ then ALL_MSG_STC=$(print "${HC_MSG_VAR}" | awk -F"${MSG_SEP}" 'BEGIN { stc = 0 } { for (i=1;i<=NF;i++) { stc = stc + $1 }} END { print stc }' 2>/dev/null) (( ARG_DEBUG != 0 )) && debug "HC all STC: ${ALL_MSG_STC}" $(data_is_numeric ${ALL_MSG_STC}) || die "HC all STC computes to a non-numeric value" +else + # nothing to do + return 0 fi # display routines 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 c7d3a8f..54d9c0f 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2016-04-08: initial version [Patrick Van der Veken] # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] +# @(#) 2018-07-10: added log_healthy hc_arg [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_hpux_ovpa_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2016-12-01" # YYYY-MM-DD +typeset _VERSION="2018-07-10" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _OVPA_BIN="/opt/perf/bin/perfstat" # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,6 +45,7 @@ typeset _ARGS=$(data_space2comma "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 typeset _OVPA_MATCH=0 typeset _OVPA_VERSION="" typeset _OVPA_DAEMONS="" @@ -52,12 +54,28 @@ typeset _OVPA_DAEMONS="" for _ARG in ${_ARGS} do case "${_ARG}" in + log_healthy) + _LOG_HEALTHY=1 + ;; help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; + ;; esac done +# log_healthy +if (( _LOG_HEALTHY > 0 )) +then + if (( ARG_LOG > 0 )) + then + log "logging/showing passed health checks" + else + log "showing passed health checks (but not logging)" + fi +else + log "not logging/showing passed health checks" +fi + # check & get ovpa status if [[ ! -x ${_OVPA_BIN} ]] then @@ -96,9 +114,12 @@ do ;; esac - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" - _STC=0 + # handle result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + _STC=0 + fi done return 0 diff --git a/sources/lib/platform/linux/check_linux_process_limits.sh b/sources/lib/platform/linux/check_linux_process_limits.sh index 2ff1bf8..739012b 100644 --- a/sources/lib/platform/linux/check_linux_process_limits.sh +++ b/sources/lib/platform/linux/check_linux_process_limits.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2018-07-10: original version [Patrick Van der Veken] +# @(#) 2018-07-11: better log_healthy handling [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_linux_process_limits { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2018-07-10" # YYYY-MM-DD +typeset _VERSION="2018-07-11" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -45,6 +46,7 @@ typeset _MSG="" typeset _STC=0 typeset _DUMMY="" typeset _LINE_COUNT=1 +typeset _CFG_HEALTHY="" typeset _LOG_HEALTHY=0 typeset _MAX_OPEN_FILES=0 typeset _MAX_PROCESSES=0 @@ -70,6 +72,9 @@ trap "rm -f ${_INSTANCE_RUN_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 for _ARG in ${_ARGS} do case "${_ARG}" in + log_healthy) + _LOG_HEALTHY=1 + ;; help) _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 ;; @@ -84,23 +89,29 @@ then return 1 fi # read required configuration values -_LOG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') -case "${_LOG_HEALTHY}" in - no|NO|No) - _LOG_HEALTHY=0 - log "not logging/showing passed health checks" - ;; - *) +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) _LOG_HEALTHY=1 - if (( ARG_LOG > 0 )) - then - log "logging/showing passed health checks" - else - log "showing passed health checks (but not logging)" - fi + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 ;; esac +# log_healthy +if (( _LOG_HEALTHY > 0 )) +then + if (( ARG_LOG > 0 )) + then + log "logging/showing passed health checks" + else + log "showing passed health checks (but not logging)" + fi +else + log "not logging/showing passed health checks" +fi + # check PROCESS stanzas grep -i '^process' ${_CONFIG_FILE} 2>/dev/null |\ while IFS=';' read _DUMMY _PROCESS _PROCESS_LIMIT _PROCESS_SOFT_THRESHOLD _PROCESS_HARD_THRESHOLD