diff --git a/configs/etc/check_hpux_drd_status.conf.dist b/configs/etc/check_hpux_drd_status.conf.dist index 8ab1131..63e2169 100644 --- a/configs/etc/check_hpux_drd_status.conf.dist +++ b/configs/etc/check_hpux_drd_status.conf.dist @@ -6,6 +6,11 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # check clone age? (yes|no) # [default: yes] check_clone="yes" diff --git a/configs/etc/check_hpux_file_age.conf.dist b/configs/etc/check_hpux_file_age.conf.dist index 7ef9959..9c2a8cc 100644 --- a/configs/etc/check_hpux_file_age.conf.dist +++ b/configs/etc/check_hpux_file_age.conf.dist @@ -6,9 +6,19 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** -# file (full path); maximum age in minutes since last change -/var/adm/syslog/syslog.log;60 +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + +# specify file details +# Format: +# file:: +# Examples: +#file:/var/log/messages:60 +#file:/var/log/ntp.log:30 + #****************************************************************************** # End of FILE -#****************************************************************************** \ No newline at end of file +#****************************************************************************** diff --git a/configs/etc/check_hpux_file_change.conf.dist b/configs/etc/check_hpux_file_change.conf.dist index d89316c..3e1d3a5 100644 --- a/configs/etc/check_hpux_file_change.conf.dist +++ b/configs/etc/check_hpux_file_change.conf.dist @@ -6,6 +6,11 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # name of the state file to use (will be relative to /var/opt/hc/state/persistent # [default: discovered.file_change] state_file=discovered.file_change diff --git a/configs/etc/check_hpux_fs_mounts_options.conf.dist b/configs/etc/check_hpux_fs_mounts_options.conf.dist index 0e8dc20..165620b 100644 --- a/configs/etc/check_hpux_fs_mounts_options.conf.dist +++ b/configs/etc/check_hpux_fs_mounts_options.conf.dist @@ -6,6 +6,11 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # specify whether non-mounted FS should be alerted on (yes|no) # [default: yes] ignore_missing_fs="yes" diff --git a/configs/etc/check_hpux_hpvm_vpar_status.conf.dist b/configs/etc/check_hpux_hpvm_vpar_status.conf.dist index af0ac12..7bd2745 100644 --- a/configs/etc/check_hpux_hpvm_vpar_status.conf.dist +++ b/configs/etc/check_hpux_hpvm_vpar_status.conf.dist @@ -6,12 +6,18 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # specify properties as displayed by the 'vzlist -a -H -o ctid,status,onboot' command -# [parid;runtime_status;boot_status] +# Format: +# [vpar:::] # runtime_status should be 'on' or 'off' # boot_status should be 'auto' or 'manual' # Examples: -#1;on;auto +#vpar:1:on:auto #****************************************************************************** diff --git a/configs/etc/check_hpux_ioscan.conf.dist b/configs/etc/check_hpux_ioscan.conf.dist index d45eed4..04cdb14 100644 --- a/configs/etc/check_hpux_ioscan.conf.dist +++ b/configs/etc/check_hpux_ioscan.conf.dist @@ -6,6 +6,11 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # comma-separated list of HW device classes that should be checked # [default: ctl,diag,disk,ext_bus,fc,fcp,i2o,ipmi,lan,lvm,olar,vxvm] ioscan_classes="ctl,diag,disk,ext_bus,fc,fcp,i2o,ipmi,lan,lvm,olar,vxvm" diff --git a/configs/etc/check_hpux_kernel_params.conf.dist b/configs/etc/check_hpux_kernel_params.conf.dist index bfaf2db..a2f61af 100644 --- a/configs/etc/check_hpux_kernel_params.conf.dist +++ b/configs/etc/check_hpux_kernel_params.conf.dist @@ -6,8 +6,14 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # specify kernel parameters and their values or expression (as reported by kctune) -# [param::] +# Format: +# [param::] # Examples: #param:nproc:5000 #param:filecache_max:50% diff --git a/configs/etc/check_hpux_kernel_usage.conf.dist b/configs/etc/check_hpux_kernel_usage.conf.dist index ddfa705..15061d1 100644 --- a/configs/etc/check_hpux_kernel_usage.conf.dist +++ b/configs/etc/check_hpux_kernel_usage.conf.dist @@ -6,15 +6,21 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # specify a general maximum usage threshold (percentage) # [ default: 90% ] max_kcusage=90 # specify individual kernel parameters and their maximum usage threshold (percentage) # definitions here will overrides max_kcusage for these parameters -# [param::] +# Format: +# [param::] # Examples: -# param:nproc:70 +#param:nproc:70 # specify parameters that should be excluded from the check # comma-separated list (as shown by kctune/kcusage) diff --git a/configs/etc/check_hpux_ovpa_status.conf.dist b/configs/etc/check_hpux_ovpa_status.conf.dist index d93ad45..3b658b3 100644 --- a/configs/etc/check_hpux_ovpa_status.conf.dist +++ b/configs/etc/check_hpux_ovpa_status.conf.dist @@ -15,6 +15,7 @@ log_healthy="yes" # [default: oacore,midaemon,perfalarm,ttd,ovcd,ovbbccb,perfd (v12)] ovpa_daemons="" + #****************************************************************************** # End of FILE #****************************************************************************** diff --git a/configs/etc/check_hpux_root_crontab.conf.dist b/configs/etc/check_hpux_root_crontab.conf.dist index 3dc7d28..a338255 100644 --- a/configs/etc/check_hpux_root_crontab.conf.dist +++ b/configs/etc/check_hpux_root_crontab.conf.dist @@ -6,8 +6,17 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # list of commands (or strings) that should appear in active cron entries -/opt/cfg2html/cfg2html_hpux.sh +# Format: +# cron: +# Examples: +#cron:/opt/cfg2html/cfg2html_hpux.sh + #****************************************************************************** # End of FILE diff --git a/configs/etc/check_hpux_sg_cluster_status.conf.dist b/configs/etc/check_hpux_sg_cluster_status.conf.dist index 26425a1..27a47c2 100644 --- a/configs/etc/check_hpux_sg_cluster_status.conf.dist +++ b/configs/etc/check_hpux_sg_cluster_status.conf.dist @@ -6,9 +6,16 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** -# list of required cluster statuses (format : "parameter=value") +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + +# list of required cluster statuses +# Format: +# sg:= # Examples: -#status=up +#sg:status=up #****************************************************************************** diff --git a/configs/etc/check_hpux_sg_package_status.conf.dist b/configs/etc/check_hpux_sg_package_status.conf.dist index 44bd3b8..dd2c1ab 100644 --- a/configs/etc/check_hpux_sg_package_status.conf.dist +++ b/configs/etc/check_hpux_sg_package_status.conf.dist @@ -6,9 +6,16 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** -# list of required package statuses (format : "package_name:parameter=value") +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + +# list of required package statuses +# Format: +# sg::= # Examples: -#my_package|status=up +#sg:my_package:status=up #****************************************************************************** diff --git a/configs/etc/check_hpux_syslog.conf.dist b/configs/etc/check_hpux_syslog.conf.dist index 7f84862..50c8965 100644 --- a/configs/etc/check_hpux_syslog.conf.dist +++ b/configs/etc/check_hpux_syslog.conf.dist @@ -6,6 +6,11 @@ # [default: indicates hardcoded script values if no value is defined here] #****************************************************************************** +# specify whether to also log passed health checks +# (warning: this may rapidly grow the HC log) +# [default: no] +log_healthy="no" + # path to the SYSLOG file # [default: /var/adm/syslog/syslog.log] syslog_file="/var/adm/syslog/syslog.log" diff --git a/sources/lib/platform/hp-ux/check_hpux_autopath.sh b/sources/lib/platform/hp-ux/check_hpux_autopath.sh index e98b0d4..f60e820 100644 --- a/sources/lib/platform/hp-ux/check_hpux_autopath.sh +++ b/sources/lib/platform/hp-ux/check_hpux_autopath.sh @@ -19,12 +19,13 @@ # @(#) MAIN: check_hpux_autopath # DOES: see _show_usage(). # EXPECTS: n/a -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2013-08-29: initial version [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -35,7 +36,7 @@ function check_hpux_autopath # ------------------------- CONFIGURATION starts here ------------------------- typeset _AUTOPATH_BIN="/sbin/autopath" typeset _AUTOPATH_NEEDLE="Failed" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,6 +48,7 @@ typeset _ARG="" typeset _MSG="" typeset _STC=0 typeset _STC_COUNT=0 +typeset _LOG_HEALTHY=0 typeset _AUTOPATH_LINE="" typeset _DEVICE="" @@ -60,6 +62,20 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 autopath presence if [[ ! -x ${_AUTOPATH_BIN} ]] then @@ -87,13 +103,16 @@ do _STC=1 _STC_COUNT=$(( _STC_COUNT + 1 )) - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi _STC=0 done # report OK situation -if (( _STC_COUNT == 0 )) +if (( _LOG_HEALTHY > 0 && _STC_COUNT == 0 )) then _MSG="no failed paths detected by {${_AUTOPATH_BIN}}" log_hc "$0" 0 "${_MSG}" @@ -106,11 +125,11 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether failed paths exist for StorageWorks disk arrays - using the 'autopath' utility. +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether failed paths exist for StorageWorks disk arrays + using the 'autopath' utility. +LOG HEALTHY : Supported EOT 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 786612d..6410b1c 100644 --- a/sources/lib/platform/hp-ux/check_hpux_drd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_drd_status.sh @@ -30,6 +30,7 @@ # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-31: better result check for DRD output [Patrick Van der Veken] # @(#) 2019-02-08: fix for mirrored boot disks [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -40,7 +41,7 @@ function check_hpux_drd_status # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _DRD_BIN="/opt/drd/bin/drd" -typeset _VERSION="2019-02-08" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -50,6 +51,8 @@ init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}" typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _RC=0 typeset _CHECK_CLONE="" typeset _CHECK_SYNC="" @@ -111,6 +114,30 @@ then _CHECK_SYNC="yes" fi _SYNC_MAX_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'sync_age') +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 # get drd status if [[ ! -x ${_DRD_BIN} ]] @@ -145,10 +172,16 @@ then [[ "${_BOOTED_DISK}" = "${_ACTIVE_DISK}" ]] then _MSG="host was booted from original disk (${_ACTIVE_DISK})" - log_hc "$0" 0 "${_MSG}" + if (( _LOG_HEALTHY > 0 )) + then + log_hc "$0" 0 "${_MSG}" + fi else _MSG="host was booted from clone disk (${_ACTIVE_DISK})" - log_hc "$0" 0 "${_MSG}" + if (( _LOG_HEALTHY > 0 )) + then + log_hc "$0" 0 "${_MSG}" + fi fi # check EFI status @@ -156,7 +189,10 @@ then if [[ "${_EFI_CLONE}" = "AUTO file present, Boot loader present" ]] then _MSG="clone disk ${_CLONE_DISK} has a bootable EFI partition" - log_hc "$0" 0 "${_MSG}" + if (( _LOG_HEALTHY > 0 )) + then + log_hc "$0" 0 "${_MSG}" + fi else _MSG="clone disk ${_CLONE_DISK} does not have a bootable EFI partition" log_hc "$0" 1 "${_MSG}" @@ -165,7 +201,10 @@ then if [[ "${_EFI_ORIGINAL}" = "AUTO file present, Boot loader present" ]] then _MSG="original disk ${_ORIGINAL_DISK} has a bootable EFI partition" - log_hc "$0" 0 "${_MSG}" + if (( _LOG_HEALTHY > 0 )) + then + log_hc "$0" 0 "${_MSG}" + fi else _MSG="original disk ${_ORIGINAL_DISK} does not have a bootable EFI partition" log_hc "$0" 1 "${_MSG}" @@ -195,7 +234,10 @@ then if (( _CLONE_EPOCH > (_NOW_EPOCH - (_CLONE_MAX_AGE * 24 * 60 * 60)) )) then _MSG="clone age is younger than ${_CLONE_MAX_AGE} days [${_CLONE_DATE}]" - log_hc "$0" 0 "${_MSG}" + if (( _LOG_HEALTHY > 0 )) + then + log_hc "$0" 0 "${_MSG}" + fi else _MSG="clone age is older than ${_CLONE_MAX_AGE} days [${_CLONE_DATE}]" log_hc "$0" 1 "${_MSG}" @@ -232,7 +274,10 @@ then if (( _SYNC_EPOCH > (_NOW_EPOCH - (_SYNC_MAX_AGE * 24 * 60 * 60)) )) then _MSG="sync age is younger than ${_SYNC_MAX_AGE} days [${_SYNC_DATE}]" - log_hc "$0" 0 "${_MSG}" + if (( _LOG_HEALTHY > 0 )) + then + log_hc "$0" 0 "${_MSG}" + fi else _MSG="sync age is older than ${_SYNC_MAX_AGE} days [${_SYNC_DATE}]" log_hc "$0" 1 "${_MSG}" @@ -259,16 +304,18 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - check_clone= - clone_age= - check_sync= - sync_age= -PURPOSE : Checks whether the DRD clone was correctly created - Checks for correct EFI partitions - Checks the age of the DRD clone and/or sync +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + check_clone= + clone_age= + check_sync= + sync_age= +PURPOSE : Checks whether the DRD clone was correctly created + Checks for correct EFI partitions + Checks the age of the DRD clone and/or sync +LOG HEALTHY : Supported EOT 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 ba2269c..c30bc47 100644 --- a/sources/lib/platform/hp-ux/check_hpux_file_age.sh +++ b/sources/lib/platform/hp-ux/check_hpux_file_age.sh @@ -19,7 +19,8 @@ # @(#) MAIN: check_hpux_file_age # DOES: see _show_usage() # EXPECTS: see _show_usage() -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: Perl, data_comma2space(), data_is_numeric(), init_hc(), +# log_hc(), warn() # # @(#) HISTORY: # @(#) 2013-05-27: initial version [Patrick Van der Veken] @@ -27,6 +28,8 @@ # @(#) 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-03-09: added code for data_is_numeric(), changed format of configuration +# @(#) file (; -> :) & added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -36,7 +39,7 @@ function check_hpux_file_age { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,6 +50,8 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _REF_FILE="${TMP_DIR}/.$0.ref.$$" typeset _DO_REF=0 typeset _ENTRY="" @@ -54,6 +59,7 @@ typeset _FILE_PATH="" typeset _FILE_AGE="" typeset _FILE_NAME="" typeset _FILE_DIR="" +typeset _IS_OLD_STYLE=0 # set local trap for cleanup # shellcheck disable=SC2064 @@ -76,14 +82,42 @@ then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# check for old-style configuration file (non-prefixed stanzas) +_IS_OLD_STYLE=$(grep -c -E -e "^file:" ${_CONFIG_FILE} 2>/dev/null) +if (( _IS_OLD_STYLE == 0 )) +then + warn "no 'file:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?" + return 1 +fi + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 # perform check -cat ${_CONFIG_FILE} | grep -v -E -e '^$' -e '^#' | while read _ENTRY +grep -E -e "^file:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _FILE_PATH _FILE_AGE do - # field split - _FILE_PATH=$(print "${_ENTRY%%;*}") - _FILE_AGE=$(print "${_ENTRY##*;}") - # split file/dir _FILE_NAME=$(print "${_FILE_PATH##*/}") _FILE_DIR=$(print "${_FILE_PATH%/*}") @@ -94,16 +128,12 @@ do warn "missing values in configuration file at ${_CONFIG_FILE}" return 1 fi - case "${_FILE_AGE}" in - +([0-9])*(.)*([0-9])) - # numeric, OK - ;; - *) - # not numeric - warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}" - return 1 - ;; - esac + data_is_numeric "${_FILE_AGE}" + if (( $? > 0 )) + then + warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}" + return 1 + fi # calculate reference timestamp & set reference file (once only) if (( _DO_REF == 0 )) @@ -122,7 +152,7 @@ do fi _DO_REF=1 fi -sleep 60 + sleep 60 # perform check if [[ ! -r "${_FILE_PATH}" ]] then @@ -145,8 +175,11 @@ sleep 60 fi fi - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi _STC=0 done @@ -160,12 +193,15 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - ; -PURPOSE : Checks whether given files have been changed in the last n minutes - (requires perl!) +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + and formatted stanzas: + file:: +PURPOSE : Checks whether given files have been changed in the last n minutes + (requires perl!) +LOG HEALTHY : Supported EOT 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 bd29458..88da27d 100644 --- a/sources/lib/platform/hp-ux/check_hpux_file_change.sh +++ b/sources/lib/platform/hp-ux/check_hpux_file_change.sh @@ -27,6 +27,7 @@ # @(#) 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-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -36,7 +37,7 @@ function check_hpux_file_change { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,6 +48,8 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _DO_META_CHECK=0 typeset _CFG_STATE_FILE="" typeset _STATE_FILE="" @@ -111,6 +114,30 @@ case "${_DO_META_CHECK}" in log "check for meta characters is enabled" ;; esac +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 for checksum tools _OPENSSL_BIN="$(which openssl 2>>${HC_STDERR_LOG})" @@ -293,7 +320,7 @@ do fi # bounce failures back and jump to next file - if (( _STC > 0 )) + if (( _LOG_HEALTHY > 0 || _STC > 0 )) then log_hc "$0" ${_STC} "${_MSG}" continue @@ -319,7 +346,11 @@ do printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE} # report with curr/exp values - log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}" + if (( _LOG_HEALTHY > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}" + continue + fi done <${_TMP1_FILE} # update state file (also if TMP2_FILE is empty) @@ -348,23 +379,26 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - incl: - excl: -PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes - of files and directories (automatically expanded). Excludes have a higher - priority than includes. Integrity checks will only be performed on files. - Will detect changed, new & deleted files (but not when deleted files - occur in an expanded directory tree). If you wish to detect deleted files: - use only direct file references in the configuration file. Uses by preference - openssl for hash calculation, with cksum as fall-back). - Updated and deleted files will cause a HC failure, new files will not. - CAVEAT EMPTOR: use only to check a relatively small number of files. +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + and formatted stanzas: + incl: + excl: +PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes + of files and directories (automatically expanded). Excludes have a higher + priority than includes. Integrity checks will only be performed on files. + Will detect changed, new & deleted files (but not when deleted files + occur in an expanded directory tree). If you wish to detect deleted files: + use only direct file references in the configuration file. Uses by preference + openssl for hash calculation, with cksum as fall-back). + Updated and deleted files will cause a HC failure, new files will not. + CAVEAT EMPTOR: use only to check a relatively small number of files. Processing a big number of files is likely to take ages and probably will cause the plugin to time out (see HC_TIME_OUT). YMMV. +LOG HEALTHY : Supported EOT 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 eb21226..c0cd04b 100644 --- a/sources/lib/platform/hp-ux/check_hpux_fs_mounts.sh +++ b/sources/lib/platform/hp-ux/check_hpux_fs_mounts.sh @@ -19,13 +19,14 @@ # @(#) MAIN: check_hpux_fs_mounts # DOES: see _show_usage() # EXPECTS: n/a -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2013-05-27: initial version [Patrick Van der Veken] # @(#) 2016-04-04: exclude dump/swap spaces (...) [Patrick Van der Veken] # @(#) 2016-07-04: fix for nfs exclusion [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_hpux_fs_mounts { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -45,6 +46,7 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 typeset _FS="" typeset _FS_COUNT=0 @@ -58,6 +60,20 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 + # collect data (mount only) mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} if (( $? > 0 )) @@ -86,8 +102,11 @@ do ;; esac - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi _STC=0 done @@ -101,10 +120,10 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether file systems are mounted or not +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether file systems are mounted or not +LOG HEALTHY : Supported EOT 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 7501dc5..52d8105 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 @@ -19,7 +19,7 @@ # @(#) MAIN: check_hpux_fs_mounts_options # DOES: see _show_usage() # EXPECTS: see _show_usage() -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2016-04-04: original version [Patrick Van der Veken] @@ -27,6 +27,7 @@ # @(#) 2017-07-31: added support for current/expected value output [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -36,7 +37,7 @@ function check_hpux_fs_mounts_options { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,6 +48,8 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _CONFIG_FS="" typeset _CONFIG_OPTS="" typeset _CURR_OPTS="" @@ -80,6 +83,30 @@ then # default _IGNORE_FS="yes" fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 # collect data (mount only) mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} @@ -110,15 +137,18 @@ do # compare strings (also flags FS that are not mounted) if [[ "${_CURR_SORTED_OPTS}" != "${_CFG_SORTED_OPTS}" ]] then - _MSG="${_CONFIG_FS} is not mounted with the correct options" - _STC=1 + _MSG="${_CONFIG_FS} is not mounted with the correct options" + _STC=1 else - _MSG="${_CONFIG_FS} is mounted with the correct options" + _MSG="${_CONFIG_FS} is mounted with the correct options" fi fi - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" "${_CURR_OPTS}" "${_CONFIG_OPTS}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_CURR_OPTS}" "${_CONFIG_OPTS}" + fi _STC=0 done @@ -129,13 +159,15 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with formatted stanzas: - fs:: - Other options: - ignore_missing_fs=yes|no -PURPOSE : Checks whether file systems are mounted with correct options +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + ignore_missing_fs= + and formatted stanzas: + fs:: +PURPOSE : Checks whether file systems are mounted with correct options +LOG HEALTHY : Supported EOT 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 a19d2ab..8b7e527 100644 --- a/sources/lib/platform/hp-ux/check_hpux_fs_usage.sh +++ b/sources/lib/platform/hp-ux/check_hpux_fs_usage.sh @@ -27,6 +27,7 @@ # @(#) 2019-01-30: refactored to support custom defintions with all # filesystems check [Patrick Van der Veken] # @(#) 2019-02-18: fixes + help update +# @(#) 2019-03-09: text fixes # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -36,7 +37,7 @@ function check_hpux_fs_usage { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-02-18" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -289,17 +290,19 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with formatted stanzas (optional): - fs::: - Other options: - log_healthy= - check_inodes_usage= - check_space_usage= - max_inodes_usage= - max_space_usage= -PURPOSE : Checks the inodes & space usage for the configured or all (local) filesystems +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + check_inodes_usage= + check_space_usage= + max_inodes_usage= + max_space_usage= + with formatted stanzas (optional): + fs::: +EXT OPTIONS : --hc-args=check_inodes, --hc-args=check_space +PURPOSE : Checks the inodes & space usage for the configured or all (local) filesystems +LOG HEALTHY : Supported EOT 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 56c21ce..f989a20 100644 --- a/sources/lib/platform/hp-ux/check_hpux_guid_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_guid_status.sh @@ -25,6 +25,7 @@ # @(#) 2017-05-18: initial version [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_hpux_guid_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -45,6 +46,7 @@ typeset _ARG="" typeset _GUID_PID="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 typeset _RC=0 # handle arguments (originally comma-separated) @@ -57,6 +59,20 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 + # ---- process state ---- # 1) try using the PID way if [[ -r "${_GUID_PID_FILE}" ]] @@ -101,8 +117,11 @@ case ${_STC} in ;; esac -# handle results -log_hc "$0" ${_STC} "${_MSG}" +# report result +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi return 0 } @@ -111,10 +130,10 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether guid daemons (VSP GUID) are running +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether guid daemons (VSP GUID) are running +LOG HEALTHY : Supported EOT 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 9590344..683b4e2 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 @@ -27,6 +27,8 @@ # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added code for data_is_numeric(), changed format of configuration +# @(#) file (; -> :) & added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +39,7 @@ function check_hpux_hpvm_vpar_status # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _HPVMSTATUS_BIN="/opt/hpvm/bin/hpvmstatus" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -57,6 +59,8 @@ typeset _PAR_ENTRY="" typeset _PAR_MATCH="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _RC=0 # handle arguments (originally comma-separated) @@ -69,6 +73,46 @@ do esac done +# handle configuration file +[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" +if [[ ! -r ${_CONFIG_FILE} ]] +then + warn "unable to read configuration file at ${_CONFIG_FILE}" + return 1 +fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# check for old-style configuration file (non-prefixed stanzas) +_IS_OLD_STYLE=$(grep -c -E -e "^vpar:" ${_CONFIG_FILE} 2>/dev/null) +if (( _IS_OLD_STYLE == 0 )) +then + warn "no 'vpar:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?" + return 1 +fi + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 HPVM if [[ ! -x ${_HPVMSTATUS_BIN} || -z "${_HPVMSTATUS_BIN}" ]] then @@ -86,24 +130,14 @@ ${_HPVMSTATUS_BIN} -M >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} } # check configuration values -grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _PAR_ENTRY +grep -E -e "^vpar:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _PAR_ID _PAR_CFG_STATUS _PAR_CFG_BOOT do - # field split - _PAR_ID=$(print "${_PAR_ENTRY}" | cut -f1 -d';') - _PAR_CFG_STATUS=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f2 -d';')") - _PAR_CFG_BOOT=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f3 -d';')") - # check configuration - case "${_PAR_ID}" in - +([0-9])*(.)*([0-9])) - # numeric, OK - ;; - *) - # not numeric - warn "invalid partition ID '${_PAR_ID}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" - return 1 - ;; - esac + data_is_numeric "${_PAR_ID}" + if (( $? > 0 )) + then + warn "invalid partition ID '${_PAR_ID}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" + fi case "${_PAR_CFG_STATUS}" in on|off) ;; @@ -124,13 +158,8 @@ do done # perform checks -grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _PAR_ENTRY +grep -E -e "^vpar:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _PAR_ID _PAR_CFG_STATUS _PAR_CFG_BOOT do - # field split - _PAR_ID=$(print "${_PAR_ENTRY}" | cut -f1 -d';') - _PAR_CFG_STATUS=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f2 -d';')") - _PAR_CFG_BOOT=$(data_lc "$(print \"${_PAR_ENTRY}\" | cut -f3 -d';')") - # check run-time values (we need to make the needle sufficiently less greedy) _PAR_MATCH=$(grep -i "^.*:.*:${_PAR_ID}::Integrity" ${HC_STDOUT_LOG} 2>/dev/null) if [[ -n "${_PAR_MATCH}" ]] @@ -157,7 +186,10 @@ do _MSG="partition ${_PAR_ID} has a wrong boot flag [${_PAR_RUN_BOOT}]" _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" "${_PAR_RUN_BOOT}" "${_PAR_CFG_BOOT}" + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_PAR_RUN_BOOT}" "${_PAR_CFG_BOOT}" + fi else warn "could not determine status for partition ${_PAR_ID} from command output {${_HPVMSTATUS_BIN}}" _RC=1 @@ -171,11 +203,14 @@ return ${_RC} function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - ;; -PURPOSE : Checks the status of vPars (on a VSP) +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + and formatted stanzas: + vpar::: +PURPOSE : Checks the status of vPars (on a VSP) +LOG HEALTHY : Supported EOT 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 fd542aa..93d74f9 100644 --- a/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_httpd_status.sh @@ -25,6 +25,7 @@ # @(#) 2017-04-23: initial version [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_hpux_httpd_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _HTTPD_PID_FILE="/var/run/httpd/httpd.pid" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -47,6 +48,7 @@ typeset _HTTPD_BIN="" typeset _HTTPD_PID="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 typeset _RC=0 # handle arguments (originally comma-separated) @@ -59,6 +61,20 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 + # ---- process state ---- # 1) try using the PID way if [[ -r "${_HTTPD_PID_FILE}" ]] @@ -94,7 +110,11 @@ case ${_STC} in _MSG="could not determine status of httpd" ;; esac -log_hc "$0" ${_STC} "${_MSG}" +# report result +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi # ---- config state ---- _HTTPD_BIN="$(which httpd 2>>${HC_STDERR_LOG})" @@ -110,7 +130,11 @@ then _MSG="httpd configuration files have syntax error(s) {httpd -s}" _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi fi return 0 @@ -120,10 +144,10 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether httpd (apache) is running +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether httpd (apache) is running +LOG HEALTHY : Supported EOT 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 d50341c..4b39093 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh @@ -19,7 +19,7 @@ # @(#) MAIN: check_hpux_ignite_backup # DOES: see _show_usage() # EXPECTS: see _show_usage() -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2013-05-28: initial version [Patrick Van der Veken] @@ -28,7 +28,8 @@ # @(#) 2016-06-03: small fix [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] -# @(#) 2019-01-31: Improve discovery routine + add log_healthy [Patrick Van der Veken] +# @(#) 2019-01-31: improve discovery routine + add log_healthy [Patrick Van der Veken] +# @(#) 2019-03-09: text updates [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -42,7 +43,7 @@ typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _IGNITE_NEEDLE="^DONE" typeset _IGNITE_SERVER_FILE="/var/opt/ignite/server/ignite.defs" typeset _IGNITE_CLIENTS_DIR="/var/opt/ignite/clients" -typeset _VERSION="2019-01-31" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -244,13 +245,15 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - backup_age= -PURPOSE : Checks the state and age of saved Ignite-UX client backups (should only be - run only on the Ignite-UX server). Backups with warnings are considered - to OK. Backups older than \$backup_age will not pass the health check. +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + backup_age= + exclude_hosts= +PURPOSE : Checks the state and age of saved Ignite-UX client backups (should only be + run only on the Ignite-UX server). Backups with warnings are considered + to OK. Backups older than \$backup_age will not pass the health check. LOG HEALTHY : Supported EOT diff --git a/sources/lib/platform/hp-ux/check_hpux_ioscan.sh b/sources/lib/platform/hp-ux/check_hpux_ioscan.sh index 575f9b5..9a46807 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ioscan.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ioscan.sh @@ -31,6 +31,7 @@ # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -42,7 +43,7 @@ function check_hpux_ioscan typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _IOSCAN_BIN="/usr/sbin/ioscan" typeset _IOSCAN_OPTS="-Fn" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -54,6 +55,8 @@ typeset _ARG="" typeset _MSG="" typeset _STC=0 typeset _STC_COUNT=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _CLASS_LINE="" typeset _IOSCAN_CLASSES="" typeset _AGILE_VIEW="" @@ -102,6 +105,30 @@ then # default _AGILE_VIEW="yes" fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 and get ioscan stuff if [[ ! -x ${_IOSCAN_BIN} ]] @@ -163,12 +190,16 @@ do continue esac - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi _STC=0 done # report OK situation -if (( _STC_COUNT == 0 )) +if (( _LOG_HEALTHY > 0 && _STC_COUNT == 0 )) then _MSG="no problems detected by {${_IOSCAN_BIN}}" log_hc "$0" 0 "${_MSG}" @@ -181,13 +212,16 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - ioscan_classes= - kernel_mode= - agile_view= -PURPOSE : Checks whether 'ioscan' returns errors or not (NO_HW, ERROR) +NAME : $1 +VERSION : $2 +CONFIG : $3 with: +CONFIG : $3 with parameters: + log_healthy= + ioscan_classes= + kernel_mode= + agile_view= +PURPOSE : Checks whether 'ioscan' returns errors or not (NO_HW, ERROR) +LOG HEALTHY : Supported EOT 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 f6f049c..c595e4d 100644 --- a/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh +++ b/sources/lib/platform/hp-ux/check_hpux_kernel_params.sh @@ -27,6 +27,7 @@ # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +38,7 @@ function check_hpux_kernel_params # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _KCTUNE_BIN="/usr/sbin/kctune" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -48,6 +49,8 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _PARAM_NAME="" typeset _CONFIG_VALUE="" typeset _CURR_VALUE="" @@ -73,6 +76,30 @@ then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 kctune information if [[ ! -x ${_KCTUNE_BIN} ]] @@ -140,8 +167,11 @@ do _REPORTED_VALUE="${_EXPR_VALUE}" fi - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" "${_REPORTED_VALUE}" "${_CONFIG_VALUE}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_REPORTED_VALUE}" "${_CONFIG_VALUE}" + fi _STC=0 done @@ -152,11 +182,14 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with formatted stanzas: - param:: -PURPOSE : Checks kernel parameters have a correct run-time value/expression +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + and formatted stanzas: + param:: +PURPOSE : Checks kernel parameters have a correct run-time value/expression +LOG HEALTHY : Supported EOT 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 869ce3a..5b965de 100644 --- a/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh +++ b/sources/lib/platform/hp-ux/check_hpux_kernel_usage.sh @@ -19,7 +19,8 @@ # @(#) MAIN: check_hpux_kernel_usage # DOES: see _show_usage() # EXPECTS: see _show_usage() -# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), data_is_numeric(), dump_logs(), init_hc(), +# log_hc(), warn() # # @(#) HISTORY: # @(#) 2017-12-22: original version [Patrick Van der Veken] @@ -28,6 +29,8 @@ # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added code for data_is_numeric() & +# @(#) support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -38,7 +41,7 @@ function check_hpux_kernel_usage # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _KCUSAGE_BIN="/usr/sbin/kcusage" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -49,6 +52,8 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _MAX_KCUSAGE=0 typeset _EXCLUDED_PARAMS="" typeset _HANDLED_PARAMS="" @@ -90,6 +95,30 @@ if [[ -n "${_EXCLUDED_PARAMS}" ]] then log "excluding following kernel parameters: ${_EXCLUDED_PARAMS}" fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 kcusage information if [[ ! -x ${_KCUSAGE_BIN} ]] @@ -126,21 +155,19 @@ do return 1 fi # check if the threshold value is correct (integer) - case "${_CONFIG_VALUE}" in - [0-9]*) - # numeric, OK - if (( _CONFIG_VALUE < 1 || _CONFIG_VALUE > 99 )) - then - warn "incorrect threshold value '${_CONFIG_VALUE}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" - return 1 - fi - ;; - *) - # not numeric - warn "invalid threshold value '${_CONFIG_VALUE}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" + data_is_numeric "${_CONFIG_VALUE}" + if (( $? == 0 )) + then + if (( _CONFIG_VALUE < 1 || _CONFIG_VALUE > 99 )) + then + warn "incorrect threshold value '${_CONFIG_VALUE}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" return 1 - ;; - esac + fi + else + # not numeric + warn "invalid threshold value '${_CONFIG_VALUE}' in configuration file ${_CONFIG_FILE} at data line ${_LINE_COUNT}" + return 1 + fi _LINE_COUNT=$(( _LINE_COUNT + 1 )) done @@ -164,8 +191,11 @@ do # push to handled list _HANDLED_PARAMS="${_HANDLED_PARAMS}\n${_PARAM_NAME}" - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" "${_CHECK_VALUE}" "${_CONFIG_VALUE}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_CHECK_VALUE}" "${_CONFIG_VALUE}" + fi _STC=0 done @@ -198,8 +228,11 @@ do _MSG="${_PARAM_NAME} is below the general threshold (${_CHECK_VALUE}% <= ${_MAX_KCUSAGE}%)" fi - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" "${_CHECK_VALUE}" "${_MAX_KCUSAGE}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_CHECK_VALUE}" "${_MAX_KCUSAGE}" + fi _STC=0 fi done @@ -211,14 +244,16 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with formatted stanzas: - param:: - Other options: - max_kcusage= - exclude_params= -PURPOSE : Checks the current usage of kernel paremeter resources +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + max_kcusage= + exclude_params= + and formatted stanzas: + param:: +PURPOSE : Checks the current usage of kernel paremeter resources +LOG HEALTHY : Supported EOT diff --git a/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh b/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh index ac7b71f..fb21086 100644 --- a/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh +++ b/sources/lib/platform/hp-ux/check_hpux_lunpaths.sh @@ -27,6 +27,7 @@ # @(#) [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-09-03: small variable fix [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -39,7 +40,7 @@ typeset _IOSCAN_BIN="/usr/sbin/ioscan" typeset _IOSCAN_OPTS="-C disk -P wwid" typeset _SCSIMGR_BIN="/usr/sbin/scsimgr" typeset _SCSIMGR_OPTS="-v get_info all_lun" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -58,7 +59,6 @@ typeset _ACTIVE_PATH_COUNT="" typeset _ALL_PATH_COUNT="" typeset _FAILED_PATH_COUNT="" typeset _STANDBY_PATH_COUNT="" -typeset _WWID="" # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -210,7 +210,7 @@ awk 'BEGIN { wwid = ""; active_paths = ""; all_paths = ""; failed_paths = ""; st print wwid "|" disks[wwid] "|" paths_active[wwid] "|" paths_all[wwid] "|" paths_failed[wwid] "|" paths_standby[wwid] } }' ${_TMP1_FILE} ${_TMP2_FILE} 2>/dev/null |\ -while IFS='|' read -r _WWID _HW_PATH _ACTIVE_PATH_COUNT _ALL_PATH_COUNT _FAILED_PATH_COUNT _STANDBY_PATH_COUNT +while IFS='|' read -r _ _HW_PATH _ACTIVE_PATH_COUNT _ALL_PATH_COUNT _FAILED_PATH_COUNT _STANDBY_PATH_COUNT do if [[ -z "${_ACTIVE_PATH_COUNT}" ]] || [[ -z "${_ALL_PATH_COUNT}" ]] || @@ -259,10 +259,10 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 - -PURPOSE : Check the active and failed (non-active) lunpaths of DISK devices +NAME : $1 +VERSION : $2 +PURPOSE : Check the active and failed (non-active) lunpaths of DISK devices +LOG HEALTHY : Supported EOT 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 61c2eb7..31c09f4 100644 --- a/sources/lib/platform/hp-ux/check_hpux_named_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_named_status.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2017-01-07: initial version [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_hpux_named_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _NAMED_PID_FILE="/var/run/named/named.pid" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 typeset _RC=0 # handle arguments (originally comma-separated) @@ -58,6 +60,20 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 + # ---- process state ---- # 1) try using the PID way if [[ -r "${_NAMED_PID_FILE}" ]] @@ -93,7 +109,11 @@ case ${_STC} in _MSG="could not determine status of named" ;; esac -log_hc "$0" ${_STC} "${_MSG}" +# report result +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi # ---- config state ---- _NAMED_CHECKCONF_BIN="$(which named-checkconf 2>>${HC_STDERR_LOG})" @@ -109,7 +129,11 @@ then _MSG="named configuration and/or zone files have syntax error(s) {named-checkconf -z}" _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi fi return 0 @@ -119,11 +143,11 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether named (BIND) service is running and whether the named - zone files are syntactically correct. +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether named (BIND) service is running and whether the named + zone files are syntactically correct. +LOG HEALTHY : Supported EOT 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 822bf8d..470ec25 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ntp_status.sh @@ -29,6 +29,7 @@ # @(#) 2019-01-10: added configuration option 'ntpq_use_ipv4', fixed problem # @(#) with offset calculation [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: Text updates [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #------------------------------------------------------------------------------ @@ -38,7 +39,7 @@ function check_hpux_ntp_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _NTPQ_BIN="/usr/sbin/ntpq" typeset _NTPQ_OPTS="-pn" @@ -183,12 +184,12 @@ function _show_usage cat <<- EOT NAME : $1 VERSION : $2 -CONFIG : $3 with: - log_healthy= - max_offset= - force_chrony= - force_ntp= - ntpq_use_ipv4= +CONFIG : $3 with parameters: + log_healthy= + max_offset= + force_chrony= + force_ntp= + ntpq_use_ipv4= EXTRA OPTS : --hc-args=force_chrony, --hc-args=force_ntp PURPOSE : Checks the status of NTP service & synchronization. Supports chronyd & ntpd. 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 09c5d77..7326856 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh @@ -29,6 +29,7 @@ # @(#) 2018-10-22: small fixes [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: text updates [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -38,7 +39,7 @@ function check_hpux_ovpa_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _OVPA_BIN="/opt/perf/bin/perfstat" # ------------------------- CONFIGURATION ends here --------------------------- @@ -162,7 +163,8 @@ function _show_usage cat <<- EOT NAME : $1 VERSION : $2 -CONFIG : $3 with: +CONFIG : $3 with parameters: + log_healthy= ovpa_daemons= PURPOSE : Checks the status of OVPA processes (OpenView Performance Agent) LOG HEALTHY : Supported 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 adc376d..4115439 100644 --- a/sources/lib/platform/hp-ux/check_hpux_patch_version.sh +++ b/sources/lib/platform/hp-ux/check_hpux_patch_version.sh @@ -29,6 +29,7 @@ # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] # @(#) 2019-02-19: fix in exclude checking [Patrick Van der Veken] +# @(#) 2019-03-09: text updates [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -42,7 +43,7 @@ typeset _SWLIST_BIN="/usr/sbin/swlist" typeset _SWLIST_OPTS="" typeset _SHOW_PATCHES_BIN="/usr/contrib/bin/show_patches" typeset _SHOW_PATCHES_OPTS="" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -256,16 +257,18 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - required_patches= - required_oe= - check_filesets= - exclude_filesets= -PURPOSE : Checks whether the required OE (Operating Environment) version is installed - Checks whether the required patches are installed - Checks whether filesets are in a configured state +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + required_patches= + required_oe= + check_filesets= + exclude_filesets= +PURPOSE : Checks whether the required OE (Operating Environment) version is installed + Checks whether the required patches are installed + Checks whether filesets are in a configured state +LOG HEALTHY : Supported EOT 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 e8271dd..aa0bca7 100644 --- a/sources/lib/platform/hp-ux/check_hpux_postfix_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_postfix_status.sh @@ -19,11 +19,12 @@ # @(#) MAIN: check_hpux_postfix_status # DOES: see _show_usage() # EXPECTS: n/a -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2016-12-01: initial version [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_hpux_postfix_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,6 +45,7 @@ typeset _ARG="" typeset _POSTFIX_BIN="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -55,6 +57,20 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 + _POSTFIX_BIN="$(which postfix 2>>${HC_STDERR_LOG})" if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]] then @@ -71,8 +87,11 @@ else return 1 fi -# handle results -log_hc "$0" ${_STC} "${_MSG}" +# report result +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi return 0 } @@ -81,10 +100,10 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether postfix (mail system) is running +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether postfix (mail system) is running +LOG HEALTHY : Supported EOT 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 28138e5..5c773b9 100644 --- a/sources/lib/platform/hp-ux/check_hpux_root_crontab.sh +++ b/sources/lib/platform/hp-ux/check_hpux_root_crontab.sh @@ -19,11 +19,13 @@ # @(#) MAIN: check_hpux_root_crontab # DOES: see _show_usage() # EXPECTS: n/a -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2013-09-19: initial version [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: changed format of stanzas in configuration file & +# @(#) added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +35,7 @@ function check_hpux_root_crontab { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -44,8 +46,11 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _CRON_ENTRY="" typeset _CRON_MATCH=0 +typeset _IS_OLD_STYLE=0 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -64,15 +69,47 @@ then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# check for old-style configuration file (non-prefixed stanzas) +_IS_OLD_STYLE=$(grep -c -E -e "^cron:" ${_CONFIG_FILE} 2>/dev/null) +if (( _IS_OLD_STYLE == 0 )) +then + warn "no 'cron:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?" + return 1 +fi + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 # collect data crontab -l >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} # perform check -grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _CRON_ENTRY +grep -E -e "^cron:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _CRON_ENTRY do - _CRON_MATCH=$(grep -v '^#' ${HC_STDOUT_LOG} 2>/dev/null |\ - grep -c -E -e "${_CRON_ENTRY}") + _CRON_MATCH=$(grep -v '^#' ${HC_STDOUT_LOG} 2>/dev/null |\ + grep -c -E -e "${_CRON_ENTRY}") case ${_CRON_MATCH} in 0) _MSG="'${_CRON_ENTRY}' is not configured in cron" @@ -86,8 +123,11 @@ do ;; esac - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi _STC=0 done @@ -98,10 +138,14 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks the content of the 'root' crontab for required entries +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + and formatted stanzas: + cron: +PURPOSE : Checks the content of the 'root' crontab for required entries +LOG HEALTHY : Supported EOT 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 cd20083..89211cd 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sfm_status.sh @@ -25,6 +25,7 @@ # @(#) HISTORY: # @(#) 2018-10-28: initial version [Patrick Van der Veken] # @(#) 2019-01-27: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: text updates [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +38,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-27" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -75,136 +76,136 @@ typeset _EVENT_SUMMARY="" # handle arguments (originally comma-separated) for _ARG in ${_ARGS} do - case "${_ARG}" in - help) - _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 - ;; - esac + case "${_ARG}" in + help) + _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 + ;; + esac done # log_healthy (( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 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 + 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" + log "not logging/showing passed health checks" fi # handle configuration file [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" if [[ ! -r ${_CONFIG_FILE} ]] then - warn "unable to read configuration file at ${_CONFIG_FILE}" - return 1 + warn "unable to read configuration file at ${_CONFIG_FILE}" + return 1 fi # read required configuration values _CFG_CHECK_EVENTS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_events') case "${_CFG_CHECK_EVENTS}" in - No|NO|no) - _CHECK_EVENTS=0 - log "will not check current events" - ;; - *) - log "will check current events" - ;; + No|NO|no) + _CHECK_EVENTS=0 + log "will not check current events" + ;; + *) + log "will check current events" + ;; esac _CFG_EVENTS_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'events_age') case "${_CFG_EVENTS_AGE}" in - *:dd|*:mm|*:yy) - _EVENTS_AGE="${_CFG_EVENTS_AGE}" - log "will use following age for current events: ${_CFG_EVENTS_AGE}" - ;; - *) - warn "invalid event age value '${_CFG_EVENTS_AGE}' in configuration file at ${_CONFIG_FILE}" - return 1 - ;; + *:dd|*:mm|*:yy) + _EVENTS_AGE="${_CFG_EVENTS_AGE}" + log "will use following age for current events: ${_CFG_EVENTS_AGE}" + ;; + *) + warn "invalid event age value '${_CFG_EVENTS_AGE}' in configuration file at ${_CONFIG_FILE}" + return 1 + ;; esac _CFG_EVENTS_SEVERITY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'events_severity') if [[ -n "${_CFG_EVENTS_SEVERITY}" ]] && (( _CHECK_EVENTS > 0 )) then - log "will use following severities for current events: ${_CFG_EVENTS_SEVERITY}" + log "will use following severities for current events: ${_CFG_EVENTS_SEVERITY}" fi _CFG_SEND_TEST_EVENT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'send_test_event') case "${_CFG_SEND_TEST_EVENT}" in - Yes|YES|yes) - if (( ARG_LOG > 0 )) - then - _SEND_TEST_EVENT=1 - else - warn "--no-log is enabled, skipping the generation of a test event" - fi - log "will send & check a test event" - ;; - *) - log "will not send & check a test event" - ;; + Yes|YES|yes) + if (( ARG_LOG > 0 )) + then + _SEND_TEST_EVENT=1 + else + warn "--no-log is enabled, skipping the generation of a test event" + fi + log "will send & check a test event" + ;; + *) + log "will not send & check a test event" + ;; esac _CFG_WAIT_TEST_EVENT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'wait_test_event') if (( _SEND_TEST_EVENT > 0 )) then - if [[ -z "${_CFG_WAIT_TEST_EVENT}" ]] - then - _WAIT_TEST_EVENT=60 - else - data_is_numeric "${_WAIT_TEST_EVENT}" - if (( $? > 0 )) - then - warn "invalid wait test event value '${_WAIT_TEST_EVENT}' in configuration file at ${_CONFIG_FILE}" - return 1 - fi - fi + if [[ -z "${_CFG_WAIT_TEST_EVENT}" ]] + then + _WAIT_TEST_EVENT=60 + else + data_is_numeric "${_WAIT_TEST_EVENT}" + if (( $? > 0 )) + then + warn "invalid wait test event value '${_WAIT_TEST_EVENT}' in configuration file at ${_CONFIG_FILE}" + return 1 + fi + fi fi _CFG_EVENT_SUBSCRIBER_CIMOM=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'event_subscriber_cimom') _CFG_EVENT_SUBSCRIBER_WBEM=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'event_subscriber_wbem') if [[ -n "${_CFG_EVENT_SUBSCRIBER_CIMOM}" ]] || [[ -n "${_CFG_EVENT_SUBSCRIBER_WBEM}" ]] then - _CHECK_EVENT_SUBSCRIBER=1 - log "will check external subscriber (cimom and/or wbem)" + _CHECK_EVENT_SUBSCRIBER=1 + log "will check external subscriber (cimom and/or wbem)" else - log "will not check external subscriber (cimom and/or wbem)" + log "will not check external subscriber (cimom and/or wbem)" fi _CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') case "${_CFG_HEALTHY}" in - yes|YES|Yes) - _LOG_HEALTHY=1 - ;; - *) - # do not override hc_arg - (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 - ;; + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; esac # check timeout (_WAIT_TEST_EVENT must be at least 30 secs smaller than health check timeout) if (( _SEND_TEST_EVENT > 0 )) then - if (( (_WAIT_TEST_EVENT + 30) > HC_TIME_OUT )) - then - warn "wait test event value will conflict with health check timeout. Specify a (larger) --timeout value" - return 1 - fi + if (( (_WAIT_TEST_EVENT + 30) > HC_TIME_OUT )) + then + warn "wait test event value will conflict with health check timeout. Specify a (larger) --timeout value" + return 1 + fi fi # check required tools if [[ ! -x ${_SFMCONFIG_BIN} ]] then - warn "${_SFMCONFIG_BIN} is not installed here" - return 1 + warn "${_SFMCONFIG_BIN} is not installed here" + return 1 fi if [[ ! -x ${_EVWEB_BIN} ]] then - warn "${_EVWEB_BIN} is not installed here" - return 1 + warn "${_EVWEB_BIN} is not installed here" + return 1 fi if [[ ! -x ${_CIMPROVIDER_BIN} ]] then - warn "${_CIMPROVIDER_BIN} is not installed here" - return 1 + warn "${_CIMPROVIDER_BIN} is not installed here" + return 1 fi # 1. is SFM active? @@ -215,15 +216,15 @@ _CHECK_SFM_OUTPUT=$(${_SFMCONFIG_BIN} -w -q 2>>${HC_STDERR_LOG}) data_contains_string "${_CHECK_SFM_OUTPUT}" "SysFaultMgmt is the default monitoring mode" if (( $? == 0 )) then - _MSG="SysFaultMgmt is not configured as default monitoring mode {${_SFMCONFIG_BIN} -w -q}" - _STC=1 + _MSG="SysFaultMgmt is not configured as default monitoring mode {${_SFMCONFIG_BIN} -w -q}" + _STC=1 else - _MSG="SysFaultMgmt is configured as default monitoring mode" - _STC=0 + _MSG="SysFaultMgmt is configured as default monitoring mode" + _STC=0 fi if (( _LOG_HEALTHY > 0 || _STC > 0 )) then - log_hc "$0" ${_STC} "${_MSG}" + log_hc "$0" ${_STC} "${_MSG}" fi # save sfmconfig OUTPUT for posterity print "${_CHECK_SFM_OUTPUT}" >>${HC_STDOUT_LOG} @@ -234,28 +235,28 @@ print "=== ${_CIMPROVIDER_BIN} -ls ===" >>${HC_STDOUT_LOG} _CHECK_CIM_OUTPUT=$(${_CIMPROVIDER_BIN} -ls 2>>${HC_STDERR_LOG}) if (( $? > 0 )) then - _MSG="unable to execute {${_CIMPROVIDER_BIN} -ls}, cimserver is probably not running" - log_hc "$0" 1 "${_MSG}" - # save cimprovider OUTPUT - print "${_CHECK_CIM_OUTPUT}" >>${HC_STDOUT_LOG} - # dump debug info - (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs - return 1 + _MSG="unable to execute {${_CIMPROVIDER_BIN} -ls}, cimserver is probably not running" + log_hc "$0" 1 "${_MSG}" + # save cimprovider OUTPUT + print "${_CHECK_CIM_OUTPUT}" >>${HC_STDOUT_LOG} + # dump debug info + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 else - # find module - _CHECK_CIM_MODULE=$(print "${_CHECK_CIM_OUTPUT}" | grep -c -E -e 'SFMProviderModule[[:space:]]*OK' 2>/dev/null) - if (( _CHECK_CIM_MODULE > 0 )) - then - _MSG="SFM CIM provider is active" - _STC=0 - else - _MSG="SFM CIM provider is not active {${_CIMPROVIDER_BIN} -ls}" - _STC=0 - fi + # find module + _CHECK_CIM_MODULE=$(print "${_CHECK_CIM_OUTPUT}" | grep -c -E -e 'SFMProviderModule[[:space:]]*OK' 2>/dev/null) + if (( _CHECK_CIM_MODULE > 0 )) + then + _MSG="SFM CIM provider is active" + _STC=0 + else + _MSG="SFM CIM provider is not active {${_CIMPROVIDER_BIN} -ls}" + _STC=0 + fi fi if (( _LOG_HEALTHY > 0 || _STC > 0 )) then - log_hc "$0" ${_STC} "${_MSG}" + log_hc "$0" ${_STC} "${_MSG}" fi # save sfmconfig OUTPUT for posterity print "${_CHECK_CIM_OUTPUT}" >>${HC_STDOUT_LOG} @@ -263,127 +264,127 @@ print "${_CHECK_CIM_OUTPUT}" >>${HC_STDOUT_LOG} # 3. check if there is an external SIM/IRS subscriber if (( _CHECK_EVENT_SUBSCRIBER > 0 )) then - log "checking external SIM/IRS subscriber ..." - print "=== ${_EVWEB_BIN} subscribe -L -b external ===" >>${HC_STDOUT_LOG} - _CHECK_EVWEB_OUTPUT=$(${_EVWEB_BIN} subscribe -L -b external) - _COUNT_SUBS_CIMOM=$(print "${_CHECK_EVWEB_OUTPUT}" | grep -c "${_CFG_EVENT_SUBSCRIBER_CIMOM}" 2>/dev/null) - _COUNT_SUBS_WBEM=$(print "${_CHECK_EVWEB_OUTPUT}" | grep -c "${_CFG_EVENT_SUBSCRIBER_WBEM}" 2>/dev/null) - if (( _COUNT_SUBS_CIMOM > 0 || _COUNT_SUBS_WBEM > 0 )) - then - case ${_COUNT_SUBS_CIMOM} in - 0) - : - ;; - 3) - _MSG="found external subscriber for CIMOM with ${_COUNT_SUBS_CIMOM} subscriptions" - _STC=0 - ;; - *) - _MSG="found external subscriber for CIMOM but not with sufficient number of subscriptions: ${_COUNT_SUBS_CIMOM}" - _STC=1 - ;; - esac - if (( _COUNT_SUBS_WBEM > 0 )) - then - _MSG="found external subscriber for WBEM" - _STC=0 - fi - else - _MSG="did not find any external subscribers for CIMOM or WBEM" - _STC=1 - fi - if (( _LOG_HEALTHY > 0 || _STC > 0 )) - then - log_hc "$0" ${_STC} "${_MSG}" - fi - # save evweb OUTPUT for posterity - print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} + log "checking external SIM/IRS subscriber ..." + print "=== ${_EVWEB_BIN} subscribe -L -b external ===" >>${HC_STDOUT_LOG} + _CHECK_EVWEB_OUTPUT=$(${_EVWEB_BIN} subscribe -L -b external) + _COUNT_SUBS_CIMOM=$(print "${_CHECK_EVWEB_OUTPUT}" | grep -c "${_CFG_EVENT_SUBSCRIBER_CIMOM}" 2>/dev/null) + _COUNT_SUBS_WBEM=$(print "${_CHECK_EVWEB_OUTPUT}" | grep -c "${_CFG_EVENT_SUBSCRIBER_WBEM}" 2>/dev/null) + if (( _COUNT_SUBS_CIMOM > 0 || _COUNT_SUBS_WBEM > 0 )) + then + case ${_COUNT_SUBS_CIMOM} in + 0) + : + ;; + 3) + _MSG="found external subscriber for CIMOM with ${_COUNT_SUBS_CIMOM} subscriptions" + _STC=0 + ;; + *) + _MSG="found external subscriber for CIMOM but not with sufficient number of subscriptions: ${_COUNT_SUBS_CIMOM}" + _STC=1 + ;; + esac + if (( _COUNT_SUBS_WBEM > 0 )) + then + _MSG="found external subscriber for WBEM" + _STC=0 + fi + else + _MSG="did not find any external subscribers for CIMOM or WBEM" + _STC=1 + fi + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi + # save evweb OUTPUT for posterity + print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} fi # 4. send a test event? if (( _SEND_TEST_EVENT > 0 )) then - log "generating SFM test event ..." - print "=== ${_SFMCONFIG_BIN} -t -a ===" >>${HC_STDOUT_LOG} - ${_SFMCONFIG_BIN} -t -a >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} - if (( $? > 0 )) - 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 - return 1 - else - # wait for test event to showing - log "waiting for SFM test event to show (${_WAIT_TEST_EVENT} seconds) ..." - sleep ${_WAIT_TEST_EVENT} - # run event viewer - print "=== ${_EVWEB_BIN} eventviewer -L -a 1:dd ===" >>${HC_STDOUT_LOG} - _CHECK_EVWEB_OUTPUT=$(${_EVWEB_BIN} eventviewer -L -a 1:dd | grep "Test event" 2>/dev/null) - if (( $? > 0 )) - then - _MSG="unable to execute {${_EVWEB_BIN} eventviewer -L -a 1:dd}" - log_hc "$0" 1 "${_MSG}" - # save evweb OUTPUT - print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} - # dump debug info - (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs - return 1 - else - if [[ -n "${_CHECK_EVWEB_OUTPUT}" ]] - then - _MSG="at least one test event was successfully generated in the last 24hrs" - _STC=0 - else - _MSG="found no test event in the last 24hrs" - _STC=1 - fi - fi - fi - if (( _LOG_HEALTHY > 0 || _STC > 0 )) - then - log_hc "$0" ${_STC} "${_MSG}" - fi - # save evweb OUTPUT for posterity - print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} + log "generating SFM test event ..." + print "=== ${_SFMCONFIG_BIN} -t -a ===" >>${HC_STDOUT_LOG} + ${_SFMCONFIG_BIN} -t -a >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} + if (( $? > 0 )) + 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 + return 1 + else + # wait for test event to showing + log "waiting for SFM test event to show (${_WAIT_TEST_EVENT} seconds) ..." + sleep ${_WAIT_TEST_EVENT} + # run event viewer + print "=== ${_EVWEB_BIN} eventviewer -L -a 1:dd ===" >>${HC_STDOUT_LOG} + _CHECK_EVWEB_OUTPUT=$(${_EVWEB_BIN} eventviewer -L -a 1:dd | grep "Test event" 2>/dev/null) + if (( $? > 0 )) + then + _MSG="unable to execute {${_EVWEB_BIN} eventviewer -L -a 1:dd}" + log_hc "$0" 1 "${_MSG}" + # save evweb OUTPUT + print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} + # dump debug info + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 + else + if [[ -n "${_CHECK_EVWEB_OUTPUT}" ]] + then + _MSG="at least one test event was successfully generated in the last 24hrs" + _STC=0 + else + _MSG="found no test event in the last 24hrs" + _STC=1 + fi + fi + fi + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi + # save evweb OUTPUT for posterity + print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} fi # 5. check events if (( _CHECK_EVENTS > 0 )) then - _CHECK_EVWEB_OUTPUT="" - log "checking for current events (age: ${_EVENTS_AGE}) ..." - print "=== ${_EVWEB_BIN} eventviewer -L -a ${_EVENTS_AGE} ===" >>${HC_STDOUT_LOG} - _CHECK_EVWEB_OUTPUT=$(${_EVWEB_BIN} eventviewer -L -a ${_EVENTS_AGE} | grep -v "Test event" 2>/dev/null) - if (( $? > 0 )) - then - _MSG="unable to execute {${_EVWEB_BIN} eventviewer -L -a ${_EVENTS_AGE}}" - log_hc "$0" 1 "${_MSG}" - # save evweb OUTPUT - print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} - # dump debug info - (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs - return 1 - else - _CFG_EVENTS_SEVERITY=$(data_lc "${_CFG_EVENTS_SEVERITY}") - print "${_CHECK_EVWEB_OUTPUT}" | grep -v -E -e "^$" -e "^=" -e "^Ev" 2>/dev/null |\ - while read -r _EVWEB_LINE - do - _EVENT_ID=$(print "${_EVWEB_LINE}" | awk '{ print $1}' 2>/dev/null) - _EVENT_SEVERITY=$(print "${_EVWEB_LINE}" | awk '{ print $2}' 2>/dev/null) - _EVENT_SEVERITY=$(data_lc "${_EVENT_SEVERITY}") - _EVENT_SUMMARY=$(print "${_EVWEB_LINE}" | awk '{$1=$2=$3=$4=$5=$6=$7=$8=$9=$10=""; gsub (/^ */,"",$0); print $0}' 2>/dev/null) - # check severity - data_contains_string "${_CFG_EVENTS_SEVERITY}" "${_EVENT_SEVERITY}" - if (( $? > 0 )) - then - _MSG="found SFM event (ID=${_EVENT_ID}/SUMMARY=${_EVENT_SUMMARY})" - log_hc "$0" 1 "${_MSG}" - fi - done - fi - # save evweb OUTPUT for posterity - print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} + _CHECK_EVWEB_OUTPUT="" + log "checking for current events (age: ${_EVENTS_AGE}) ..." + print "=== ${_EVWEB_BIN} eventviewer -L -a ${_EVENTS_AGE} ===" >>${HC_STDOUT_LOG} + _CHECK_EVWEB_OUTPUT=$(${_EVWEB_BIN} eventviewer -L -a ${_EVENTS_AGE} | grep -v "Test event" 2>/dev/null) + if (( $? > 0 )) + then + _MSG="unable to execute {${_EVWEB_BIN} eventviewer -L -a ${_EVENTS_AGE}}" + log_hc "$0" 1 "${_MSG}" + # save evweb OUTPUT + print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} + # dump debug info + (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs + return 1 + else + _CFG_EVENTS_SEVERITY=$(data_lc "${_CFG_EVENTS_SEVERITY}") + print "${_CHECK_EVWEB_OUTPUT}" | grep -v -E -e "^$" -e "^=" -e "^Ev" 2>/dev/null |\ + while read -r _EVWEB_LINE + do + _EVENT_ID=$(print "${_EVWEB_LINE}" | awk '{ print $1}' 2>/dev/null) + _EVENT_SEVERITY=$(print "${_EVWEB_LINE}" | awk '{ print $2}' 2>/dev/null) + _EVENT_SEVERITY=$(data_lc "${_EVENT_SEVERITY}") + _EVENT_SUMMARY=$(print "${_EVWEB_LINE}" | awk '{$1=$2=$3=$4=$5=$6=$7=$8=$9=$10=""; gsub (/^ */,"",$0); print $0}' 2>/dev/null) + # check severity + data_contains_string "${_CFG_EVENTS_SEVERITY}" "${_EVENT_SEVERITY}" + if (( $? > 0 )) + then + _MSG="found SFM event (ID=${_EVENT_ID}/SUMMARY=${_EVENT_SUMMARY})" + log_hc "$0" 1 "${_MSG}" + fi + done + fi + # save evweb OUTPUT for posterity + print "${_CHECK_EVWEB_OUTPUT}" >>${HC_STDOUT_LOG} fi return 0 @@ -393,22 +394,24 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - check_events= - events_age= - events_severity= - send_test_event= - wait_test_event= - event_subscriber= -PURPOSE : Checks the heath of SFM (System Fault Management) - * checks default monitoring mode - * checks CIM provider module - * checks external event subscriber (optional) - * sends & checks a test event (optional) - * checks current events (optional) -NOTE: Test events should not be generated more than once a day +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + check_events= + events_age= + events_severity= + send_test_event= + wait_test_event= + event_subscriber= +PURPOSE : Checks the heath of SFM (System Fault Management) + * checks default monitoring mode + * checks CIM provider module + * checks external event subscriber (optional) + * sends & checks a test event (optional) + * checks current events (optional) +LOG HEALTHY : Supported +NOTE : Test events should not be generated more than once a day EOT 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 6f9a011..05dc02c 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 @@ -28,6 +28,8 @@ # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: changed format of stanzas in configuration file & +# @(#) added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +39,7 @@ function check_hpux_sg_cluster_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SG_DAEMON="/usr/lbin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- @@ -49,11 +51,14 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _SG_ENTRY="" typeset _SG_MATCH="" typeset _SG_CFG_PARAM="" typeset _SG_CFG_VALUE="" typeset _SG_RUN_VALUE="" +typeset _IS_OLD_STYLE=0 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -72,6 +77,38 @@ then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# check for old-style configuration file (non-prefixed stanzas) +_IS_OLD_STYLE=$(grep -c -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null) +if (( _IS_OLD_STYLE == 0 )) +then + warn "no 'sg:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?" + return 1 +fi + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 serviceguard status if [[ ! -x ${_SG_DAEMON} ]] @@ -91,7 +128,8 @@ fi # do cluster status checks # (replace ':' by '|' for cmcviewcl output) -grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' | while read _SG_ENTRY +grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\ + while read -r _ _SG_ENTRY do # field split _SG_CFG_PARAM="$(print ${_SG_ENTRY} | cut -f1 -d'=')" # field 1 @@ -111,7 +149,10 @@ do _MSG="cluster parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]" _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" + fi else warn "could not determine status for ${_SG_CFG_PARAM} from command output {cmviewcl}" fi @@ -124,10 +165,14 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+) +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + and formatted stanzas: + sg:= +PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+) +LOG HEALTHY : Supported EOT 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 c7ad12d..87ac79e 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 @@ -28,6 +28,8 @@ # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: changed format of stanzas in configuration file & +# @(#) added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +39,7 @@ function check_hpux_sg_package_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SG_DAEMON="/usr/lbin/cmcld" # ------------------------- CONFIGURATION ends here --------------------------- @@ -49,12 +51,15 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _SG_ENTRY="" typeset _SG_MATCH="" typeset _SG_PACKAGE="" typeset _SG_CFG_PARAM="" typeset _SG_CFG_VALUE="" typeset _SG_RUN_VALUE="" +typeset _IS_OLD_STYLE=0 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -73,6 +78,38 @@ then warn "unable to read configuration file at ${_CONFIG_FILE}" return 1 fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# check for old-style configuration file (non-prefixed stanzas) +_IS_OLD_STYLE=$(grep -c -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null) +if (( _IS_OLD_STYLE == 0 )) +then + warn "no 'sg:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?" + return 1 +fi + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 serviceguard status if [[ ! -x ${_SG_DAEMON} ]] @@ -92,7 +129,8 @@ fi # do package status checks # (replace ':' by '|' for cmcviewcl output) -grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' | while read _SG_ENTRY +grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\ + while read -r _ _SG_ENTRY do # field split _SG_PACKAGE="$(print ${_SG_ENTRY} | cut -f1 -d':')" @@ -113,7 +151,10 @@ do _MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]" _STC=1 fi - log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" + fi else warn "could not determine status for ${_SG_PACKAGE}/${_SG_CFG_PARAM} from command output {cmviewcl}" fi @@ -126,10 +167,14 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks the status of Serviceguard package parameters (SG 11.16+) +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + and formatted stanzas: + sg::= +PURPOSE : Checks the status of Serviceguard package parameters (SG 11.16+) +LOG HEALTHY : Supported EOT 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 09779aa..89f45cd 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 @@ -19,12 +19,13 @@ # @(#) MAIN: check_hpux_sg_qs_status # DOES: see _show_usage() # EXPECTS: n/a -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2017-05-01: initial version [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,7 @@ function check_hpux_sg_qs_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _QS_BIN="/usr/lbin/qsc" typeset _QS_AUTH_FILE="/etc/cmcluster/qs_authfile" @@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 # handle arguments (originally comma-separated) for _ARG in ${_ARGS} @@ -57,6 +59,21 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 QS presence if [[ ! -x ${_QS_BIN} ]] then @@ -79,7 +96,10 @@ case ${_STC} in _MSG="could not determine status of QS" ;; esac -log_hc "$0" ${_STC} "${_MSG}" +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi # ---- config state ---- if [[ -s ${_QS_AUTH_FILE} ]] @@ -90,7 +110,10 @@ else _MSG="QS authorizations file is missing or empty (${_QS_AUTH_FILE})" _STC=1 fi -log_hc "$0" ${_STC} "${_MSG}" +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi return 0 } @@ -99,10 +122,10 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether the Serviceguard quorum server is running +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether the Serviceguard quorum server is running +LOG HEALTHY : Supported EOT 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 eabe7e1..5c47bdf 100644 --- a/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_sshd_status.sh @@ -25,6 +25,8 @@ # @(#) 2017-04-01: initial version [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] + # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +36,7 @@ function check_hpux_sshd_status { # ------------------------- CONFIGURATION starts here ------------------------- typeset _SSHD_PID_FILE="/var/run/sshd/sshd.pid" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -46,6 +48,7 @@ typeset _ARG="" typeset _SSHD_PID="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 typeset _RC=0 # handle arguments (originally comma-separated) @@ -58,6 +61,20 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 + # ---- process state ---- # 1) try using the PID way if [[ -r "${_SSHD_PID_FILE}" ]] @@ -94,8 +111,11 @@ case ${_STC} in ;; esac -# handle results -log_hc "$0" ${_STC} "${_MSG}" +# report results +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi return 0 } @@ -104,10 +124,11 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether sshd (Secure Shell daemon) is running +NAME : $1 +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether sshd (Secure Shell daemon) is running +LOG HEALTHY : Supported EOT diff --git a/sources/lib/platform/hp-ux/check_hpux_syslog.sh b/sources/lib/platform/hp-ux/check_hpux_syslog.sh index 8dda73d..ffe804f 100644 --- a/sources/lib/platform/hp-ux/check_hpux_syslog.sh +++ b/sources/lib/platform/hp-ux/check_hpux_syslog.sh @@ -19,7 +19,7 @@ # @(#) MAIN: check_hpux_syslog # DOES: see _show_usage() # EXPECTS: see _show_usage() -# REQUIRES: data_comma2space(), init_hc(), log_hc() +# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn() # # @(#) HISTORY: # @(#) 2016-06-20: initial version [Patrick Van der Veken] @@ -27,6 +27,7 @@ # @(#) 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-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -37,7 +38,7 @@ function check_hpux_syslog # ------------------------- CONFIGURATION starts here ------------------------- typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _STATE_FILE="${STATE_PERM_DIR}/discovered.syslog" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -49,6 +50,8 @@ typeset _ARG="" typeset _MSG="" typeset _STC=0 typeset _STC_COUNT=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$" typeset _CLASSES_LINE="" typeset _SYSLOG_FILE="" @@ -93,6 +96,30 @@ else # add PID qualifier to last item _SYSLOG_CLASSES="${_SYSLOG_CLASSES}(\[[0-9]+\])?:" fi +_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') +case "${_CFG_HEALTHY}" in + yes|YES|Yes) + _LOG_HEALTHY=1 + ;; + *) + # do not override hc_arg + (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 + ;; +esac + +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 SYSLOG file [[ -r ${_SYSLOG_FILE} ]] || _MSG="SYSLOG file ${_SYSLOG_FILE} cannot be found" @@ -144,8 +171,11 @@ else _MSG="no new SYSLOG messages found" fi -# handle results -log_hc "$0" ${_STC} "${_MSG}" +# report results +if (( _LOG_HEALTHY > 0 || _STC > 0 )) +then + log_hc "$0" ${_STC} "${_MSG}" +fi # do cleanup [[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1 @@ -157,15 +187,17 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 with: - syslog_file= - syslog_classes= -PURPOSE : Provides a KISS syslog monitor (keep tracks of already discovered messages in - a state file and compares new lines in SYSLOG to the ones kept in the - state file. The plugin will sort both state & SYSLOG data before doing - the comparison. +NAME : $1 +VERSION : $2 +CONFIG : $3 with parameters: + log_healthy= + syslog_file= + syslog_classes= +PURPOSE : Provides a KISS syslog monitor (keep tracks of already discovered messages in + a state file and compares new lines in SYSLOG to the ones kept in the + state file. The plugin will sort both state & SYSLOG data before doing + the comparison. +LOG HEALTHY : Supported EOT diff --git a/sources/lib/platform/hp-ux/check_hpux_syslogd_status.sh b/sources/lib/platform/hp-ux/check_hpux_syslogd_status.sh index 53f3d09..40ec490 100644 --- a/sources/lib/platform/hp-ux/check_hpux_syslogd_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_syslogd_status.sh @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2018-02-08: initial version [Patrick Van der Veken] # @(#) 2018-02-13: fix to avoid log check if syslogd is not active [Patrick Van der Veken] +# @(#) 2019-03-09: text updates [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -34,7 +35,7 @@ function check_hpux_syslogd_status # ------------------------- CONFIGURATION starts here ------------------------- typeset _SYSLOGD_PID_FILE="/var/run/syslog.pid" typeset _SYSLOGD_LOG_FILE="/var/adm/syslog.log" -typeset _VERSION="2019-02-13" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -159,7 +160,6 @@ function _show_usage cat <<- EOT NAME : $1 VERSION : $2 -CONFIG : $3 PURPOSE : Checks whether syslogd service is running and whether syslogd is actually logging to ${_SYSLOGD_LOG_FILE}. LOG HEALTHY : Supported 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 49f29ee..526e53e 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 @@ -24,6 +24,7 @@ # @(#) HISTORY: # @(#) 2016-04-28: initial version [Patrick Van der Veken] # @(#) 2019-01-24: arguments fix [Patrick Van der Veken] +# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -32,7 +33,7 @@ function check_hpux_vg_minor_number { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2019-01-24" # YYYY-MM-DD +typeset _VERSION="2019-03-09" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -43,6 +44,7 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _LOG_HEALTHY=0 typeset _VG="" typeset _VG_DUPE="" typeset _VG_DUPES="" @@ -57,8 +59,23 @@ do esac done +# log_healthy +(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 +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 + # get list of major and minor numbers for vgs -vgdisplay -F | cut -f1 -d':' | cut -f2 -d'=' | while read _VG +vgdisplay -F 2>>${HC_STDERR_LOG} | cut -f1 -d':' 2>/dev/null | cut -f2 -d'=' 2>/dev/null |\ + while read -r _VG do ls -l ${_VG}/group >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} done @@ -67,19 +84,25 @@ done _VG_DUPES="$(awk '{ print $5":"$6 }' ${HC_STDOUT_LOG} | sort | uniq -d)" if [[ -n ${_VG_DUPES} ]] then - print "${_VG_DUPES}" | while read _VG_DUPE + print "${_VG_DUPES}" | while read -r _VG_DUPE do _MSG="MAJ/MIN numbers combination '${_VG_DUPE}' is not unique" _STC=1 - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi done else _MSG="no VGs with duplicate MAJ/MIN numbers detected" - # handle unit result - log_hc "$0" ${_STC} "${_MSG}" + # report result + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + fi fi return 0 @@ -89,10 +112,11 @@ return 0 function _show_usage { cat <<- EOT -NAME : $1 -VERSION : $2 -CONFIG : $3 -PURPOSE : Checks whether all volume groups have a unique minor number +NAME : $1 +VERSION : $2 +PURPOSE : Checks whether all volume groups have a unique minor number +LOG HEALTHY : Supported + EOT 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 d3511fe..9597dee 100644 --- a/sources/lib/platform/linux/check_linux_sg_cluster_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_cluster_status.sh @@ -172,7 +172,7 @@ CONFIG : $3 with parameters: log_healthy= and formatted stanzas: sg:= -PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+) +PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+) LOG HEALTHY : Supported EOT 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 df9fa11..f01e787 100644 --- a/sources/lib/platform/linux/check_linux_sg_package_status.sh +++ b/sources/lib/platform/linux/check_linux_sg_package_status.sh @@ -174,7 +174,7 @@ CONFIG : $3 with parameters: log_healthy= and formatted stanzas: sg::= -PURPOSE : Checks the status of Serviceguard package parameters (SG 11.16+) +PURPOSE : Checks the status of Serviceguard package parameters (SG 11.16+) LOG HEALTHY : Supported EOT diff --git a/sources/lib/platform/linux/check_linux_sshd_status.sh b/sources/lib/platform/linux/check_linux_sshd_status.sh index 3ebb977..314059a 100644 --- a/sources/lib/platform/linux/check_linux_sshd_status.sh +++ b/sources/lib/platform/linux/check_linux_sshd_status.sh @@ -142,6 +142,8 @@ case ${_STC} in _MSG="could not determine status of sshd" ;; esac + +# report results if (( _LOG_HEALTHY > 0 || _STC > 0 )) then log_hc "$0" ${_STC} "${_MSG}"