From ada5fbb1e2e249bbf33aed900e9b6029bc61c354 Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Thu, 31 Jan 2019 13:39:06 +0100 Subject: [PATCH] * Improved discovery routine & added log_healthy in check_hpux_ignite_backup() * Improved config file comments --- configs/etc/check_aix_file_change.conf.dist | 11 +-- configs/etc/check_hpux_drd_status.conf.dist | 6 +- configs/etc/check_hpux_file_change.conf.dist | 11 +-- .../check_hpux_fs_mounts_options.conf.dist | 2 +- configs/etc/check_hpux_fs_usage.conf.dist | 7 +- .../etc/check_hpux_hpvm_vpar_status.conf.dist | 1 + .../etc/check_hpux_ignite_backup.conf.dist | 5 ++ configs/etc/check_hpux_ioscan.conf.dist | 6 +- .../etc/check_hpux_kernel_params.conf.dist | 7 +- configs/etc/check_hpux_kernel_usage.conf.dist | 7 +- configs/etc/check_hpux_ntp_status.conf.dist | 2 +- configs/etc/check_hpux_ovpa_status.conf.dist | 2 +- .../etc/check_hpux_patch_version.conf.dist | 4 +- configs/etc/check_hpux_sfm_status.conf.dist | 6 +- .../check_hpux_sg_cluster_status.conf.dist | 1 + .../check_hpux_sg_package_status.conf.dist | 1 + configs/etc/check_linux_burp_backup.conf.dist | 7 +- configs/etc/check_linux_file_change.conf.dist | 11 +-- configs/etc/check_linux_fs_usage.conf.dist | 7 +- configs/etc/check_linux_ntp_status.conf.dist | 8 +-- .../etc/check_linux_process_limits.conf.dist | 6 +- .../check_linux_sg_cluster_status.conf.dist | 1 + .../check_linux_sg_package_status.conf.dist | 1 + .../etc/check_linux_vz_ct_status.conf.dist | 1 + .../hp-ux/check_hpux_ignite_backup.sh | 72 +++++++++++++++---- 25 files changed, 129 insertions(+), 64 deletions(-) diff --git a/configs/etc/check_aix_file_change.conf.dist b/configs/etc/check_aix_file_change.conf.dist index 0885a38..e90b740 100644 --- a/configs/etc/check_aix_file_change.conf.dist +++ b/configs/etc/check_aix_file_change.conf.dist @@ -12,7 +12,7 @@ state_file=discovered.file_change # specify if file names need to be checked/flagged for meta characters [yes|no] # [default: yes] -do_meta_check=yes +do_meta_check="yes" # specify files or directories check (directories are automatically expanded) # format: @@ -20,11 +20,12 @@ do_meta_check=yes # excl: (excludes a path) # note: shell wild cards in the file paths are not supported! Exclusions have # a higher priority than inclusions. -incl:file1 -incl:dir1 -excl:dir1/file2 +# Examples: +#incl:file1 +#incl:dir1 +#excl:dir1/file2 #****************************************************************************** # End of FILE -#****************************************************************************** \ No newline at end of file +#****************************************************************************** diff --git a/configs/etc/check_hpux_drd_status.conf.dist b/configs/etc/check_hpux_drd_status.conf.dist index fbfd286..8ab1131 100644 --- a/configs/etc/check_hpux_drd_status.conf.dist +++ b/configs/etc/check_hpux_drd_status.conf.dist @@ -8,7 +8,7 @@ # check clone age? (yes|no) # [default: yes] -check_clone=yes +check_clone="yes" # maximum days before the drd clone gets flagged as 'too old' # [default: 30] @@ -16,7 +16,7 @@ clone_age=30 # check sync age? (yes|no) # [default: yes] -check_sync=yes +check_sync="yes" # maximum days before the drd sync gets flagged as 'too old' # [default: 30] @@ -25,4 +25,4 @@ sync_age=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 69e0280..d89316c 100644 --- a/configs/etc/check_hpux_file_change.conf.dist +++ b/configs/etc/check_hpux_file_change.conf.dist @@ -12,7 +12,7 @@ state_file=discovered.file_change # specify if file names need to be checked/flagged for meta characters [yes|no] # [default: yes] -do_meta_check=yes +do_meta_check="yes" # specify files or directories check (directories are automatically expanded) # format: @@ -20,11 +20,12 @@ do_meta_check=yes # excl: (excludes a path) # note: shell wild cards in the file paths are not supported! Exclusions have # a higher priority than inclusions. -incl:file1 -incl:dir1 -excl:dir1/file2 +# Examples: +#incl:file1 +#incl:dir1 +#excl:dir1/file2 #****************************************************************************** # End of FILE -#****************************************************************************** \ No newline at end of file +#****************************************************************************** diff --git a/configs/etc/check_hpux_fs_mounts_options.conf.dist b/configs/etc/check_hpux_fs_mounts_options.conf.dist index f7aa0b8..0e8dc20 100644 --- a/configs/etc/check_hpux_fs_mounts_options.conf.dist +++ b/configs/etc/check_hpux_fs_mounts_options.conf.dist @@ -8,7 +8,7 @@ # specify whether non-mounted FS should be alerted on (yes|no) # [default: yes] -ignore_missing_fs=yes +ignore_missing_fs="yes" # specify mount points and their options (use the mount options as displayed # by the 'mount' command; order of the options is not important) diff --git a/configs/etc/check_hpux_fs_usage.conf.dist b/configs/etc/check_hpux_fs_usage.conf.dist index 63a8cd4..af9c0c4 100644 --- a/configs/etc/check_hpux_fs_usage.conf.dist +++ b/configs/etc/check_hpux_fs_usage.conf.dist @@ -9,15 +9,15 @@ # specify whether to also log passed health checks # (warning: this may rapidly grow the HC log) # [default: no] -log_healthy=yes +log_healthy="yes" # specify whether to perform inode usage check # [default: yes] -check_inodes_usage=yes +check_inodes_usage="yes" # specify whether to perform space usage check # [default: yes] -check_space_usage=yes +check_space_usage="yes" # specify the maximum % of inodes usage a filesystem may reach (general threshold) # [default: 90] @@ -31,6 +31,7 @@ max_space_usage=90 # for a given filesystem, the general threshold will be used (see above). When # defining a threshold of 0 (zero), then the check will for this give filesystem # will be skipped (this allows for exclusion of filesystems) +# Format: # [fs::::] -param:nproc:5000 -param:filecache_max:50% +# Examples: +#param:nproc:5000 +#param:filecache_max:50% #****************************************************************************** # End of FILE -#****************************************************************************** \ No newline at end of file +#****************************************************************************** diff --git a/configs/etc/check_hpux_kernel_usage.conf.dist b/configs/etc/check_hpux_kernel_usage.conf.dist index d1775e4..ddfa705 100644 --- a/configs/etc/check_hpux_kernel_usage.conf.dist +++ b/configs/etc/check_hpux_kernel_usage.conf.dist @@ -13,9 +13,10 @@ max_kcusage=90 # specify individual kernel parameters and their maximum usage threshold (percentage) # definitions here will overrides max_kcusage for these parameters # [param::] -param:nproc:70 +# Examples: +# param:nproc:70 -# specify parameters that should be excluded from the check +# specify parameters that should be excluded from the check # comma-separated list (as shown by kctune/kcusage) # (does not override param:: lines from above) # [ default: none ] @@ -24,4 +25,4 @@ exclude_params="" #****************************************************************************** # End of FILE -#****************************************************************************** \ No newline at end of file +#****************************************************************************** diff --git a/configs/etc/check_hpux_ntp_status.conf.dist b/configs/etc/check_hpux_ntp_status.conf.dist index 40151ad..5f37c84 100644 --- a/configs/etc/check_hpux_ntp_status.conf.dist +++ b/configs/etc/check_hpux_ntp_status.conf.dist @@ -9,7 +9,7 @@ # specify whether to also log passed health checks # (warning: this may rapidly grow the HC log) # [default: no] -log_healthy=yes +log_healthy="yes" # maximum allowed offset (in milliseconds (positive integers only)) # [default: 500] diff --git a/configs/etc/check_hpux_ovpa_status.conf.dist b/configs/etc/check_hpux_ovpa_status.conf.dist index 775c133..d93ad45 100644 --- a/configs/etc/check_hpux_ovpa_status.conf.dist +++ b/configs/etc/check_hpux_ovpa_status.conf.dist @@ -9,7 +9,7 @@ # specify whether to also log passed health checks # (warning: this may rapidly grow the HC log) # [default: no] -log_healthy=yes +log_healthy="yes" # list of OVPA daemons to check (comma-separated list) # [default: oacore,midaemon,perfalarm,ttd,ovcd,ovbbccb,perfd (v12)] diff --git a/configs/etc/check_hpux_patch_version.conf.dist b/configs/etc/check_hpux_patch_version.conf.dist index 49f5249..8bbdc00 100644 --- a/configs/etc/check_hpux_patch_version.conf.dist +++ b/configs/etc/check_hpux_patch_version.conf.dist @@ -9,7 +9,7 @@ # specify whether to also log passed health checks # (warning: this may rapidly grow the HC log) # [default: no] -log_healthy=yes +log_healthy="yes" # OE version that should be checked (version string as displayed by 'swlist') # [default: none] @@ -21,7 +21,7 @@ required_patches="" # check that all installed filesets are configured? # [default: yes] -check_filesets=yes +check_filesets="yes" # list of filesets to exclude from the check (comma-separated list) # [default: none] diff --git a/configs/etc/check_hpux_sfm_status.conf.dist b/configs/etc/check_hpux_sfm_status.conf.dist index d10fb20..cff707e 100644 --- a/configs/etc/check_hpux_sfm_status.conf.dist +++ b/configs/etc/check_hpux_sfm_status.conf.dist @@ -9,11 +9,11 @@ # specify whether to also log passed health checks (yes|no) # (warning: this may rapidly grow the HC log) # [default: no] -log_healthy=yes +log_healthy="yes" # specify whether to check for new events? (yes|no) # [default: yes] -check_events=yes +check_events="yes" # specify the age interval for which to check events # (format: X:mm|X:hh|X:dd|X:yy, where X stands for an integer and @@ -32,7 +32,7 @@ events_severity="CRITICAL" # specify whether to send a test event? (yes|no) # [default: no] -send_test_event=yes +send_test_event="yes" # specify wait time for test event (seconds) # [default: 60] diff --git a/configs/etc/check_hpux_sg_cluster_status.conf.dist b/configs/etc/check_hpux_sg_cluster_status.conf.dist index f029e95..26425a1 100644 --- a/configs/etc/check_hpux_sg_cluster_status.conf.dist +++ b/configs/etc/check_hpux_sg_cluster_status.conf.dist @@ -7,6 +7,7 @@ #****************************************************************************** # list of required cluster statuses (format : "parameter=value") +# Examples: #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 0d31a6c..44bd3b8 100644 --- a/configs/etc/check_hpux_sg_package_status.conf.dist +++ b/configs/etc/check_hpux_sg_package_status.conf.dist @@ -7,6 +7,7 @@ #****************************************************************************** # list of required package statuses (format : "package_name:parameter=value") +# Examples: #my_package|status=up diff --git a/configs/etc/check_linux_burp_backup.conf.dist b/configs/etc/check_linux_burp_backup.conf.dist index ad06c92..2bf2ac6 100644 --- a/configs/etc/check_linux_burp_backup.conf.dist +++ b/configs/etc/check_linux_burp_backup.conf.dist @@ -7,9 +7,10 @@ #****************************************************************************** # client name; maximum amount of warnings allowed; maximum backup age (hours/days/weeks) -testclient1;0;10h -testclient2;0;2d -testclient3;0;5w +# Examples: +#testclient1;0;10h +#testclient2;0;2d +#testclient3;0;5w #****************************************************************************** diff --git a/configs/etc/check_linux_file_change.conf.dist b/configs/etc/check_linux_file_change.conf.dist index d1aa4c7..64eed41 100644 --- a/configs/etc/check_linux_file_change.conf.dist +++ b/configs/etc/check_linux_file_change.conf.dist @@ -12,7 +12,7 @@ state_file=discovered.file_change # specify if file names need to be checked/flagged for meta characters [yes|no] # [default: yes] -do_meta_check=yes +do_meta_check="yes" # specify files or directories check (directories are automatically expanded) # format: @@ -20,11 +20,12 @@ do_meta_check=yes # excl: (excludes a path) # note: shell wild cards in the file paths are not supported! Exclusions have # a higher priority than inclusions. -incl:file1 -incl:dir1 -excl:dir1/file2 +# Examples: +#incl:file1 +#incl:dir1 +#excl:dir1/file2 #****************************************************************************** # End of FILE -#****************************************************************************** \ No newline at end of file +#****************************************************************************** diff --git a/configs/etc/check_linux_fs_usage.conf.dist b/configs/etc/check_linux_fs_usage.conf.dist index bb52334..c7d6dd3 100644 --- a/configs/etc/check_linux_fs_usage.conf.dist +++ b/configs/etc/check_linux_fs_usage.conf.dist @@ -9,15 +9,15 @@ # specify whether to also log passed health checks # (warning: this may rapidly grow the HC log) # [default: no] -log_healthy=yes +log_healthy="yes" # specify whether to perform inode usage check # [default: yes] -check_inodes_usage=yes +check_inodes_usage="yes" # specify whether to perform space usage check # [default: yes] -check_space_usage=yes +check_space_usage="yes" # specify the maximum % of inodes usage a filesystem may reach (general threshold) # [default: 90] @@ -31,6 +31,7 @@ max_space_usage=90 # for a given filesystem, the general threshold will be used (see above). When # defining a threshold of 0 (zero), then the check will for this give filesystem # will be skipped (this allows for exclusion of filesystems) +# Format: # [fs:::;;; # note: must exactly match the descriptor in /proc//limits # thresholds are optional (will not be checked when not specified) -user;postfix;Max open files;;75 +# Examples: +#user;postfix;Max open files;;75 # -- process stanzas -- # supported limit checks: Max open files @@ -25,7 +26,8 @@ user;postfix;Max open files;;75 # process:;;; # note: must exactly match the descriptor in /proc//limits # thresholds are optional (will not be checked when not specified) -process;nfsd;Max open files;100;80 +# Examples: +#process;nfsd;Max open files;100;80 #****************************************************************************** diff --git a/configs/etc/check_linux_sg_cluster_status.conf.dist b/configs/etc/check_linux_sg_cluster_status.conf.dist index 0c25d41..71bb1fb 100644 --- a/configs/etc/check_linux_sg_cluster_status.conf.dist +++ b/configs/etc/check_linux_sg_cluster_status.conf.dist @@ -7,6 +7,7 @@ #****************************************************************************** # list of required cluster statuses (format : "parameter=value") +# Examples: #status=up diff --git a/configs/etc/check_linux_sg_package_status.conf.dist b/configs/etc/check_linux_sg_package_status.conf.dist index b3298b7..7883d9f 100644 --- a/configs/etc/check_linux_sg_package_status.conf.dist +++ b/configs/etc/check_linux_sg_package_status.conf.dist @@ -7,6 +7,7 @@ #****************************************************************************** # list of required package statuses (format : "package_name:parameter=value") +# Examples: #my_package|status=up diff --git a/configs/etc/check_linux_vz_ct_status.conf.dist b/configs/etc/check_linux_vz_ct_status.conf.dist index e26c2b1..6b0d09f 100644 --- a/configs/etc/check_linux_vz_ct_status.conf.dist +++ b/configs/etc/check_linux_vz_ct_status.conf.dist @@ -10,6 +10,7 @@ # [ctid;runtime_status;boot_status] # runtime_status should be 'running' or 'stopped' # boot_status should be 'yes' or 'no' +# Examples: #100;running;yes 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 1ecf445..d50341c 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ignite_backup.sh @@ -28,6 +28,7 @@ # @(#) 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] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -39,7 +40,9 @@ function check_hpux_ignite_backup typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" # backup DONE identifier typeset _IGNITE_NEEDLE="^DONE" -typeset _VERSION="2019-01-24" # YYYY-MM-DD +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 _SUPPORTED_PLATFORMS="HP-UX" # uname -s match # ------------------------- CONFIGURATION ends here --------------------------- @@ -50,6 +53,8 @@ typeset _ARGS=$(data_comma2space "$*") typeset _ARG="" typeset _MSG="" typeset _STC=0 +typeset _CFG_HEALTHY="" +typeset _LOG_HEALTHY=0 typeset _BACKUP_AGE=0 typeset _EXCLUDE_HOSTS="" typeset _IGNITE_HOST="" @@ -89,24 +94,55 @@ esac log "backup age to check: ${_BACKUP_AGE} days" _EXCLUDE_HOSTS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'exclude_hosts') [[ -n "${_EXCLUDE_HOSTS}" ]] && log "excluding hosts: $(print ${_EXCLUDE_HOSTS})" +_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 if this host is an Ignite-UX server +if [[ ! -f ${_IGNITE_SERVER_FILE} ]] +then + warn "host is not an Ignite-UX server" + return 1 +fi # perform check on Ignite 'client_status' files -if [[ -d /var/opt/ignite/clients ]] +if [[ -d ${_IGNITE_CLIENTS_DIR} ]] then _OLD_PWD="$(pwd)" # shellcheck disable=SC2164 - cd /var/opt/ignite/clients + cd ${_IGNITE_CLIENTS_DIR} + # shellcheck disable=SC2181 if (( $? > 0 )) then - _MSG="unable to run command: cd /var/opt/ignite/clients" - log_hc "$0" 1 "${_MSG}" + warn "unable to run command: {cd ${_IGNITE_CLIENTS_DIR}}" # dump debug info (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi # check backup states - find * -prune -type l | while read _IGNITE_HOST + find -- * -prune -type l 2>/dev/null | while read -r _IGNITE_HOST do # check exclude [[ "${_EXCLUDE_HOSTS#*${_IGNITE_HOST}}" != "${_EXCLUDE_HOSTS}" ]] && continue @@ -146,12 +182,15 @@ then fi # handle unit result - log_hc "$0" ${_STC} "${_MSG}" - _STC=0 + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + _STC=0 + fi done # check backup ages - find * -prune -type l | while read _IGNITE_HOST + find -- * -prune -type l 2>/dev/null | while read -r _IGNITE_HOST do # check exclude [[ "${_EXCLUDE_HOSTS#*${_IGNITE_HOST}}" != "${_EXCLUDE_HOSTS}" ]] && continue @@ -175,23 +214,27 @@ then fi # handle unit result - log_hc "$0" ${_STC} "${_MSG}" - _STC=0 + if (( _LOG_HEALTHY > 0 || _STC > 0 )) + then + log_hc "$0" ${_STC} "${_MSG}" + _STC=0 + fi done # shellcheck disable=SC2164 cd "${_OLD_PWD}" + # shellcheck disable=SC2181 if (( $? > 0 )) then - _MSG="unable to run command: cd /var/opt/ignite/clients" + _MSG="unable to run command: {cd ${_IGNITE_CLIENTS_DIR}}" log_hc "$0" 1 "${_MSG}" # dump debug info (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs return 1 fi else - _MSG="Host is not an Ignite/UX server" - log_hc "$0" ${_STC} "${_MSG}" + warn "could not access/find the Ignite-UX's clients directory at ${_IGNITE_CLIENTS_DIR}" + return 1 fi return 0 @@ -208,6 +251,7 @@ CONFIG : $3 with: 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