From 9a44dabd0d343a058e6aa0589785bb129c48278f Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Wed, 29 Aug 2018 20:01:08 +0200 Subject: [PATCH] Added config file to check_hpux_ovpa_status() plugin so a custom list of daemons to be checked can be specified --- .../hc_hpux_platform/hc_hpux_platform.psf | 1 + configs/etc/check_hpux_ovpa_status.conf.dist | 15 +++++ .../platform/hp-ux/check_hpux_ovpa_status.sh | 58 +++++++++++++------ 3 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 configs/etc/check_hpux_ovpa_status.conf.dist diff --git a/build/hpux/hc_hpux_platform/hc_hpux_platform.psf b/build/hpux/hc_hpux_platform/hc_hpux_platform.psf index 1fb30ac..4c9f83c 100644 --- a/build/hpux/hc_hpux_platform/hc_hpux_platform.psf +++ b/build/hpux/hc_hpux_platform/hc_hpux_platform.psf @@ -112,6 +112,7 @@ This is the OS/platform plugin package" file -m 644 check_hpux_kernel_params.conf.dist file -m 644 check_hpux_kernel_usage.conf.dist file -m 644 check_hpux_ntp_status.conf.dist + file -m 755 check_hpux_ovpa_status.conf.dist file -m 755 check_hpux_patch_version.conf.dist file -m 644 check_hpux_root_crontab.conf.dist file -m 644 check_hpux_sg_package_status.conf.dist diff --git a/configs/etc/check_hpux_ovpa_status.conf.dist b/configs/etc/check_hpux_ovpa_status.conf.dist new file mode 100644 index 0000000..68eddef --- /dev/null +++ b/configs/etc/check_hpux_ovpa_status.conf.dist @@ -0,0 +1,15 @@ +#****************************************************************************** +# @(#) check_hpux_ovpa_status.conf.dist +#****************************************************************************** +# This is a configuration file for the check_hpux_ovpa_status HC plugin. +# All lines starting with a '#' are comment lines. +# [default: indicates hardcoded script values if no value is defined here] +#****************************************************************************** + +# list of OVPA daemons to check (comma-separated list) +# [default: oacore,midaemon,perfalarm,ttd,ovcd,ovbbccb,perfd (v12)] +ovpa_daemons="" + +#****************************************************************************** +# End of FILE +#****************************************************************************** \ No newline at end of file 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 f10ff6b..5be70d8 100644 --- a/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh +++ b/sources/lib/platform/hp-ux/check_hpux_ovpa_status.sh @@ -25,6 +25,7 @@ # @(#) 2016-04-08: initial version [Patrick Van der Veken] # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] # @(#) 2018-07-10: added log_healthy hc_arg [Patrick Van der Veken] +# @(#) 2018-08-30: added config file + check list for daemons [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -33,7 +34,8 @@ function check_hpux_ovpa_status { # ------------------------- CONFIGURATION starts here ------------------------- -typeset _VERSION="2018-07-10" # YYYY-MM-DD +typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" +typeset _VERSION="2018-08-30" # YYYY-MM-DD typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _OVPA_BIN="/opt/perf/bin/perfstat" # ------------------------- CONFIGURATION ends here --------------------------- @@ -60,6 +62,36 @@ 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 +# read required configuration values +_OVPA_DAEMONS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'ovpa_daemons') +if [[ -z "${_OVPA_DAEMONS}" ]] +then + # default + # get ovpa version (<12.x: scopeux; >=12.x: oacore, no coda) + _OVPA_VERSION="$(${_OVPA_BIN} -v 2>>${HC_STDERR_LOG} | grep "HP Performance Agent" 2>/dev/null | awk '{ print $NF }') 2>/dev/null" + case "${_OVPA_VERSION}" in + 12.*) + log "running HP Operations Agent v12" + _OVPA_DAEMONS="oacore midaemon perfalarm ttd ovcd ovbbccb perfd" + ;; + *) + log "running HP Operations Agent v11 or lower ..." + _OVPA_DAEMONS="scopeux midaemon perfalarm ttd ovcd ovbbccb coda perfd" + ;; + esac +else + # convert commas and strip quotes + _OVPA_DAEMONS=$(data_comma2space $(data_dequote "${_OVPA_DAEMONS}")) +fi +log "checking daemons: ${_OVPA_DAEMONS} ..." + # log_healthy (( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1 if (( _LOG_HEALTHY > 0 )) @@ -73,9 +105,9 @@ then else log "not logging/showing passed health checks" fi - + # check & get ovpa status -if [[ ! -x ${_OVPA_BIN} ]] +if [[ ! -x ${_OVPA_BIN} ]] then warn "${_OVPA_BIN} is not installed here" return 1 @@ -84,19 +116,6 @@ else # no RC check here because perfstat will throw <>0 when procs are down fi -# get ovpa version (<12.x: scopeux; >=12.x: oacore, no coda) -_OVPA_VERSION="$(${_OVPA_BIN} -v 2>>${HC_STDERR_LOG} | grep "HP Performance Agent" | awk '{ print $NF }')" -case "${_OVPA_VERSION}" in - 12.*) - log "running HP Operations Agent v12 ..." - _OVPA_DAEMONS="oacore midaemon perfalarm ttd ovcd ovbbccb" - ;; - *) - log "running HP Operations Agent v11 or lower ..." - _OVPA_DAEMONS="scopeux midaemon perfalarm ttd ovcd ovbbccb coda" - ;; -esac - # do OVPA status checks for _OVPA_DAEMON in ${_OVPA_DAEMONS} do @@ -106,12 +125,12 @@ do 0) _MSG="${_OVPA_DAEMON} is not running" _STC=1 - ;; + ;; *) _MSG="${_OVPA_DAEMON} is running" ;; esac - + # handle result if (( _LOG_HEALTHY > 0 || _STC > 0 )) then @@ -129,7 +148,8 @@ function _show_usage cat <<- EOT NAME : $1 VERSION : $2 -CONFIG : $3 +CONFIG : $3 with: + ovpa_daemons= PURPOSE : Checks the status of OVPA processes (OpenView Performance Agent) LOG HEALTHY : Supported