* Added Clusterware (CRS) plugins (as a platform).

* Moved Serviceguard plugins to separate platform (+fixes)
* Other fixes
This commit is contained in:
Patrick Van der Veken
2019-04-24 14:19:02 +02:00
parent a4e1b4b954
commit 05dd91edc4
49 changed files with 1584 additions and 1126 deletions
+33 -1
View File
@@ -30,7 +30,7 @@
# RETURNS: 0
function version_include_data
{
typeset _VERSION="2019-03-16" # YYYY-MM-DD
typeset _VERSION="2019-04-20" # YYYY-MM-DD
print "INFO: $0: ${_VERSION#version_*}"
@@ -80,6 +80,38 @@ print -R "${1%?}" 2>/dev/null
return 0
}
# -----------------------------------------------------------------------------
# @(#) FUNCTION: data_get_length_string()
# DOES: get length of a string
# EXPECTS: string
# OUTPUTS: length of string [integer]
# RETURNS: 0
# REQUIRES: n/a
function data_get_length_string
{
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
print -R "${#1}" 2>/dev/null
return 0
}
# -----------------------------------------------------------------------------
# @(#) FUNCTION: data_get_substring()
# DOES: get a substring of a string
# EXPECTS: $1=string; $2=length of substring [integer]
# OUTPUTS: substring [string]
# RETURNS: 0
# REQUIRES: n/a
function data_get_substring
{
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
print -R "${1}" | cut -f1-${2} 2>/dev/null
return 0
}
# -----------------------------------------------------------------------------
# @(#) FUNCTION: data_contains_string()
# DOES: checks if a string (haystack) contains a substring (needle).
+3 -1
View File
@@ -30,7 +30,7 @@
function notify_mail
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _VERSION="2019-03-16" # YYYY-MM-DD
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@@ -130,6 +130,7 @@ fi
eval "cat << __EOT
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_HEADER_TPL})
__EOT" >>${_TMP1_MAIL_FILE}
print "" >>${_TMP1_MAIL_FILE}
# create body part (from $HC_MSG_VAR)
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _MAIL_MSG_STC _ _MAIL_MSG_TEXT _MAIL_MSG_CUR_VAL _MAIL_MSG_EXP_VAL
@@ -175,6 +176,7 @@ done
eval "cat << __EOT
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_BODY_TPL})
__EOT" >>${_TMP1_MAIL_FILE}
print "" >>${_TMP1_MAIL_FILE}
# HC STDOUT log? (drop the .$$ bit)
_MAIL_STDOUT_LOG="${EVENTS_DIR}/${DIR_PREFIX}/${_MAIL_FAIL_ID}/${_HC_STDOUT_LOG_SHORT%.*}"
@@ -0,0 +1,236 @@
#!/usr/bin/env ksh
#******************************************************************************
# @(#) check_clusterware_resource_config
#******************************************************************************
# @(#) Copyright (C) 2019 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_clusterware_resource_config
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
#
# @(#) HISTORY:
# @(#) 2019-04-20: merged HP-UX+Linux version + fixes [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_clusterware_resource_config
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _MAX_LENGTH_VALUE_STRING=30
# ------------------------- 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 _CRSCTL_BIN=""
typeset _RES_RUN_FILE="${TMP_DIR}/.$0.res_run.$$"
typeset _RES_CFG_FILE="${TMP_DIR}/.$0.res_cfg.$$"
typeset _RES_INSTANCE=""
typeset _RES_INSTANCES=""
typeset _RES_CFG_ENTRY=""
typeset _RES_ENTRY=""
typeset _RES_MATCH=""
typeset _RES_PARAM=""
typeset _RES_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 ${_RES_RUN_FILE}.* ${_RES_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
_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
# look for resource instance names
grep -E -e '^\[' ${_CONFIG_FILE} 2>/dev/null | cut -f1 -d']' 2>/dev/null | cut -f2 -d'[' 2>/dev/null |\
while read _RES_INSTANCE
do
_RES_INSTANCES="${_RES_INSTANCES} ${_RES_INSTANCE}"
done
if [[ -z "${_RES_INSTANCES}" ]]
then
warn "no resource information configured in ${_CONFIG_FILE}"
return 1
fi
# get resource information from crsctl
_CRSCTL_BIN="$(command -v crsctl 2>>${HC_STDERR_LOG})"
if [[ -z "${_CRSCTL_BIN}" || ! -x ${_CRSCTL_BIN} ]]
then
warn "CRS {crsctl} is not installed here"
return 1
else
for _RES_INSTANCE in ${_RES_INSTANCES}
do
crsctl status resource ${_RES_INSTANCE} -f 2>>${HC_STDERR_LOG} |\
tr -d ' \t' >${_RES_RUN_FILE}.${_RES_INSTANCE} 2>/dev/null
[[ -s ${_RES_RUN_FILE}.${_RES_INSTANCE} ]] || {
_MSG="unable to gather configuration cluster resource ${_RES_INSTANCE}"
log_hc "$0" 1 "${_MSG}"
# dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 1
}
done
fi
# gather resource information from healthcheck configuration
for _RES_INSTANCE in ${_RES_INSTANCES}
do
awk -v resource="${_RES_INSTANCE}" '
# double escape []
BEGIN { found = 0; needle = "^\\["resource"\\]$" }
# skip blank lines
/^\s*$/ { next; }
# skip comment lines
/^#/ { next; }
# end marker
( $0 ~ /^\[.*\]$/ && found ) {
exit 1;
}
# 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} >${_RES_CFG_FILE}.${_RES_INSTANCE}
done
# do resource configuration checks (using the compressed strings)
for _RES_INSTANCE in ${_RES_INSTANCES}
do
while read _RES_ENTRY
do
# split entry to get the compressed version
_RES_CFG_ENTRY=$(print "${_RES_ENTRY}" | cut -f2 -d'|' 2>/dev/null)
# get parameter name from non-compressed version
_RES_PARAM=$(print "${_RES_ENTRY}" | cut -f1 -d'|' 2>/dev/null | cut -f1 -d'=' 2>/dev/null)
# get parameter value from non-compressed version
_RES_VALUE=$(print "${_RES_ENTRY}" | cut -f1 -d'|' 2>/dev/null | cut -f2 -d'=' 2>/dev/null)
# is it present?
_RES_MATCH=$(grep -c "${_RES_CFG_ENTRY}" ${_RES_RUN_FILE}.${_RES_INSTANCE} 2>/dev/null)
# chop value if needed
if (( $(data_get_length_string "${_RES_VALUE}") > _MAX_LENGTH_VALUE_STRING ))
then
_RES_VALUE=$(data_get_substring "${_RES_VALUE}" ${_MAX_LENGTH_VALUE_STRING})
_RES_VALUE="${_RES_VALUE} ..."
fi
# find match between active and desired state?
if (( _RES_MATCH == 0 ))
then
# get parameter name from non-compressed version
_MSG="'${_RES_PARAM}' (${_RES_VALUE}) is not correctly configured for ${_RES_INSTANCE}"
_STC=1
else
_MSG="'${_RES_PARAM}' (${_RES_VALUE}) is configured for ${_RES_INSTANCE}"
fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
_STC=0
fi
done <${_RES_CFG_FILE}.${_RES_INSTANCE}
# add crsctl output to stdout log
print "==== {${_CRSCTL_BIN} status resource ${_RES_INSTANCE} -f} ====" >>${HC_STDOUT_LOG}
cat "${_RES_CFG_FILE}.${_RES_INSTANCE}" >>${HC_STDOUT_LOG}
done
# do cleanup
rm -f ${_RES_RUN_FILE}.* ${_RES_CFG_FILE}.* >/dev/null 2>&1
return 0
}
# -----------------------------------------------------------------------------
function _show_usage
{
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3 with parameters:
log_healthy=<yes|no>
and formatted stanzas for resource definitions
PURPOSE : Checks the configuration of Clusterware resources (parameters/values)
(comparing serialized strings from the HC configuration file to the
active cluster configuration)
EOT
return 0
}
#******************************************************************************
# END of script
#******************************************************************************
@@ -0,0 +1,217 @@
#!/usr/bin/env ksh
#******************************************************************************
# @(#) check_clusterware_resource_status
#******************************************************************************
# @(#) Copyright (C) 2019 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_clusterware_resource_status
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), data_contains_string(), data_uc(), dump_logs(),
# init_hc(), log_hc(), warn()
#
# @(#) HISTORY:
# @(#) 2019-04-20: merged HP-UX+Linux version [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_clusterware_resource_status
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- 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 _CRS_HOST=""
typeset _CRS_NEEDLE=""
typeset _CRS_RESOURCE=""
typeset _CRS_STATES=""
typeset _CRS_STATE=""
typeset _CRS_STATES_ENTRY=""
typeset _CRS_STATE_ENTRY=""
typeset _CRSCTL_BIN=""
typeset _CRSCTL_STATUS=""
typeset _IS_ONLINE=0
typeset _MATCH_RC=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
# 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 clusterware
_CRSCTL_BIN="$(command -v crsctl 2>>${HC_STDERR_LOG})"
if [[ -z "${_CRSCTL_BIN}" || ! -x ${_CRSCTL_BIN} ]]
then
warn "CRS {crsctl} is not installed here"
return 1
fi
# do resource status checks
grep -E -e "^crs:" ${_CONFIG_FILE} 2>/dev/null |\
while IFS=":" read -r _ _CRS_RESOURCE _CRS_STATES
do
# get actual resource info
(( ARG_DEBUG > 0 )) && debug "checking for resource: ${_CRS_RESOURCE}"
_CRSCTL_STATUS=$(crsctl status resource "${_CRS_RESOURCE}" 2>>${HC_STDERR_LOG})
if (( $? > 0 )) || [[ -z "${_CRSCTL_STATUS}" ]]
then
_MSG="unable to run command: {crsctl status resource ${_CRS_RESOURCE}}"
log_hc "$0" 1 "${_MSG}"
# dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 1
fi
# loop over host/state entries
print "${_CRS_STATES}" | while IFS=',' read -rA _CRS_STATES_ENTRY
do
_IS_ONLINE=0
for _CRS_STATE_ENTRY in "${_CRS_STATES_ENTRY[@]}"
do
_CRS_HOST=$(print "${_CRS_STATE_ENTRY}" | cut -f1 -d'=' 2>/dev/null)
_CRS_STATE=$(print "${_CRS_STATE_ENTRY}" | cut -f2 -d'=' 2>/dev/null)
if [[ -z "${_CRS_HOST}" || -z "${_CRS_STATE}" ]]
then
warn "host/state value(s) for resource ${_CRS_RESOURCE} are/is incorrect in configuration file ${_CONFIG_FILE}"
continue
fi
(( ARG_DEBUG > 0 )) && debug "checking for host/state: ${_CRS_HOST}/${_CRS_STATE}"
# get actual resource state
CRS_STATE_LINE=$(print "${_CRSCTL_STATUS}" | grep -E -e "^STATE=" 2>/dev/null)
# set needle (wildcard or host check?)
if [[ "${_CRS_HOST}" = "*" ]]
then
_CRS_NEEDLE=$(data_uc "${_CRS_STATE}")
else
case "${_CRS_STATE}" in
ONLINE|online|Online)
_CRS_NEEDLE=$(data_uc "${_CRS_STATE}")
_CRS_NEEDLE="${_CRS_NEEDLE} on ${_CRS_HOST}"
;;
OFFLINE|offline|Offline)
_CRS_NEEDLE=$(data_uc "${_CRS_STATE}")
;;
esac
fi
# check for match
# if resource is online on at least one node, then CRS will not flag it offline
# on any other nodes in which case we just do a NOOP
# (ONLINE stanzas must preceed OFFLINE stanzas in the configuration file)
if (( _IS_ONLINE > 0 ))
then
_MATCH_RC=1
else
data_contains_string "${CRS_STATE_LINE}" "${_CRS_NEEDLE}"
_MATCH_RC=$?
fi
if (( _MATCH_RC >> 0 ))
then
_MSG="resource ${_CRS_RESOURCE} has a correct state [${_CRS_STATE}@${_CRS_HOST}]"
_STC=0
_IS_ONLINE=1
else
_MSG="resource ${_CRS_RESOURCE} has a wrong state [${_CRS_STATE}@${_CRS_HOST}]"
_STC=1
fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
done
done
# add crsctl output to stdout log
print "==== {${_CRSCTL_BIN} status resource ${_CRS_RESOURCE}} ====" >>${HC_STDOUT_LOG}
print "${_CRSCTL_STATUS}" >>${HC_STDOUT_LOG}
done
return 0
}
# -----------------------------------------------------------------------------
function _show_usage
{
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3 with parameters:
log_healthy=<yes|no>
and formatted stanzas:
crs:<resource_name>:<*|node>=<ONLINE|OFFLINE>,<*|node>=<ONLINE|OFFLINE>,...
PURPOSE : Checks the STATE of CRS resource(s)
LOG HEALTHY : Supported
EOT
return 0
}
#******************************************************************************
# END of script
#******************************************************************************
@@ -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
#******************************************************************************
@@ -340,7 +340,7 @@ then
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && debug "excluding table: ${_MYSQL_TABLE}"
fi
done
# add mysqlcheck output to stdout log_hc
# add mysqlcheck output to stdout log
print "==== {${_MYSQLCHECK_BIN} <hidden_opts> --database ${_MYSQL_DB}} ====" >>${HC_STDOUT_LOG}
print "${_MYSQLCHECK_OUTPUT}" >>${HC_STDOUT_LOG}
done
@@ -12,40 +12,35 @@
# 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
#*****************************************hpux*************************************
#******************************************************************************
#
# DOCUMENTATION (MAIN)
# -----------------------------------------------------------------------------
# @(#) MAIN: check_linux_sg_cluster_status
# @(#) MAIN: check_serviceguard_cluster_status
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
#
# @(#) HISTORY:
# @(#) 2017-04-01: initial version [Patrick Van der Veken]
# @(#) 2018-05-21: added dump_logs() & other fixes [Patrick Van der Veken]
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
# @(#) 2019-04-20: merged HP-UX+Linux version [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_linux_sg_cluster_config
function check_serviceguard_cluster_status
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX,Linux" # uname -s match
# 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}
PATH=$PATH:/opt/cmcluster/bin
PATH=$PATH:/opt/cmcluster/bin # Linux
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
@@ -61,10 +56,6 @@ 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
@@ -75,6 +66,10 @@ do
esac
done
# 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 configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]]
@@ -96,6 +91,14 @@ then
fi
# check serviceguard status & gather cluster information from running cluster (compressed lines)
case "${OS_NAME}" in
HP-UX)
typeset _SG_DAEMON="/usr/lbin/cmcld"
;;
Linux)
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
;;
esac
if [[ ! -x ${_SG_DAEMON} ]]
then
warn "${_SG_DAEMON} is not installed here"
@@ -103,15 +106,17 @@ then
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}"
# dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 0
}
# dump configuration information in compressed format
cmgetconf -c ${_CLUSTER_INSTANCE} 2>>${HC_STDERR_LOG} |\
grep -v -E -e "${_SG_CMGETCONF_FILTER}" |\
tr -d ' \t' >${_CLUSTER_RUN_FILE}.${_CLUSTER_INSTANCE} 2>/dev/null
[[ -s ${_CLUSTER_RUN_FILE}.${_CLUSTER_INSTANCE} ]] || {
_MSG="unable to gather configuration for cluster instance ${_CLUSTER_INSTANCE}"
log_hc "$0" 1 "${_MSG}"
# dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 1
}
done
fi
@@ -119,7 +124,8 @@ fi
for _CLUSTER_INSTANCE in ${_CLUSTER_INSTANCES}
do
awk -v cluster="${_CLUSTER_INSTANCE}" '
BEGIN { found = 0; needle = "^\["cluster"\]" }
# ^ anchor not supported in all AWKs
BEGIN { found = 0; needle = "\["cluster"\]$" }
# skip blank lines
/^\s*$/ { next; }
@@ -1,6 +1,6 @@
#!/usr/bin/env ksh
#******************************************************************************
# @(#) check_linux_sg_cluster_status
# @(#) check_serviceguard_cluster_status
#******************************************************************************
# @(#) Copyright (C) 2016 by KUDOS BVBA (info@kudos.be). All rights reserved.
#
@@ -16,37 +16,29 @@
#
# DOCUMENTATION (MAIN)
# -----------------------------------------------------------------------------
# @(#) MAIN: check_linux_sg_cluster_status
# @(#) MAIN: check_serviceguard_cluster_status
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
#
# @(#) HISTORY:
# @(#) 2017-04-01: initial version [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-05-21: STDERR 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: changed format of stanzas in configuration file &
# @(#) added support for --log-healthy [Patrick Van der Veken]
# @(#) 2017-04-20: merged HP-UX+Linux version [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_linux_sg_cluster_status
function check_serviceguard_cluster_status
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX,Linux" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
PATH=$PATH:/opt/cmcluster/bin
PATH=$PATH:/opt/cmcluster/bin # Linux
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
@@ -112,6 +104,14 @@ else
fi
# check & get serviceguard status
case "${OS_NAME}" in
HP-UX)
typeset _SG_DAEMON="/usr/lbin/cmcld"
;;
Linux)
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
;;
esac
if [[ ! -x ${_SG_DAEMON} ]]
then
warn "${_SG_DAEMON} is not installed here"
@@ -130,11 +130,11 @@ fi
# do cluster status checks
# (replace ':' by '|' for cmcviewcl output)
grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
while read -r _ _SG_ENTRY
while IFS=":" read -r _ _SG_ENTRY
do
# field split
_SG_CFG_PARAM="$(print ${_SG_ENTRY} | cut -f1 -d'=' 2>/dev/null)" # field 1
_SG_CFG_VALUE="$(print ${_SG_ENTRY} | cut -f2 -d'=' 2>/dev/null)" # field 2
_SG_CFG_PARAM=$(print "${_SG_ENTRY}" | cut -f1 -d'=' 2>/dev/null) # field 1
_SG_CFG_VALUE=$(print "${_SG_ENTRY}" | cut -f2 -d'=' 2>/dev/null) # field 2
# check run-time values (anchored grep here!)
_SG_MATCH=$(grep -i "^${_SG_CFG_PARAM}" ${HC_STDOUT_LOG} 2>/dev/null)
@@ -1,6 +1,6 @@
#!/usr/bin/env ksh
#******************************************************************************
# @(#) check_linux_sg_package_config
# @(#) check_serviceguard_package_config
#******************************************************************************
# @(#) Copyright (C) 2016 by KUDOS BVBA (info@kudos.be). All rights reserved.
#
@@ -16,36 +16,31 @@
#
# DOCUMENTATION (MAIN)
# -----------------------------------------------------------------------------
# @(#) MAIN: check_linux_sg_package_config
# @(#) MAIN: check_serviceguard_package_config
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
#
# @(#) HISTORY:
# @(#) 2017-04-01: initial version [Patrick Van der Veken]
# @(#) 2018-05-21: added dump_logs() & other fixes [Patrick Van der Veken]
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
# @(#) 2019-04-20: merged HP-UX+Linux version [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_linux_sg_package_config
function check_serviceguard_package_config
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX,Linux" # uname -s match
# 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}
PATH=$PATH:/opt/cmcluster/bin
PATH=$PATH:/opt/cmcluster/bin # Linux
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
@@ -61,10 +56,6 @@ typeset _PKG_MATCH=""
typeset _PKG_PARAM=""
typeset _PKG_VALUE=""
# 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 arguments (originally comma-separated)
for _ARG in ${_ARGS}
do
@@ -75,7 +66,11 @@ do
esac
done
# handle config file
# 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
@@ -96,6 +91,14 @@ then
fi
# check serviceguard status & gather package information from running cluster (compressed lines)
case "${OS_NAME}" in
HP-UX)
typeset _SG_DAEMON="/usr/lbin/cmcld"
;;
Linux)
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
;;
esac
if [[ ! -x ${_SG_DAEMON} ]]
then
warn "${_SG_DAEMON} is not installed here"
@@ -103,15 +106,17 @@ then
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}"
# dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 0
}
# dump configuration information in compressed format
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} 2>/dev/null
[[ -s ${_PKG_RUN_FILE}.${_PKG_INSTANCE} ]] || {
_MSG="unable to gather configuration for cluster package ${_PKG_INSTANCE}"
log_hc "$0" 1 "${_MSG}"
# dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 1
}
done
fi
@@ -119,7 +124,8 @@ fi
for _PKG_INSTANCE in ${_PKG_INSTANCES}
do
awk -v package="${_PKG_INSTANCE}" '
BEGIN { found = 0; needle = "^\["package"\]" }
# ^ anchor not supported in all AWKs
BEGIN { found = 0; needle = "\["package"\]$" }
# skip blank lines
/^\s*$/ { next; }
@@ -1,6 +1,6 @@
#!/usr/bin/env ksh
#******************************************************************************
# @(#) check_linux_sg_package_status
# @(#) check_serviceguard_package_status
#******************************************************************************
# @(#) Copyright (C) 2016 by KUDOS BVBA (info@kudos.be). All rights reserved.
#
@@ -16,37 +16,29 @@
#
# DOCUMENTATION (MAIN)
# -----------------------------------------------------------------------------
# @(#) MAIN: check_linux_sg_package_status
# @(#) MAIN: check_serviceguard_package_status
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
#
# @(#) HISTORY:
# @(#) 2017-04-01: initial version [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-05-21: STDERR 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: changed format of stanzas in configuration file &
# @(#) added support for --log-healthy [Patrick Van der Veken]
# @(#) 2019-04-20: merged HP-UX+Linux version [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_linux_sg_package_status
function check_serviceguard_package_status
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX,Linux" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
PATH=$PATH:/opt/cmcluster/bin
PATH=$PATH:/opt/cmcluster/bin # Linux
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
@@ -113,6 +105,14 @@ else
fi
# check & get serviceguard status
case "${OS_NAME}" in
HP-UX)
typeset _SG_DAEMON="/usr/lbin/cmcld"
;;
Linux)
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
;;
esac
if [[ ! -x ${_SG_DAEMON} ]]
then
warn "${_SG_DAEMON} is not installed here"
@@ -131,12 +131,12 @@ fi
# do package status checks
# (replace ':' by '|' for cmcviewcl output)
grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
while read -r _ _SG_ENTRY
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':' 2>/dev/null | cut -f1 -d'=' 2>/dev/null)" # field 2-,1
_SG_CFG_VALUE="$(print ${_SG_ENTRY} | cut -f2- -d':' 2>/dev/null | cut -f2 -d'=' 2>/dev/null)" # field 2-,2
_SG_PACKAGE=$(print "${_SG_ENTRY}" | cut -f1 -d':')
_SG_CFG_PARAM=$(print "${_SG_ENTRY}" | cut -f2- -d':' 2>/dev/null | cut -f1 -d'=' 2>/dev/null) # field 2-,1
_SG_CFG_VALUE=$(print "${_SG_ENTRY}" | cut -f2- -d':' 2>/dev/null | cut -f2 -d'=' 2>/dev/null) # 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)
@@ -1,6 +1,6 @@
#!/usr/bin/env ksh
#******************************************************************************
# @(#) check_linux_sg_qs_status.sh
# @(#) check_serviceguard_qs_status.sh
#******************************************************************************
# @(#) Copyright (C) 2017 by KUDOS BVBA (info@kudos.be). All rights reserved.
#
@@ -16,28 +16,23 @@
#
# DOCUMENTATION (MAIN)
# -----------------------------------------------------------------------------
# @(#) MAIN: check_linux_sg_qs_status
# @(#) MAIN: check_serviceguard_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-05-21: STDERR fixes [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]
# @(#) 2019-04-20: merged HP-UX+Linux version [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_linux_sg_qs_status
function check_serviceguard_qs_status
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _VERSION="2019-04-20" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _QS_BIN="/opt/qs/bin/qsc"
typeset _QS_AUTH_FILE="/opt/qs/conf/qs_authfile"
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
@@ -73,6 +68,18 @@ else
log "not logging/showing passed health checks"
fi
# set OS specific parameters
case "${OS_NAME}" in
HP-UX)
typeset _QS_BIN="/usr/lbin/qsc"
typeset _QS_AUTH_FILE="/etc/cmcluster/qs_authfile"
;;
Linux)
typeset _QS_BIN="/opt/qs/bin/qsc"
typeset _QS_AUTH_FILE="/opt/qs/conf/qs_authfile"
;;
esac
# check QS presence
if [[ ! -x ${_QS_BIN} ]]
then