* Added Clusterware (CRS) plugins (as a platform).
* Moved Serviceguard plugins to separate platform (+fixes) * Other fixes
This commit is contained in:
@@ -1,195 +0,0 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_sg_cluster_config
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2016 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_hpux_sg_cluster_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-03-08: initial version [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_sg_cluster_config
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
typeset _SG_DAEMON="/usr/lbin/cmcld"
|
||||
# rubbish that cmgetconf outputs to STDOUT instead of STDERR
|
||||
typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _CLUSTER_RUN_FILE="${TMP_DIR}/.$0.cluster_run.$$"
|
||||
typeset _CLUSTER_CFG_FILE="${TMP_DIR}/.$0.cluster_cfg.$$"
|
||||
typeset _CLUSTER_INSTANCE=""
|
||||
typeset _CLUSTER_INSTANCES=""
|
||||
typeset _CLUSTER_ENTRY=""
|
||||
typeset _CLUSTER_CFG_ENTRY=""
|
||||
typeset _CLUSTER_MATCH=""
|
||||
typeset _CLUSTER_PARAM=""
|
||||
typeset _CLUSTER_VALUE=""
|
||||
|
||||
# set local trap for cleanup
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
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
|
||||
|
||||
# look for cluster instance names
|
||||
grep -E -e '^\[' ${_CONFIG_FILE} 2>/dev/null | cut -f1 -d']' | cut -f2 -d'[' |\
|
||||
while read _CLUSTER_INSTANCE
|
||||
do
|
||||
_CLUSTER_INSTANCES="${_CLUSTER_INSTANCES} ${_CLUSTER_INSTANCE}"
|
||||
done
|
||||
if [[ -z "${_CLUSTER_INSTANCES}" ]]
|
||||
then
|
||||
warn "no cluster information configured in ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check serviceguard status & gather cluster information from running cluster (compressed lines)
|
||||
if [[ ! -x ${_SG_DAEMON} ]]
|
||||
then
|
||||
warn "${_SG_DAEMON} is not installed here"
|
||||
return 1
|
||||
else
|
||||
for _CLUSTER_INSTANCE in ${_CLUSTER_INSTANCES}
|
||||
do
|
||||
cmgetconf -c ${_CLUSTER_INSTANCE} 2>>${HC_STDERR_LOG} |\
|
||||
grep -v -E -e "${_SG_CMGETCONF_FILTER}" | tr -d ' \t' >${_CLUSTER_RUN_FILE}.${_CLUSTER_INSTANCE}
|
||||
[[ -s ${_CLUSTER_RUN_FILE}.${_CLUSTER_INSTANCE} ]] || {
|
||||
_MSG="unable to gather cluster configuration"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
return 0
|
||||
}
|
||||
done
|
||||
fi
|
||||
|
||||
# gather cluster information from healthcheck configuration
|
||||
for _CLUSTER_INSTANCE in ${_CLUSTER_INSTANCES}
|
||||
do
|
||||
awk -v cluster="${_CLUSTER_INSTANCE}" '
|
||||
BEGIN { found = 0; needle = "^\["cluster"\]" }
|
||||
|
||||
# skip blank lines
|
||||
/^\s*$/ { next; }
|
||||
# skip comment lines
|
||||
/^#/ { next; }
|
||||
|
||||
# end marker
|
||||
( $0 ~ /^\[.*\]/ && found ) {
|
||||
found = 0;
|
||||
}
|
||||
# start marker
|
||||
$0 ~ needle {
|
||||
found = 1;
|
||||
};
|
||||
# stanza body
|
||||
( found && $0 !~ /^\[.*\]/ ) {
|
||||
# print non-compressed and compressed version
|
||||
printf "%s|", $0;
|
||||
gsub(" |\t", "", $0);
|
||||
printf "%s\n", $0;
|
||||
}' < ${_CONFIG_FILE} 2>>${HC_STDERR_LOG} >${_CLUSTER_CFG_FILE}.${_CLUSTER_INSTANCE}
|
||||
done
|
||||
|
||||
# do cluster configuration checks (using the compressed strings)
|
||||
for _CLUSTER_INSTANCE in ${_CLUSTER_INSTANCES}
|
||||
do
|
||||
while read _CLUSTER_ENTRY
|
||||
do
|
||||
# split entry to get the compressed version
|
||||
_CLUSTER_CFG_ENTRY=$(print "${_CLUSTER_ENTRY}" | cut -f2 -d'|')
|
||||
# get parameter name from non-compressed version
|
||||
_CLUSTER_PARAM=$(print "${_CLUSTER_ENTRY}" | cut -f1 -d'|' | awk '{ print $1 }')
|
||||
# get parameter value from non-compressed version
|
||||
_CLUSTER_VALUE=$(print "${_CLUSTER_ENTRY}" | cut -f1 -d'|' | awk '{ print substr($2,1,30)}')
|
||||
# is it present?
|
||||
_CLUSTER_MATCH=$(grep -c "${_CLUSTER_CFG_ENTRY}" ${_CLUSTER_RUN_FILE}.${_CLUSTER_INSTANCE} 2>/dev/null)
|
||||
if (( _CLUSTER_MATCH == 0 ))
|
||||
then
|
||||
# get parameter name from non-compressed version
|
||||
_MSG="'${_CLUSTER_PARAM} (${_CLUSTER_VALUE} ...)' is not correctly configured for ${_CLUSTER_INSTANCE}"
|
||||
_STC=1
|
||||
else
|
||||
_MSG="'${_CLUSTER_PARAM} (${_CLUSTER_VALUE} ...)' is configured for ${_CLUSTER_INSTANCE}"
|
||||
fi
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done <${_CLUSTER_CFG_FILE}.${_CLUSTER_INSTANCE}
|
||||
done
|
||||
|
||||
# do cleanup
|
||||
rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks the configuration of Serviceguard cluster (SG 11.16+) (comparing
|
||||
serialized strings from the plugin configuration file to the running cluster
|
||||
configuration)
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -1,185 +0,0 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_sg_cluster_status
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2016 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_hpux_sg_cluster_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-03-25: initial version [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken]
|
||||
# @(#) 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]
|
||||
# @(#) 2019-04-08: IFS fix [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_sg_cluster_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-04-08" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
typeset _SG_DAEMON="/usr/lbin/cmcld"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
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}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
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 "^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} ]]
|
||||
then
|
||||
warn "${_SG_DAEMON} is not installed here"
|
||||
return 1
|
||||
else
|
||||
cmviewcl -v -f line 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG}
|
||||
(( $? > 0 )) && {
|
||||
_MSG="unable to run command: {cmviewcl}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
fi
|
||||
|
||||
# do cluster status checks
|
||||
# (replace ':' by '|' for cmcviewcl output)
|
||||
grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
|
||||
while IFS=":" read -r _ _SG_ENTRY
|
||||
do
|
||||
# field split
|
||||
_SG_CFG_PARAM="$(print ${_SG_ENTRY} | cut -f1 -d'=')" # field 1
|
||||
_SG_CFG_VALUE="$(print ${_SG_ENTRY} | cut -f2 -d'=')" # field 2
|
||||
|
||||
# check run-time values (anchored grep here!)
|
||||
_SG_MATCH=$(grep -i "^${_SG_CFG_PARAM}" ${HC_STDOUT_LOG} 2>/dev/null)
|
||||
if [[ -n "${_SG_MATCH}" ]]
|
||||
then
|
||||
_SG_RUN_VALUE=$(print "${_SG_MATCH}" | cut -f2 -d'=') # field 2
|
||||
|
||||
if [[ "${_SG_CFG_VALUE}" = "${_SG_RUN_VALUE}" ]]
|
||||
then
|
||||
_MSG="cluster parameter ${_SG_CFG_PARAM} has a correct value [${_SG_RUN_VALUE}]"
|
||||
_STC=0
|
||||
else
|
||||
_MSG="cluster parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]"
|
||||
_STC=1
|
||||
fi
|
||||
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
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
and formatted stanzas:
|
||||
sg:<param>=<value>
|
||||
PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+)
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -1,195 +0,0 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_sg_package_config
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2016 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_hpux_sg_package_config
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-03-08: initial version [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_sg_package_config
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
typeset _SG_DAEMON="/usr/lbin/cmcld"
|
||||
# rubbish that cmgetconf outputs to STDOUT instead of STDERR
|
||||
typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _PKG_RUN_FILE="${TMP_DIR}/.$0.pkg_run.$$"
|
||||
typeset _PKG_CFG_FILE="${TMP_DIR}/.$0.pkg_cfg.$$"
|
||||
typeset _PKG_INSTANCE=""
|
||||
typeset _PKG_INSTANCES=""
|
||||
typeset _PKG_ENTRY=""
|
||||
typeset _PKG_CFG_ENTRY=""
|
||||
typeset _PKG_MATCH=""
|
||||
typeset _PKG_PARAM=""
|
||||
typeset _PKG_VALUE=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# set local trap for cleanup
|
||||
# shellcheck disable=SC2064
|
||||
trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
|
||||
|
||||
# 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
|
||||
|
||||
# look for package instance names
|
||||
grep -E -e '^\[' ${_CONFIG_FILE} 2>/dev/null | cut -f1 -d']' | cut -f2 -d'[' |\
|
||||
while read _PKG_INSTANCE
|
||||
do
|
||||
_PKG_INSTANCES="${_PKG_INSTANCES} ${_PKG_INSTANCE}"
|
||||
done
|
||||
if [[ -z "${_PKG_INSTANCES}" ]]
|
||||
then
|
||||
warn "no package information configured in ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check serviceguard status & gather package information from running cluster (compressed lines)
|
||||
if [[ ! -x ${_SG_DAEMON} ]]
|
||||
then
|
||||
warn "${_SG_DAEMON} is not installed here"
|
||||
return 1
|
||||
else
|
||||
for _PKG_INSTANCE in ${_PKG_INSTANCES}
|
||||
do
|
||||
cmgetconf -p ${_PKG_INSTANCE} -v 0 2>>${HC_STDERR_LOG} |\
|
||||
grep -v -E -e "${_SG_CMGETCONF_FILTER}" | tr -d ' \t' >${_PKG_RUN_FILE}.${_PKG_INSTANCE}
|
||||
[[ -s ${_PKG_RUN_FILE}.${_PKG_INSTANCE} ]] || {
|
||||
_MSG="unable to gather package configuration for at least one cluster package"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
return 0
|
||||
}
|
||||
done
|
||||
fi
|
||||
|
||||
# gather package information from healthcheck configuration
|
||||
for _PKG_INSTANCE in ${_PKG_INSTANCES}
|
||||
do
|
||||
awk -v package="${_PKG_INSTANCE}" '
|
||||
BEGIN { found = 0; needle = "^\["package"\]" }
|
||||
|
||||
# skip blank lines
|
||||
/^\s*$/ { next; }
|
||||
# skip comment lines
|
||||
/^#/ { next; }
|
||||
|
||||
# end marker
|
||||
( $0 ~ /^\[.*\]/ && found ) {
|
||||
found = 0;
|
||||
}
|
||||
# start marker
|
||||
$0 ~ needle {
|
||||
found = 1;
|
||||
};
|
||||
# stanza body
|
||||
( found && $0 !~ /^\[.*\]/ ) {
|
||||
# print non-compressed and compressed version
|
||||
printf "%s|", $0;
|
||||
gsub(" |\t", "", $0);
|
||||
printf "%s\n", $0;
|
||||
}' < ${_CONFIG_FILE} 2>>${HC_STDERR_LOG} >${_PKG_CFG_FILE}.${_PKG_INSTANCE}
|
||||
done
|
||||
|
||||
# do package configuration checks (using the compressed strings)
|
||||
for _PKG_INSTANCE in ${_PKG_INSTANCES}
|
||||
do
|
||||
while read _PKG_ENTRY
|
||||
do
|
||||
# split entry to get the compressed version
|
||||
_PKG_CFG_ENTRY=$(print "${_PKG_ENTRY}" | cut -f2 -d'|')
|
||||
# get parameter name from non-compressed version
|
||||
_PKG_PARAM=$(print "${_PKG_ENTRY}" | awk '{ print $1 }')
|
||||
# get parameter value from non-compressed version
|
||||
_PKG_VALUE=$(print "${_PKG_ENTRY}" | cut -f1 -d'|' | awk '{ print substr($2,1,30)}')
|
||||
# is it present?
|
||||
_PKG_MATCH=$(grep -c "${_PKG_CFG_ENTRY}" ${_PKG_RUN_FILE}.${_PKG_INSTANCE} 2>/dev/null)
|
||||
if (( _PKG_MATCH == 0 ))
|
||||
then
|
||||
# get parameter name from non-compressed version
|
||||
_MSG="'${_PKG_PARAM} (${_PKG_VALUE} ...)' is not correctly configured for ${_PKG_INSTANCE}"
|
||||
_STC=1
|
||||
else
|
||||
_MSG="'${_PKG_PARAM} (${_PKG_VALUE} ...)' is configured for ${_PKG_INSTANCE}"
|
||||
fi
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done <${_PKG_CFG_FILE}.${_PKG_INSTANCE}
|
||||
done
|
||||
|
||||
# do cleanup
|
||||
rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks the configuration of Serviceguard packages (SG 11.16+) (comparing
|
||||
serialized strings from the HC configuration file to the running cluster
|
||||
configuration)
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -1,187 +0,0 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_sg_package_status
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2016 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_hpux_sg_package_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-03-08: initial version [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken]
|
||||
# @(#) 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]
|
||||
# @(#) 2019-04-08: IFS fix [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_sg_package_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-04-08" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
typeset _SG_DAEMON="/usr/lbin/cmcld"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
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}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
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 "^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} ]]
|
||||
then
|
||||
warn "${_SG_DAEMON} is not installed here"
|
||||
return 1
|
||||
else
|
||||
cmviewcl -v -f line -l package 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG}
|
||||
(( $? > 0)) && {
|
||||
_MSG="unable to run command: {cmviewcl}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
fi
|
||||
|
||||
# do package status checks
|
||||
# (replace ':' by '|' for cmcviewcl output)
|
||||
grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
|
||||
while IFS=":" read -r _ _SG_ENTRY
|
||||
do
|
||||
# field split
|
||||
_SG_PACKAGE="$(print ${_SG_ENTRY} | cut -f1 -d':')"
|
||||
_SG_CFG_PARAM="$(print ${_SG_ENTRY} | cut -f2- -d':' | cut -f1 -d'=')" # field 2-,1
|
||||
_SG_CFG_VALUE="$(print ${_SG_ENTRY} | cut -f2- -d':' | cut -f2 -d'=')" # field 2-,2
|
||||
|
||||
# check run-time values (anchored grep here!)
|
||||
_SG_MATCH=$(grep -i "^package:${_SG_PACKAGE}:${_SG_CFG_PARAM}" ${HC_STDOUT_LOG} 2>/dev/null)
|
||||
if [[ -n "${_SG_MATCH}" ]]
|
||||
then
|
||||
_SG_RUN_VALUE=$(print "${_SG_MATCH}" | cut -f3- -d':' | cut -f2 -d'=') # field3-,2
|
||||
|
||||
if [[ "${_SG_CFG_VALUE}" = "${_SG_RUN_VALUE}" ]]
|
||||
then
|
||||
_MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a correct value [${_SG_RUN_VALUE}]"
|
||||
_STC=0
|
||||
else
|
||||
_MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]"
|
||||
_STC=1
|
||||
fi
|
||||
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
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
and formatted stanzas:
|
||||
sg:<package_name>:<parameter>=<value>
|
||||
PURPOSE : Checks the status of Serviceguard package parameters (SG 11.16+)
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -1,137 +0,0 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_sg_qs_status.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2017 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_hpux_sg_qs_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# 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!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_sg_qs_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
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"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
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
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
|
||||
# check QS presence
|
||||
if [[ ! -x ${_QS_BIN} ]]
|
||||
then
|
||||
warn "${_QS_BIN} is not installed here"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# ---- process state ----
|
||||
(( $(pgrep -u root -f ${_QS_BIN} 2>>${HC_STDERR_LOG} | wc -l) == 0 )) && _STC=1
|
||||
|
||||
# evaluate results
|
||||
case ${_STC} in
|
||||
0)
|
||||
_MSG="QS is running"
|
||||
;;
|
||||
1)
|
||||
_MSG="QS is not running"
|
||||
;;
|
||||
*)
|
||||
_MSG="could not determine status of QS"
|
||||
;;
|
||||
esac
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
# ---- config state ----
|
||||
if [[ -s ${_QS_AUTH_FILE} ]]
|
||||
then
|
||||
_MSG="QS authorizations file has been configured"
|
||||
_STC=0
|
||||
else
|
||||
_MSG="QS authorizations file is missing or empty (${_QS_AUTH_FILE})"
|
||||
_STC=1
|
||||
fi
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether the Serviceguard quorum server is running
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
Reference in New Issue
Block a user