From c9c02c0d0f7e986676413a803ab61731ecfb747b Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Sun, 27 Jan 2019 19:39:57 +0100 Subject: [PATCH] * Fix for slow --report --last * Fix for data_is_numeric() calls --- sources/lib/core/include_core.sh | 7 +---- sources/lib/core/report_std.sh | 10 ++++++- .../lib/platform/hp-ux/check_hpux_fs_usage.sh | 19 ++++++++----- .../platform/hp-ux/check_hpux_sfm_status.sh | 6 ++--- .../platform/linux/check_linux_fs_usage.sh | 27 +++++++++++-------- .../linux/check_linux_process_limits.sh | 12 ++++----- 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/sources/lib/core/include_core.sh b/sources/lib/core/include_core.sh index a9ba35e..c572287 100644 --- a/sources/lib/core/include_core.sh +++ b/sources/lib/core/include_core.sh @@ -557,11 +557,6 @@ then then die "you cannot specify '--today' with '--id'" fi - # switch on history for --last & --today - if (( ARG_LAST > 0 )) || (( ARG_TODAY > 0 )) - then - ARG_HISTORY=1 - fi fi if (( DO_REPORT_STD == 0 )) && (( ARG_LAST > 0 )) then @@ -853,7 +848,7 @@ then # determine ALL_MSG_STC (sum of all STCs) ALL_MSG_STC=$(print "${HC_MSG_VAR}" | awk -F"${MSG_SEP}" 'BEGIN { stc = 0 } { for (i=1;i<=NF;i++) { stc = stc + $1 }} END { print stc }' 2>/dev/null) (( ARG_DEBUG > 0 )) && debug "HC all STC: ${ALL_MSG_STC}" - data_is_numeric ${ALL_MSG_STC} || die "HC all STC computes to a non-numeric value" + data_is_numeric "${ALL_MSG_STC}" || die "HC all STC computes to a non-numeric value" else # nothing to do return 0 diff --git a/sources/lib/core/report_std.sh b/sources/lib/core/report_std.sh index fe890ce..aa3140e 100644 --- a/sources/lib/core/report_std.sh +++ b/sources/lib/core/report_std.sh @@ -30,7 +30,7 @@ function report_std { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-01-27" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -198,6 +198,14 @@ else fi fi +# general note: history or not? +if (( ARG_HISTORY > 0 )) +then + print "NOTE: showing results with all history (archive) included (--with-history)" +else + print "NOTE: showing results only of current log entries (use --with-history to view all entries)" +fi + # check consistency of log(s) find ${_LOG_STASH} -type f -print 2>/dev/null | while read _CHECK_FILE do diff --git a/sources/lib/platform/hp-ux/check_hpux_fs_usage.sh b/sources/lib/platform/hp-ux/check_hpux_fs_usage.sh index 42fa5ef..d217223 100644 --- a/sources/lib/platform/hp-ux/check_hpux_fs_usage.sh +++ b/sources/lib/platform/hp-ux/check_hpux_fs_usage.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2019-01-24: initial version [Patrick Van der Veken] +# @(#) 2019-01-27: regex fix [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_hpux_fs_usage { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-01-27" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -175,7 +176,7 @@ then warn "missing filesystem name and/or threshold in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" continue fi - data_is_numeric ${_CFG_INODES_THRESHOLD} + data_is_numeric "${_CFG_INODES_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -186,8 +187,9 @@ then (( ARG_DEBUG > 0 )) && debug "found out-of-bounds inodes threshold for ${_CFG_FS}, using general threshold" _CFG_INODES_THRESHOLD=${_CFG_MAX_INODES_USAGE} fi + # add space to grep must be non-greedy! _INODES_USAGE=$(grep -E -e "^${_CFG_FS} " ${HC_STDOUT_LOG} 2>/dev/null | awk '{print $2}' 2>/dev/null) - data_is_numeric ${_INODES_USAGE} + data_is_numeric "${_INODES_USAGE}" if (( $? > 0 )) then warn "discovered value for inode usage is incorrect [${_CFG_FS}:${_INODES_USAGE}]" @@ -222,7 +224,7 @@ then warn "missing filesystem name and/or threshold in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" continue fi - data_is_numeric ${_CFG_SPACE_THRESHOLD} + data_is_numeric "${_CFG_SPACE_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -233,8 +235,9 @@ then (( ARG_DEBUG > 0 )) && debug "found out-of-bounds space threshold for ${_CFG_FS}, using general threshold" _CFG_SPACE_THRESHOLD=${_CFG_MAX_SPACE_USAGE} fi + # add space to grep must be non-greedy! _SPACE_USAGE=$(grep -E -e "^${_CFG_FS} " ${HC_STDOUT_LOG} 2>/dev/null | awk '{print $3}' 2>/dev/null) - data_is_numeric ${_SPACE_USAGE} + data_is_numeric "${_SPACE_USAGE}" if (( $? > 0 )) then warn "discovered value for space usage is incorrect [${_CFG_FS}:${_SPACE_USAGE}]" @@ -262,8 +265,9 @@ else while read _FS do # a) --- inodes --- + # add space to grep must be non-greedy! _INODES_USAGE=$(grep "^${_FS} " ${HC_STDOUT_LOG} 2>/dev/null | awk '{print $2}' 2>/dev/null) - data_is_numeric ${_INODES_USAGE} + data_is_numeric "${_INODES_USAGE}" if (( $? > 0 )) then warn "discovered value for inode usage is incorrect [${_FS}:${_INODES_USAGE}]" @@ -283,8 +287,9 @@ else log_hc "$0" ${_STC} "${_MSG}" ${_INODES_USAGE} ${_CFG_MAX_INODES_USAGE} fi # b) --- space --- + # add space to grep must be non-greedy! _SPACE_USAGE=$(grep "^${_FS} " ${HC_STDOUT_LOG} 2>/dev/null | awk '{print $3}' 2>/dev/null) - data_is_numeric ${_SPACE_USAGE} + data_is_numeric "${_SPACE_USAGE}" if (( $? > 0 )) then warn "discovered value for space usage is incorrect [${_FS}:${_SPACE_USAGE}]" 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 425138d..cd20083 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh @@ -24,7 +24,7 @@ # # @(#) HISTORY: # @(#) 2018-10-28: initial version [Patrick Van der Veken] -# @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-01-27: arguments fix [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +37,7 @@ typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _SFMCONFIG_BIN="/opt/sfm/bin/sfmconfig" typeset _EVWEB_BIN="/opt/sfm/bin/evweb" typeset _CIMPROVIDER_BIN="/opt/wbem/bin/cimprovider" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-01-27" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -152,7 +152,7 @@ then then _WAIT_TEST_EVENT=60 else - data_is_numeric ${_WAIT_TEST_EVENT} + data_is_numeric "${_WAIT_TEST_EVENT}" if (( $? > 0 )) then warn "invalid wait test event value '${_WAIT_TEST_EVENT}' in configuration file at ${_CONFIG_FILE}" diff --git a/sources/lib/platform/linux/check_linux_fs_usage.sh b/sources/lib/platform/linux/check_linux_fs_usage.sh index 0eab0c3..0b31ee6 100644 --- a/sources/lib/platform/linux/check_linux_fs_usage.sh +++ b/sources/lib/platform/linux/check_linux_fs_usage.sh @@ -23,6 +23,7 @@ # # @(#) HISTORY: # @(#) 2019-01-24: initial version [Patrick Van der Veken] +# @(#) 2019-01-27: regex fix [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_linux_fs_usage { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-01-27" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -190,7 +191,7 @@ then warn "missing filesystem name and/or threshold in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" continue fi - data_is_numeric ${_CFG_INODES_THRESHOLD} + data_is_numeric "${_CFG_INODES_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -201,8 +202,9 @@ then (( ARG_DEBUG > 0 )) && debug "found out-of-bounds inodes threshold for ${_CFG_FS}, using general threshold" _CFG_INODES_THRESHOLD=${_CFG_MAX_INODES_USAGE} fi - _INODES_USAGE=$(grep -E -e "${_CFG_FS}$" ${_INODES_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) - data_is_numeric ${_INODES_USAGE} + # add space to grep must be non-greedy! + _INODES_USAGE=$(grep -E -e " ${_CFG_FS}$" ${_INODES_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) + data_is_numeric "${_INODES_USAGE}" if (( $? > 0 )) then warn "discovered value for inodes usage is incorrect [${_CFG_FS}:${_INODES_USAGE}]" @@ -241,7 +243,7 @@ then warn "missing filesystem name and/or threshold in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" continue fi - data_is_numeric ${_CFG_SPACE_THRESHOLD} + data_is_numeric "${_CFG_SPACE_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -252,8 +254,9 @@ then (( ARG_DEBUG > 0 )) && debug "found out-of-bounds space threshold for ${_CFG_FS}, using general threshold" _CFG_SPACE_THRESHOLD=${_CFG_MAX_SPACE_USAGE} fi - _SPACE_USAGE=$(grep -E -e "${_CFG_FS}$" ${_SPACE_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) - data_is_numeric ${_SPACE_USAGE} + # add space to grep must be non-greedy! + _SPACE_USAGE=$(grep -E -e " ${_CFG_FS}$" ${_SPACE_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) + data_is_numeric "${_SPACE_USAGE}" if (( $? > 0 )) then warn "discovered value for space usage is incorrect [${_CFG_FS}:${_SPACE_USAGE}]" @@ -287,8 +290,9 @@ else # a) --- inodes (df -Pil) --- if (( _DO_INODES > 0 )) then - _INODES_USAGE=$(grep -E -e "${_FS}$" ${_INODES_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) - data_is_numeric ${_INODES_USAGE} + # add space to grep must be non-greedy! + _INODES_USAGE=$(grep -E -e " ${_FS}$" ${_INODES_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) + data_is_numeric "${_INODES_USAGE}" if (( $? > 0 )) then warn "discovered value for inodes usage is incorrect [${_FS}:${_INODES_USAGE}]" @@ -315,8 +319,9 @@ else # b) --- space (df -Pl) --- if (( _DO_SPACE > 0 )) then - _SPACE_USAGE=$(grep -E -e "${_FS}$" ${_SPACE_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) - data_is_numeric ${_SPACE_USAGE} + # add space to grep must be non-greedy! + _SPACE_USAGE=$(grep -E -e " ${_FS}$" ${_SPACE_FILE} 2>/dev/null | awk '{gsub(/%/,"",$5);print $5}' 2>/dev/null) + data_is_numeric "${_SPACE_USAGE}" if (( $? > 0 )) then warn "discovered value for space usage is incorrect [${_FS}:${_SPACE_USAGE}]" diff --git a/sources/lib/platform/linux/check_linux_process_limits.sh b/sources/lib/platform/linux/check_linux_process_limits.sh index e12fe1f..42c91b2 100644 --- a/sources/lib/platform/linux/check_linux_process_limits.sh +++ b/sources/lib/platform/linux/check_linux_process_limits.sh @@ -26,7 +26,7 @@ # @(#) 2018-07-12: better log_healthy handling [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken] -# @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-01-27: arguments fix [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -36,7 +36,7 @@ function check_linux_process_limits { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-01-27" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -125,7 +125,7 @@ do fi if [[ -n "${_PROCESS_SOFT_THRESHOLD}" ]] then - data_is_numeric ${_PROCESS_SOFT_THRESHOLD} + data_is_numeric "${_PROCESS_SOFT_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -134,7 +134,7 @@ do fi if [[ -n "${_PROCESS_HARD_THRESHOLD}" ]] then - data_is_numeric ${_PROCESS_HARD_THRESHOLD} + data_is_numeric "${_PROCESS_HARD_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -189,7 +189,7 @@ do fi if [[ -n "${_USER_SOFT_THRESHOLD}" ]] then - data_is_numeric ${_USER_SOFT_THRESHOLD} + data_is_numeric "${_USER_SOFT_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" @@ -198,7 +198,7 @@ do fi if [[ -n "${_USER_HARD_THRESHOLD}" ]] then - data_is_numeric ${_USER_HARD_THRESHOLD} + data_is_numeric "${_USER_HARD_THRESHOLD}" if (( $? > 0 )) then warn "parameter is not numeric in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}"