* Fixes on trap settings

* Updated check_hpux_drd_status() plugin (boot check fix)
* Added check_hpux_lunpaths() plugin
* Updated check_hpux_patch_version() plugin with fileset state check
This commit is contained in:
Patrick Van der Veken 2018-10-22 09:48:20 +02:00
parent 3a67452848
commit af81b7eb67
21 changed files with 263 additions and 427 deletions

View File

@ -61,7 +61,7 @@ This is the OS/platform plugin package"
directory ../../sources/lib/platform/hp-ux=/opt/hc/lib/platform/hp-ux directory ../../sources/lib/platform/hp-ux=/opt/hc/lib/platform/hp-ux
file -m 755 check_hpux_autopath.sh file -m 755 check_hpux_autopath.sh
file -m 755 check_hpux_cdsf_cluster.sh file -m 755 check_hpux_cdsf_cluster.sh
file -m 755 check_hpux_drd_status.sh file -m 755 check_hpux_drd_status.sh
file -m 755 check_hpux_file_age.sh file -m 755 check_hpux_file_age.sh
file -m 755 check_hpux_file_change.sh file -m 755 check_hpux_file_change.sh
file -m 755 check_hpux_fs_mounts.sh file -m 755 check_hpux_fs_mounts.sh
@ -72,7 +72,8 @@ This is the OS/platform plugin package"
file -m 644 check_hpux_hpvm_vpar_status.sh file -m 644 check_hpux_hpvm_vpar_status.sh
file -m 755 check_hpux_httpd_status.sh file -m 755 check_hpux_httpd_status.sh
file -m 755 check_hpux_kernel_params.sh file -m 755 check_hpux_kernel_params.sh
file -m 755 check_hpux_kernel_usage.sh file -m 755 check_hpux_kernel_usage.sh
file -m 755 check_hpux_lunpaths.sh
file -m 755 check_hpux_named_status.sh file -m 755 check_hpux_named_status.sh
file -m 755 check_hpux_ntp_status.sh file -m 755 check_hpux_ntp_status.sh
file -m 755 check_hpux_patch_version.sh file -m 755 check_hpux_patch_version.sh

View File

@ -6,6 +6,11 @@
# [default: indicates hardcoded script values if no value is defined here] # [default: indicates hardcoded script values if no value is defined here]
#****************************************************************************** #******************************************************************************
# specify whether to also log passed health checks
# (warning: this may rapidly grow the HC log)
# [default: no]
log_healthy=yes
# OE version that should be checked (version string as displayed by 'swlist') # OE version that should be checked (version string as displayed by 'swlist')
# [default: none] # [default: none]
required_oe="" required_oe=""
@ -14,7 +19,11 @@ required_oe=""
# [default: none] # [default: none]
required_patches="" required_patches=""
# check that all installed filesets are configured?
# [default: yes]
check_filesets=yes
#****************************************************************************** #******************************************************************************
# End of FILE # End of FILE
#****************************************************************************** #******************************************************************************

View File

@ -65,6 +65,11 @@ typeset _TMP_EXCL_FILE="${TMP_DIR}/.$0.tmp_excl.$$"
set -o noglob # no file globbing set -o noglob # no file globbing
# set local trap for clean-up # set local trap for clean-up
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1;
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1;
return 0" 0
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1;
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1;

View File

@ -97,7 +97,7 @@ then
log_hc "$0" 1 "cDSF conflict found for ${_CDSF_DEV}" log_hc "$0" 1 "cDSF conflict found for ${_CDSF_DEV}"
done done
else else
if (( _LOG_HEALTHY > 0)) if (( _LOG_HEALTHY > 0 ))
then then
log_hc "$0" 0 "no cDSF conflicts found" log_hc "$0" 0 "no cDSF conflicts found"
fi fi

View File

@ -26,6 +26,7 @@
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2018-05-11: initial version [Patrick Van der Veken] # @(#) 2018-05-11: initial version [Patrick Van der Veken]
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
# @(#) 2018-10-18: changed boot status [Patrick Van der Veken]
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -36,7 +37,7 @@ function check_hpux_drd_status
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _DRD_BIN="/opt/drd/bin/drd" typeset _DRD_BIN="/opt/drd/bin/drd"
typeset _VERSION="2018-05-18" # YYYY-MM-DD typeset _VERSION="2018-10-18" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -135,16 +136,16 @@ then
_BOOTED_DISK=$(grep "Booted Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')') _BOOTED_DISK=$(grep "Booted Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')')
_ACTIVE_DISK=$(grep "Activated Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')') _ACTIVE_DISK=$(grep "Activated Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')')
# check clone status: after a fresh clone -> booted == activated == original # check boot status: after a fresh clone -> booted == activated == original
if [[ "${_ORIGINAL_DISK}" = "${_BOOTED_DISK}" ]] && if [[ "${_ORIGINAL_DISK}" = "${_BOOTED_DISK}" ]] &&
[[ "${_ORIGINAL_DISK}" = "${_ACTIVE_DISK}" ]] && [[ "${_ORIGINAL_DISK}" = "${_ACTIVE_DISK}" ]] &&
[[ "${_BOOTED_DISK}" = "${_ACTIVE_DISK}" ]] [[ "${_BOOTED_DISK}" = "${_ACTIVE_DISK}" ]]
then then
_MSG="clone disk ${_CLONE_DISK} was correctly created" _MSG="host was booted from original disk (${_ACTIVE_DISK})"
log_hc "$0" 0 "${_MSG}" log_hc "$0" 0 "${_MSG}"
else else
_MSG="clone disk ${_CLONE_DISK} was probably not correctly created" _MSG="host was booted from clone disk (${_ACTIVE_DISK})"
log_hc "$0" 1 "${_MSG}" log_hc "$0" 0 "${_MSG}"
fi fi
# check EFI status # check EFI status

View File

@ -1,277 +0,0 @@
#!/usr/bin/env ksh
#******************************************************************************
# @(#) check_hpux_drd_status.sh
#******************************************************************************
# @(#) Copyright (C) 2018 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_drd_status
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_space2comma(), data_get_lvalue_from_config(), data_date2epoch(),
# data_lc(), data_strip_space(), data_strip_outer_space(),
# dump_logs(), init_hc(), log_hc(), warn()
#
# @(#) HISTORY:
# @(#) 2018-05-11: initial version [Patrick Van der Veken]
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
# @(#) 2018-10-18: changed boot status [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
# -----------------------------------------------------------------------------
function check_hpux_drd_status
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _DRD_BIN="/opt/drd/bin/drd"
typeset _VERSION="2018-10-18" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX" # 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_space2comma "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _RC=0
typeset _CHECK_CLONE=""
typeset _CHECK_SYNC=""
typeset _CLONE_MAX_AGE=30
typeset _SYNC_MAX_AGE=30
typeset _CLONE_DISK=""
typeset _ORIGINAL_DISK=""
typeset _ACTIVE_DISK=""
typeset _BOOTED_DISK=""
typeset _NOW_EPOCH=""
typeset _EFI_CLONE=""
typeset _EFI_ORIGINAL=""
typeset _CLONE_DATE=""
typeset _CLONE_YEAR=""
typeset _CLONE_MONTH=""
typeset _CLONE_DAY=""
typeset _CLONE_HOUR=""
typeset _CLONE_MINUTE=""
typeset _CLONE_SECOND=""
typeset _CLONE_EPOCH=""
typeset _SYNC_DATE=""
typeset _SYNC_YEAR=""
typeset _SYNC_MONTH=""
typeset _SYNC_DAY=""
typeset _SYNC_HOUR=""
typeset _SYNC_MINUTE=""
typeset _SYNC_SECOND=""
typeset _SYNC_EPOCH=""
# 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
# read required configuration values
_CHECK_CLONE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_clone')
if [[ -z "${_CHECK_CLONE}" ]]
then
# default
_CHECK_CLONE="yes"
fi
_CLONE_MAX_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'clone_age')
_CHECK_SYNC=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_sync')
if [[ -z "${_CHECK_SYNC}" ]]
then
# default
_CHECK_SYNC="yes"
fi
_SYNC_MAX_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'sync_age')
# get drd status
if [[ ! -x ${_DRD_BIN} ]]
then
warn "${_DRD_BIN} is not installed here"
return 1
else
log "executing {${_DRD_BIN}} ..."
# drd outputs on STDERR
${_DRD_BIN} status >${HC_STDOUT_LOG} 2>&1
_RC=$?
fi
# check drd status
if (( _RC == 0 )) && (( $(grep -c -E -e ".*Information succeeded.*" ${HC_STDOUT_LOG} 2>/dev/null) > 0 ))
then
# convert NOW to epoch (pass date values as unquoted parameters)
#_NOW_EPOCH=$(data_date2epoch "$(date '+%Y')" "$(date '+%m')" "$(date '+%d')" "$(date '+%H')" "$(date '+%M')" "$(date '+%S')")
_NOW_EPOCH=$(data_date2epoch $(date '+%Y %m %d %H %M %S'))
# get devices
_ORIGINAL_DISK=$(data_strip_space "$(grep "Original Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
_CLONE_DISK=$(data_strip_space "$(grep 'Clone Disk:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
_BOOTED_DISK=$(grep "Booted Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')')
_ACTIVE_DISK=$(grep "Activated Disk:" ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d'(' | cut -f1 -d ')')
# check boot status: after a fresh clone -> booted == activated == original
if [[ "${_ORIGINAL_DISK}" = "${_BOOTED_DISK}" ]] &&
[[ "${_ORIGINAL_DISK}" = "${_ACTIVE_DISK}" ]] &&
[[ "${_BOOTED_DISK}" = "${_ACTIVE_DISK}" ]]
then
_MSG="host was booted from original disk (${_ACTIVE_DISK})"
log_hc "$0" 0 "${_MSG}"
else
_MSG="host was booted from clone disk (${_ACTIVE_DISK})"
log_hc "$0" 0 "${_MSG}"
fi
# check EFI status
_EFI_CLONE=$(data_strip_outer_space "$(grep 'Clone EFI Partition:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
if [[ "${_EFI_CLONE}" = "AUTO file present, Boot loader present" ]]
then
_MSG="clone disk ${_CLONE_DISK} has a bootable EFI partition"
log_hc "$0" 0 "${_MSG}"
else
_MSG="clone disk ${_CLONE_DISK} does not have a bootable EFI partition"
log_hc "$0" 1 "${_MSG}"
fi
_EFI_ORIGINAL=$(data_strip_outer_space "$(grep 'Original EFI Partition:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2 -d':')")
if [[ "${_EFI_ORIGINAL}" = "AUTO file present, Boot loader present" ]]
then
_MSG="original disk ${_ORIGINAL_DISK} has a bootable EFI partition"
log_hc "$0" 0 "${_MSG}"
else
_MSG="original disk ${_ORIGINAL_DISK} does not have a bootable EFI partition"
log_hc "$0" 1 "${_MSG}"
fi
# check clone age
if [[ $(data_lc "${_CHECK_CLONE}") = "yes" ]]
then
# e.g.: 05/10/18 16:52:21 METDST (always in US format)
_CLONE_DATE=$(data_strip_outer_space "$(grep 'Clone Creation Date:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2- -d':')")
if [[ "${_CLONE_DATE}" != "None" ]]
then
# split into year/month/day/hour/minute/second
_CLONE_YEAR=$(print "${_CLONE_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f3 -d'/')
_CLONE_MONTH=$(print "${_CLONE_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f1 -d'/')
_CLONE_DAY=$(print "${_CLONE_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f2 -d'/')
_CLONE_HOUR=$(print "${_CLONE_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f1 -d':')
_CLONE_MINUTE=$(print "${_CLONE_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f2 -d':')
_CLONE_SECOND=$(print "${_CLONE_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f3 -d':')
# convert _CLONE_DATE to epoch
_CLONE_EPOCH=$(data_date2epoch "20${_CLONE_YEAR}" "${_CLONE_MONTH}" "${_CLONE_DAY}" "${_CLONE_HOUR}" "${_CLONE_MINUTE}" "${_CLONE_SECOND}")
# check age
if (( _CLONE_EPOCH > (_NOW_EPOCH - (_CLONE_MAX_AGE * 24 * 60 * 60)) ))
then
_MSG="clone age is younger than ${_CLONE_MAX_AGE} days [${_CLONE_DATE}]"
log_hc "$0" 0 "${_MSG}"
else
_MSG="clone age is older than ${_CLONE_MAX_AGE} days [${_CLONE_DATE}]"
log_hc "$0" 1 "${_MSG}"
fi
else
_MSG="clone has not yet been created"
log_hc "$0" 1 "${_MSG}"
fi
else
log "not checking age of clone (see ${_CONFIG_FILE})"
fi
# check sync age
if [[ $(data_lc "${_CHECK_SYNC}") = "yes" ]]
then
# e.g.: 05/10/18 16:52:21 METDST (always in US format)
_SYNC_DATE=$(data_strip_outer_space "$(grep 'Last Sync Date:' ${HC_STDOUT_LOG} 2>/dev/null | cut -f2- -d':')")
if [[ "${_SYNC_DATE}" != "None" ]]
then
# split into year/month/day/hour/minute/second
_SYNC_YEAR=$(print "${_SYNC_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f3 -d'/')
_SYNC_MONTH=$(print "${_SYNC_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f1 -d'/')
_SYNC_DAY=$(print "${_SYNC_DATE}" | awk '{ print $1 }' 2>/dev/null | cut -f2 -d'/')
_SYNC_HOUR=$(print "${_SYNC_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f1 -d':')
_SYNC_MINUTE=$(print "${_SYNC_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f2 -d':')
_SYNC_SECOND=$(print "${_SYNC_DATE}" | awk '{ print $2 }' 2>/dev/null | cut -f3 -d':')
# convert _SYNC_DATE to epoch
_SYNC_EPOCH=$(data_date2epoch "20${_SYNC_YEAR}" "${_SYNC_MONTH}" "${_SYNC_DAY}" "${_SYNC_HOUR}" "${_SYNC_MINUTE}" "${_SYNC_SECOND}")
# check age
if (( _SYNC_EPOCH > (_NOW_EPOCH - (_SYNC_MAX_AGE * 24 * 60 * 60)) ))
then
_MSG="sync age is younger than ${_SYNC_MAX_AGE} days [${_SYNC_DATE}]"
log_hc "$0" 0 "${_MSG}"
else
_MSG="sync age is older than ${_SYNC_MAX_AGE} days [${_SYNC_DATE}]"
log_hc "$0" 1 "${_MSG}"
fi
else
_MSG="sync has not yet been executed"
log_hc "$0" 1 "${_MSG}"
fi
else
log "not checking age of sync (see ${_CONFIG_FILE})"
fi
else
_MSG="unable to run command: {${_DRD_BIN}}"
log_hc "$0" 1 "${_MSG}"
# dump debug info
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 1
fi
return 0
}
# -----------------------------------------------------------------------------
function _show_usage
{
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3 with:
check_clone=<yes|no>
clone_age=<max_age_of_clone_in_days>
check_sync=<yes|no>
sync_age=<max_age_of_sync_in_days>
PURPOSE : Checks whether the DRD clone was correctly created
Checks for correct EFI partitions
Checks the age of the DRD clone and/or sync
EOT
return 0
}
#******************************************************************************
# END of script
#******************************************************************************

View File

@ -55,6 +55,7 @@ typeset _FILE_NAME=""
typeset _FILE_DIR="" typeset _FILE_DIR=""
# set local trap for cleanup # set local trap for cleanup
trap "[[ -f ${_REF_FILE} ]] && rm -f ${_REF_FILE} >/dev/null 2>&1; return 0" 0
trap "[[ -f ${_REF_FILE} ]] && rm -f ${_REF_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 trap "[[ -f ${_REF_FILE} ]] && rm -f ${_REF_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -63,46 +64,46 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi fi
# perform check # perform check
cat ${_CONFIG_FILE} | grep -v -E -e '^$' -e '^#' | while read _ENTRY cat ${_CONFIG_FILE} | grep -v -E -e '^$' -e '^#' | while read _ENTRY
do do
# field split # field split
_FILE_PATH=$(print "${_ENTRY%%;*}") _FILE_PATH=$(print "${_ENTRY%%;*}")
_FILE_AGE=$(print "${_ENTRY##*;}") _FILE_AGE=$(print "${_ENTRY##*;}")
# split file/dir # split file/dir
_FILE_NAME=$(print "${_FILE_PATH##*/}") _FILE_NAME=$(print "${_FILE_PATH##*/}")
_FILE_DIR=$(print "${_FILE_PATH%/*}") _FILE_DIR=$(print "${_FILE_PATH%/*}")
# check config # check config
if [ \( -z "${_FILE_PATH}" \) -a \( -z "${_FILE_AGE}" \) ] if [ \( -z "${_FILE_PATH}" \) -a \( -z "${_FILE_AGE}" \) ]
then then
warn "missing values in configuration file at ${_CONFIG_FILE}" warn "missing values in configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi fi
case "${_FILE_AGE}" in case "${_FILE_AGE}" in
+([0-9])*(.)*([0-9])) +([0-9])*(.)*([0-9]))
# numeric, OK # numeric, OK
;; ;;
*) *)
# not numeric # not numeric
warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}" warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}"
return 1 return 1
;; ;;
esac esac
# calculate reference timestamp & set reference file (once only) # calculate reference timestamp & set reference file (once only)
if (( _DO_REF == 0 )) if (( _DO_REF == 0 ))
then then
@ -110,29 +111,29 @@ do
if (( $? != 0 )) if (( $? != 0 ))
then then
warn "failed to query reference time (Perl)" warn "failed to query reference time (Perl)"
return 1 return 1
fi fi
touch -amt "${REF_TIME}" ${_REF_FILE} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} touch -amt "${REF_TIME}" ${_REF_FILE} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
if (( $? != 0 )) if (( $? != 0 ))
then then
warn "failed to create reference time ${TMP_DIR}" warn "failed to create reference time ${TMP_DIR}"
return 1 return 1
fi fi
_DO_REF=1 _DO_REF=1
fi fi
sleep 60 sleep 60
# perform check # perform check
if [[ ! -r "${_FILE_PATH}" ]] if [[ ! -r "${_FILE_PATH}" ]]
then then
_MSG="unable to read or access requested file at ${_FILE_PATH}" _MSG="unable to read or access requested file at ${_FILE_PATH}"
_STC=1 _STC=1
else else
# age check # age check
AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -newer ${_REF_FILE}) AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -newer ${_REF_FILE})
if (( $? != 0 )) if (( $? != 0 ))
then then
warn "unable to execute file age test for ${_FILE_PATH}" warn "unable to execute file age test for ${_FILE_PATH}"
return 1 return 1
fi fi
if [[ -z "${AGE_CHECK}" ]] if [[ -z "${AGE_CHECK}" ]]
then then
@ -142,7 +143,7 @@ sleep 60
_MSG="file age of ${_FILE_AGE} has not expired on ${_FILE_PATH}" _MSG="file age of ${_FILE_AGE} has not expired on ${_FILE_PATH}"
fi fi
fi fi
# handle unit result # handle unit result
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
_STC=0 _STC=0

View File

@ -65,6 +65,11 @@ typeset _TMP_EXCL_FILE="${TMP_DIR}/.$0.tmp_excl.$$"
set -o noglob # no file globbing set -o noglob # no file globbing
# set local trap for clean-up # set local trap for clean-up
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1;
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1;
return 0" 0
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1;
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1;

View File

@ -26,6 +26,7 @@
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken] # @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
# @(#) 2018-07-10: added log_healthy hc_arg [Patrick Van der Veken] # @(#) 2018-07-10: added log_healthy hc_arg [Patrick Van der Veken]
# @(#) 2018-08-30: added config file + check list for daemons [Patrick Van der Veken] # @(#) 2018-08-30: added config file + check list for daemons [Patrick Van der Veken]
# @(#) 2018-10-22: small fixes [Patrick Van der Veken]
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -35,7 +36,7 @@ function check_hpux_ovpa_status
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf" typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2018-08-30" # YYYY-MM-DD typeset _VERSION="2018-10-22" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
typeset _OVPA_BIN="/opt/perf/bin/perfstat" typeset _OVPA_BIN="/opt/perf/bin/perfstat"
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -47,6 +48,7 @@ typeset _ARGS=$(data_space2comma "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0 typeset _LOG_HEALTHY=0
typeset _OVPA_MATCH=0 typeset _OVPA_MATCH=0
typeset _OVPA_VERSION="" typeset _OVPA_VERSION=""
@ -90,14 +92,13 @@ else
# convert commas and strip quotes # convert commas and strip quotes
_OVPA_DAEMONS=$(data_comma2space $(data_dequote "${_OVPA_DAEMONS}")) _OVPA_DAEMONS=$(data_comma2space $(data_dequote "${_OVPA_DAEMONS}"))
fi fi
log "checking daemons: ${_OVPA_DAEMONS} ..."
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy') _CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
case "${_CFG_HEALTHY}" in case "${_CFG_HEALTHY}" in
yes|YES|Yes) yes|YES|Yes)
_LOG_HEALTHY=1 _LOG_HEALTHY=1
;; ;;
*) *)
# do not override hc_arg # do not override hc_arg
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
;; ;;
esac esac
@ -127,6 +128,7 @@ else
fi fi
# do OVPA status checks # do OVPA status checks
log "checking daemons: ${_OVPA_DAEMONS} ..."
for _OVPA_DAEMON in ${_OVPA_DAEMONS} for _OVPA_DAEMON in ${_OVPA_DAEMONS}
do do
# anchored grep here! # anchored grep here!

View File

@ -25,7 +25,7 @@
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2018-05-11: initial version [Patrick Van der Veken] # @(#) 2018-05-11: initial version [Patrick Van der Veken]
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken] # @(#) 2018-10-22: added check on fileset state [Patrick Van der Veken]
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -39,7 +39,7 @@ typeset _SWLIST_BIN="/usr/sbin/swlist"
typeset _SWLIST_OPTS="" typeset _SWLIST_OPTS=""
typeset _SHOW_PATCHES_BIN="/usr/contrib/bin/show_patches" typeset _SHOW_PATCHES_BIN="/usr/contrib/bin/show_patches"
typeset _SHOW_PATCHES_OPTS="" typeset _SHOW_PATCHES_OPTS=""
typeset _VERSION="2018-05-20" # YYYY-MM-DD typeset _VERSION="2018-10-22" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -50,8 +50,13 @@ typeset _ARGS=$(data_space2comma "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _OE_VERSION="" typeset _OE_VERSION=""
typeset _PATCH_LINE="" typeset _PATCH_LINE=""
typeset _CHECK_FILESETS=""
typeset _FILESET=""
typeset _FILESET_LINE=""
typeset _PATCHES="" typeset _PATCHES=""
typeset _PATCH="" typeset _PATCH=""
@ -65,6 +70,20 @@ do
esac esac
done 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
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
@ -80,6 +99,33 @@ then
# convert commas and strip quotes # convert commas and strip quotes
_PATCHES=$(data_comma2space $(data_dequote "${_PATCH_LINE}")) _PATCHES=$(data_comma2space $(data_dequote "${_PATCH_LINE}"))
fi fi
if [[ -z "${_CHECK_FILESETS}" ]]
then
# default
_CHECK_FILESETS="yes"
fi
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
case "${_CFG_HEALTHY}" in
yes|YES|Yes)
_LOG_HEALTHY=1
;;
*)
# do not override hc_arg
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
;;
esac
# check required tools
if [[ ! -x ${_SWLIST_BIN} ]]
then
warn "${_SWLIST_BIN} is not installed here"
return 1
fi
if [[ ! -x ${_SHOW_PATCHES_BIN} ]]
then
warn "${_SHOW_PATCHES_BIN} is not installed here"
return 1
fi
# get and check OE version # get and check OE version
if [[ -n "${_OE_VERSION}" ]] if [[ -n "${_OE_VERSION}" ]]
@ -162,6 +208,32 @@ else
warn "required patches will not be checked (not configured in ${_CONFIG_FILE})" warn "required patches will not be checked (not configured in ${_CONFIG_FILE})"
fi fi
# get and check (all) filesets
if [[ "${_CHECK_FILESETS}" = "yes" ]]
then
_SWLIST_OPTS="-a state -l fileset"
log "executing {${_SWLIST_BIN}} with options: ${_SWLIST_OPTS}"
print "=== swlist ({$_SWLIST_OPTS}) ===" >>${HC_STDOUT_LOG}
${_SWLIST_BIN} ${_SWLIST_OPTS} >>${HC_STDOUT_LOG} 2>${HC_STDERR_LOG}
if (( $? == 0 ))
then
grep -E -e "installed[[:space:]]*$" ${HC_STDOUT_LOG} 2>/dev/null |\
while read _FILESET_LINE
do
_FILESET=$(print "${_FILESET_LINE}" | awk '{print $1}' 2>/dev/null)
_MSG="fileset ${_FILESET} is not in a configured state"
log_hc "$0" 1 "${_MSG}"
done
else
_MSG="unable to run command: {${_SWLIST_BIN}}"
log_hc "$0" 1 "${_MSG}"
# dump debug info
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 1
fi
fi
return 0 return 0
} }

View File

@ -37,7 +37,7 @@ typeset _VERSION="2016-12-01" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
typeset _SG_DAEMON="/usr/lbin/cmcld" typeset _SG_DAEMON="/usr/lbin/cmcld"
# rubbish that cmgetconf outputs to STDOUT instead of STDERR # rubbish that cmgetconf outputs to STDOUT instead of STDERR
typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured"
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
# set defaults # set defaults
@ -58,6 +58,7 @@ typeset _CLUSTER_PARAM=""
typeset _CLUSTER_VALUE="" typeset _CLUSTER_VALUE=""
# set local trap for cleanup # set local trap for cleanup
trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 0" 0
trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -66,13 +67,13 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -91,7 +92,7 @@ then
fi fi
# check serviceguard status & gather cluster information from running cluster (compressed lines) # check serviceguard status & gather cluster information from running cluster (compressed lines)
if [[ ! -x ${_SG_DAEMON} ]] if [[ ! -x ${_SG_DAEMON} ]]
then then
warn "${_SG_DAEMON} is not installed here" warn "${_SG_DAEMON} is not installed here"
return 1 return 1
@ -115,10 +116,10 @@ do
BEGIN { found = 0; needle = "^\["cluster"\]" } BEGIN { found = 0; needle = "^\["cluster"\]" }
# skip blank lines # skip blank lines
/^\s*$/ { next; } /^\s*$/ { next; }
# skip comment lines # skip comment lines
/^#/ { next; } /^#/ { next; }
# end marker # end marker
( $0 ~ /^\[.*\]/ && found ) { ( $0 ~ /^\[.*\]/ && found ) {
found = 0; found = 0;
@ -157,13 +158,13 @@ do
else else
_MSG="'${_CLUSTER_PARAM} (${_CLUSTER_VALUE} ...)' is configured for ${_CLUSTER_INSTANCE}" _MSG="'${_CLUSTER_PARAM} (${_CLUSTER_VALUE} ...)' is configured for ${_CLUSTER_INSTANCE}"
fi fi
# handle unit result # handle unit result
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
_STC=0 _STC=0
done <${_CLUSTER_CFG_FILE}.${_CLUSTER_INSTANCE} done <${_CLUSTER_CFG_FILE}.${_CLUSTER_INSTANCE}
done done
# remove working files # remove working files
rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1 rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1
@ -180,7 +181,7 @@ CONFIG : $3
PURPOSE : Checks the configuration of Serviceguard cluster (SG 11.16+) (comparing PURPOSE : Checks the configuration of Serviceguard cluster (SG 11.16+) (comparing
serialized strings from the plugin configuration file to the running cluster serialized strings from the plugin configuration file to the running cluster
configuration) configuration)
EOT EOT
return 0 return 0

View File

@ -37,7 +37,7 @@ typeset _VERSION="2016-12-01" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
typeset _SG_DAEMON="/usr/lbin/cmcld" typeset _SG_DAEMON="/usr/lbin/cmcld"
# rubbish that cmgetconf outputs to STDOUT instead of STDERR # rubbish that cmgetconf outputs to STDOUT instead of STDERR
typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured"
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
# set defaults # set defaults
@ -63,16 +63,17 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# set local trap for cleanup # set local trap for cleanup
trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 0" 0
trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -91,7 +92,7 @@ then
fi fi
# check serviceguard status & gather package information from running cluster (compressed lines) # check serviceguard status & gather package information from running cluster (compressed lines)
if [[ ! -x ${_SG_DAEMON} ]] if [[ ! -x ${_SG_DAEMON} ]]
then then
warn "${_SG_DAEMON} is not installed here" warn "${_SG_DAEMON} is not installed here"
return 1 return 1
@ -115,10 +116,10 @@ do
BEGIN { found = 0; needle = "^\["package"\]" } BEGIN { found = 0; needle = "^\["package"\]" }
# skip blank lines # skip blank lines
/^\s*$/ { next; } /^\s*$/ { next; }
# skip comment lines # skip comment lines
/^#/ { next; } /^#/ { next; }
# end marker # end marker
( $0 ~ /^\[.*\]/ && found ) { ( $0 ~ /^\[.*\]/ && found ) {
found = 0; found = 0;
@ -157,13 +158,13 @@ do
else else
_MSG="'${_PKG_PARAM} (${_PKG_VALUE} ...)' is configured for ${_PKG_INSTANCE}" _MSG="'${_PKG_PARAM} (${_PKG_VALUE} ...)' is configured for ${_PKG_INSTANCE}"
fi fi
# handle unit result # handle unit result
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
_STC=0 _STC=0
done <${_PKG_CFG_FILE}.${_PKG_INSTANCE} done <${_PKG_CFG_FILE}.${_PKG_INSTANCE}
done done
# remove working files # remove working files
rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1 rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1

View File

@ -57,16 +57,17 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# set local trap for cleanup # set local trap for cleanup
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -104,7 +105,7 @@ fi
print "## this file is not date sorted! Do not edit manually!" >${_STATE_FILE} print "## this file is not date sorted! Do not edit manually!" >${_STATE_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to create new state file at ${_STATE_FILE}" warn "failed to create new state file at ${_STATE_FILE}"
return 1 return 1
} }
log "created new state file at ${_STATE_FILE}" log "created new state file at ${_STATE_FILE}"
} }
@ -126,20 +127,20 @@ then
sort -u ${HC_STDOUT_LOG} ${_STATE_FILE} >${_TMP_FILE} sort -u ${HC_STDOUT_LOG} ${_STATE_FILE} >${_TMP_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to sort temporary state file" warn "failed to sort temporary state file"
return 1 return 1
} }
if (( ARG_LOG != 0 )) if (( ARG_LOG != 0 ))
then then
mv ${_TMP_FILE} ${_STATE_FILE} >/dev/null 2>&1 mv ${_TMP_FILE} ${_STATE_FILE} >/dev/null 2>&1
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to move temporary state file to permanent state file ${_STATE_FILE}" warn "failed to move temporary state file to permanent state file ${_STATE_FILE}"
return 1 return 1
} }
fi fi
else else
_MSG="no new SYSLOG messages found" _MSG="no new SYSLOG messages found"
fi fi
# handle results # handle results
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"

View File

@ -69,7 +69,12 @@ set -o noglob # no file globbing
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1; trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1;
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1; [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1; [[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1; [[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1;
return 0" 0
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1;
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_INCL_FILE} ]] && rm -f ${_TMP_INCL_FILE} >/dev/null 2>&1;
[[ -f ${_TMP_EXCL_FILE} ]] && rm -f ${_TMP_EXCL_FILE} >/dev/null 2>&1;
return 1" 1 2 3 15 return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -78,13 +83,13 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -132,29 +137,29 @@ fi
>${_STATE_FILE} >${_STATE_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to create new state file at ${_STATE_FILE}" warn "failed to create new state file at ${_STATE_FILE}"
return 1 return 1
} }
log "created new state file at ${_STATE_FILE}" log "created new state file at ${_STATE_FILE}"
} }
>${_TMP_INCL_FILE} >${_TMP_INCL_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to create temporary file at ${_TMP_INCL_FILE}" warn "failed to create temporary file at ${_TMP_INCL_FILE}"
return 1 return 1
} }
>${_TMP_EXCL_FILE} >${_TMP_EXCL_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to create temporary file at ${_TMP_EXCL_FILE}" warn "failed to create temporary file at ${_TMP_EXCL_FILE}"
return 1 return 1
} }
>${_TMP1_FILE} >${_TMP1_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to create temporary file at ${_TMP1_FILE}" warn "failed to create temporary file at ${_TMP1_FILE}"
return 1 return 1
} }
>${_TMP2_FILE} >${_TMP2_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to create temporary file at ${_TMP2_FILE}" warn "failed to create temporary file at ${_TMP2_FILE}"
return 1 return 1
} }
# build list of configured objects: inclusion # build list of configured objects: inclusion
@ -171,7 +176,7 @@ do
;; ;;
esac esac
fi fi
# expand directories # expand directories
if [[ -d ${_INCL_OBJECT} ]] if [[ -d ${_INCL_OBJECT} ]]
then then
@ -195,7 +200,7 @@ do
;; ;;
esac esac
fi fi
# expand directories # expand directories
if [[ -d ${_EXCL_OBJECT} ]] if [[ -d ${_EXCL_OBJECT} ]]
then then
@ -217,7 +222,7 @@ do
_STC=0 _STC=0
_MSG="" _MSG=""
_IS_NEW=0 _IS_NEW=0
# object to check must be a file (and be present) # object to check must be a file (and be present)
if [[ ! -f ${_FILE_TO_CHECK} ]] if [[ ! -f ${_FILE_TO_CHECK} ]]
then then
@ -226,18 +231,18 @@ do
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
continue continue
fi fi
# read entry from state file # read entry from state file
_STATE_FILE_LINE=$(grep -E -e "^${_FILE_TO_CHECK}\|" ${_STATE_FILE} 2>/dev/null) _STATE_FILE_LINE=$(grep -E -e "^${_FILE_TO_CHECK}\|" ${_STATE_FILE} 2>/dev/null)
if [[ -n "${_STATE_FILE_LINE}" ]] if [[ -n "${_STATE_FILE_LINE}" ]]
then then
# field 1 is the file name # field 1 is the file name
_STATE_FILE_TYPE=$(print "${_STATE_FILE_LINE}" | cut -f2 -d'|' 2>/dev/null) _STATE_FILE_TYPE=$(print "${_STATE_FILE_LINE}" | cut -f2 -d'|' 2>/dev/null)
_STATE_FILE_CKSUM=$(print "${_STATE_FILE_LINE}" | cut -f3 -d'|' 2>/dev/null) _STATE_FILE_CKSUM=$(print "${_STATE_FILE_LINE}" | cut -f3 -d'|' 2>/dev/null)
else else
_IS_NEW=1 _IS_NEW=1
fi fi
# compute new checksum (keep the same type as before) # compute new checksum (keep the same type as before)
if (( _IS_NEW == 0 )) if (( _IS_NEW == 0 ))
then then
@ -282,14 +287,14 @@ do
_STC=1 _STC=1
fi fi
fi fi
# check for failed checksums # check for failed checksums
if [[ -z "${_FILE_CKSUM}" ]] if [[ -z "${_FILE_CKSUM}" ]]
then then
_MSG="did not receive checksum (openssl/cksum) for ${_FILE_TO_CHECK}" _MSG="did not receive checksum (openssl/cksum) for ${_FILE_TO_CHECK}"
_STC=1 _STC=1
fi fi
# bounce failures back and jump to next file # bounce failures back and jump to next file
if (( _STC != 0 )) if (( _STC != 0 ))
then then
@ -303,7 +308,7 @@ do
if [[ "${_STATE_FILE_CKSUM}" != "${_FILE_CKSUM}" ]] if [[ "${_STATE_FILE_CKSUM}" != "${_FILE_CKSUM}" ]]
then then
_MSG="${_FILE_TO_CHECK} has a changed checksum [${_FILE_TYPE}]" _MSG="${_FILE_TO_CHECK} has a changed checksum [${_FILE_TYPE}]"
_STC=1 _STC=1
else else
_MSG="${_FILE_TO_CHECK} has the same checksum [${_FILE_TYPE}]" _MSG="${_FILE_TO_CHECK} has the same checksum [${_FILE_TYPE}]"
_STC=0 _STC=0
@ -312,10 +317,10 @@ do
_MSG="${_FILE_TO_CHECK} is a new file [${_FILE_TYPE}]" _MSG="${_FILE_TO_CHECK} is a new file [${_FILE_TYPE}]"
_STC=0 _STC=0
fi fi
# save entry to temp file # save entry to temp file
printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE} printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE}
# report with curr/exp values # report with curr/exp values
log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}" log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}"
done <${_TMP1_FILE} done <${_TMP1_FILE}
@ -329,7 +334,7 @@ then
mv ${_TMP2_FILE} ${_STATE_FILE} >/dev/null 2>&1 mv ${_TMP2_FILE} ${_STATE_FILE} >/dev/null 2>&1
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to move temporary state file" warn "failed to move temporary state file"
return 1 return 1
} }
fi fi
@ -352,18 +357,18 @@ CONFIG : $3 with formatted stanzas:
incl:<full path> incl:<full path>
excl:<full path> excl:<full path>
PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes
of files and directories (automatically expanded). Excludes have a higher of files and directories (automatically expanded). Excludes have a higher
priority than includes. Integrity checks will only be performed on files. priority than includes. Integrity checks will only be performed on files.
Will detect changed, new & deleted files (but not when deleted files Will detect changed, new & deleted files (but not when deleted files
occur in an expanded directory tree). If you wish to detect deleted files: occur in an expanded directory tree). If you wish to detect deleted files:
use only direct file references in the configuration file. Uses by preference use only direct file references in the configuration file. Uses by preference
openssl for hash calculation, with cksum as fall-back). openssl for hash calculation, with cksum as fall-back).
Updated and deleted files will cause a HC failure, new files will not. Updated and deleted files will cause a HC failure, new files will not.
CAVEAT EMPTOR: use only to check a relatively small number of files. CAVEAT EMPTOR: use only to check a relatively small number of files.
Processing a big number of files is likely to take Processing a big number of files is likely to take
ages and probably will cause the plugin to time out ages and probably will cause the plugin to time out
(see HC_TIME_OUT). YMMV. (see HC_TIME_OUT). YMMV.
EOT EOT

View File

@ -57,6 +57,7 @@ typeset _DO_ACU_LOGL=1
typeset _DO_CHECK=0 typeset _DO_CHECK=0
# set local trap for cleanup # set local trap for cleanup
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -65,13 +66,13 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -88,7 +89,7 @@ case "${_DO_ACU_CTRL}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_acu_controller' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_acu_controller' in ${_CONFIG_FILE}, using default"
_DO_ACU_CTRL=1 _DO_ACU_CTRL=1
@ -99,7 +100,7 @@ case "${_DO_ACU_ENCL}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_acu_enclosure' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_acu_enclosure' in ${_CONFIG_FILE}, using default"
_DO_ACU_ENCL=1 _DO_ACU_ENCL=1
@ -110,7 +111,7 @@ case "${_DO_ACU_PHYS}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_acu_physical' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_acu_physical' in ${_CONFIG_FILE}, using default"
_DO_ACU_PHYS=1 _DO_ACU_PHYS=1
@ -121,7 +122,7 @@ case "${_DO_ACU_LOGL}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_acu_logical' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_acu_logical' in ${_CONFIG_FILE}, using default"
_DO_ACU_LOGL=1 _DO_ACU_LOGL=1
@ -137,7 +138,7 @@ then
fi fi
# check for HP tools # check for HP tools
if [[ ! -x ${_HPACUCLI_BIN} || -z "${_HPACUCLI_BIN}" ]] if [[ ! -x ${_HPACUCLI_BIN} || -z "${_HPACUCLI_BIN}" ]]
then then
warn "${_HPACUCLI_BIN} is not installed here" warn "${_HPACUCLI_BIN} is not installed here"
return 1 return 1
@ -156,7 +157,7 @@ then
_MSG="failure in controller" _MSG="failure in controller"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU controller(s) ===" >>${HC_STDOUT_LOG} print "=== ACU controller(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
@ -173,12 +174,12 @@ then
# non-numeric # non-numeric
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}" warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
;; ;;
esac esac
done done
else else
warn "${_HPACUCLI_BIN}: do_acu_controller check is not enabled" warn "${_HPACUCLI_BIN}: do_acu_controller check is not enabled"
fi fi
# ENCLOSURE(s) # ENCLOSURE(s)
if (( _DO_ACU_ENCL != 0 )) if (( _DO_ACU_ENCL != 0 ))
then then
@ -195,7 +196,7 @@ then
_MSG="failure in enclosure for controller ${_CTRL_SLOT}" _MSG="failure in enclosure for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU enclosure(s) ===" >>${HC_STDOUT_LOG} print "=== ACU enclosure(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
@ -220,15 +221,15 @@ then
_MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU physical drive(s) ===" >>${HC_STDOUT_LOG} print "=== ACU physical drive(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
done done
else else
warn "${_HPACUCLI_BIN}: do_acu_physical check is not enabled" warn "${_HPACUCLI_BIN}: do_acu_physical check is not enabled"
fi fi
# LOGICAL DRIVE(s) # LOGICAL DRIVE(s)
if (( _DO_ACU_LOGL != 0 )) if (( _DO_ACU_LOGL != 0 ))
then then
@ -245,14 +246,14 @@ then
_MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU logical drive(s) ===" >>${HC_STDOUT_LOG} print "=== ACU logical drive(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
done done
else else
warn "${_HPACUCLI_BIN}: do_acu_logical check is not enabled" warn "${_HPACUCLI_BIN}: do_acu_logical check is not enabled"
fi fi
# report OK situation # report OK situation
if (( _STC_COUNT == 0 )) if (( _STC_COUNT == 0 ))

View File

@ -62,6 +62,7 @@ typeset _THRES_VALUE=""
typeset _TEMP_UNIT="" typeset _TEMP_UNIT=""
# set local trap for cleanup # set local trap for cleanup
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -70,7 +71,7 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done

View File

@ -55,6 +55,9 @@ typeset _SEVERITY_ENTRY=""
typeset _EVENT_ENTRY="" typeset _EVENT_ENTRY=""
# set local trap for cleanup # set local trap for cleanup
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1
return 0" 0
trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 trap "[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1
[[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1 [[ -f ${_TMP2_FILE} ]] && rm -f ${_TMP2_FILE} >/dev/null 2>&1
return 1" 1 2 3 15 return 1" 1 2 3 15
@ -65,13 +68,13 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -93,7 +96,7 @@ else
_HPLOG_SEVERITIES="^" _HPLOG_SEVERITIES="^"
print "${_SEVERITIES_LINE}" | tr ',' '\n' 2>/dev/null | while read -r _SEVERITY_ENTRY print "${_SEVERITIES_LINE}" | tr ',' '\n' 2>/dev/null | while read -r _SEVERITY_ENTRY
do do
_HPLOG_SEVERITIES="${_HPLOG_SEVERITIES}(([0-9]+)\s*${_SEVERITY_ENTRY})|" _HPLOG_SEVERITIES="${_HPLOG_SEVERITIES}(([0-9]+)\s*${_SEVERITY_ENTRY})|"
done done
# delete last 'OR' # delete last 'OR'
_HPLOG_SEVERITIES=${_HPLOG_SEVERITIES%?} _HPLOG_SEVERITIES=${_HPLOG_SEVERITIES%?}
@ -121,7 +124,7 @@ ${_HPLOG_BIN} -v >${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
print "## this file sorted! Do not edit manually!" >${_STATE_FILE} print "## this file sorted! Do not edit manually!" >${_STATE_FILE}
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to create new state file" warn "failed to create new state file"
return 1 return 1
} }
log "created new state file at ${_STATE_FILE}" log "created new state file at ${_STATE_FILE}"
} }
@ -139,7 +142,7 @@ do
_MSG="${_EVENT_ENTRY}" _MSG="${_EVENT_ENTRY}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done <${_TMP2_FILE} done <${_TMP2_FILE}
if (( _STC_COUNT > 0 )) if (( _STC_COUNT > 0 ))
then then
@ -149,8 +152,8 @@ then
sort -u ${_TMP1_FILE} ${_TMP2_FILE} >${_STATE_FILE} 2>/dev/null sort -u ${_TMP1_FILE} ${_TMP2_FILE} >${_STATE_FILE} 2>/dev/null
(( $? > 0 )) && { (( $? > 0 )) && {
warn "failed to sort temporary state file" warn "failed to sort temporary state file"
return 1 return 1
} }
else else
_MSG="no new HPLOG messages found" _MSG="no new HPLOG messages found"
fi fi

View File

@ -57,6 +57,7 @@ typeset _DO_SSA_LOGL=1
typeset _DO_CHECK=0 typeset _DO_CHECK=0
# set local trap for cleanup # set local trap for cleanup
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 0" 0
trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15 trap "[[ -f ${_TMP_FILE} ]] && rm -f ${_TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -65,13 +66,13 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -88,7 +89,7 @@ case "${_DO_SSA_CTRL}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_ssa_controller' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_ssa_controller' in ${_CONFIG_FILE}, using default"
_DO_SSA_CTRL=1 _DO_SSA_CTRL=1
@ -99,7 +100,7 @@ case "${_DO_SSA_ENCL}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_ssa_enclosure' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_ssa_enclosure' in ${_CONFIG_FILE}, using default"
_DO_SSA_ENCL=1 _DO_SSA_ENCL=1
@ -110,7 +111,7 @@ case "${_DO_SSA_PHYS}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_ssa_physical' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_ssa_physical' in ${_CONFIG_FILE}, using default"
_DO_SSA_PHYS=1 _DO_SSA_PHYS=1
@ -121,7 +122,7 @@ case "${_DO_SSA_LOGL}" in
0|1) 0|1)
# on/off, OK # on/off, OK
;; ;;
*) *)
# set default # set default
warn "illegal value for 'do_ssa_logical' in ${_CONFIG_FILE}, using default" warn "illegal value for 'do_ssa_logical' in ${_CONFIG_FILE}, using default"
_DO_SSA_LOGL=1 _DO_SSA_LOGL=1
@ -137,7 +138,7 @@ then
fi fi
# check for HP tools # check for HP tools
if [[ ! -x ${_HPSSACLI_BIN} || -z "${_HPSSACLI_BIN}" ]] if [[ ! -x ${_HPSSACLI_BIN} || -z "${_HPSSACLI_BIN}" ]]
then then
warn "${_HPSSACLI_BIN} is not installed here" warn "${_HPSSACLI_BIN} is not installed here"
return 1 return 1
@ -156,7 +157,7 @@ then
_MSG="failure in controller" _MSG="failure in controller"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA controller(s) ===" >>${HC_STDOUT_LOG} print "=== SSA controller(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
@ -173,12 +174,12 @@ then
# non-numeric # non-numeric
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}" warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
;; ;;
esac esac
done done
else else
warn "${_HPSSACLI_BIN}: do_ssa_controller check is not enabled" warn "${_HPSSACLI_BIN}: do_ssa_controller check is not enabled"
fi fi
# ENCLOSURE(s) # ENCLOSURE(s)
if (( _DO_SSA_ENCL != 0 )) if (( _DO_SSA_ENCL != 0 ))
then then
@ -195,7 +196,7 @@ then
_MSG="failure in enclosure for controller ${_CTRL_SLOT}" _MSG="failure in enclosure for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA enclosure(s) ===" >>${HC_STDOUT_LOG} print "=== SSA enclosure(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
@ -220,15 +221,15 @@ then
_MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA physical drive(s) ===" >>${HC_STDOUT_LOG} print "=== SSA physical drive(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
done done
else else
warn "${_HPSSACLI_BIN}: do_ssa_physical check is not enabled" warn "${_HPSSACLI_BIN}: do_ssa_physical check is not enabled"
fi fi
# LOGICAL DRIVE(s) # LOGICAL DRIVE(s)
if (( _DO_SSA_LOGL != 0 )) if (( _DO_SSA_LOGL != 0 ))
then then
@ -245,14 +246,14 @@ then
_MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result # handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA logical drive(s) ===" >>${HC_STDOUT_LOG} print "=== SSA logical drive(s) ===" >>${HC_STDOUT_LOG}
cat ${_TMP_FILE} >>${HC_STDOUT_LOG} cat ${_TMP_FILE} >>${HC_STDOUT_LOG}
done done
else else
warn "${_HPSSACLI_BIN}: do_ssa_logical check is not enabled" warn "${_HPSSACLI_BIN}: do_ssa_logical check is not enabled"
fi fi
# report OK situation # report OK situation
if (( _STC_COUNT == 0 )) if (( _STC_COUNT == 0 ))

View File

@ -66,6 +66,7 @@ typeset _USER_PS_PID=""
typeset _USER_PS_COMM="" typeset _USER_PS_COMM=""
# set local trap for cleanup # set local trap for cleanup
trap "rm -f ${_INSTANCE_RUN_FILE}.* >/dev/null 2>&1; return 0" 0
trap "rm -f ${_INSTANCE_RUN_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 trap "rm -f ${_INSTANCE_RUN_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -92,7 +93,7 @@ case "${_CFG_HEALTHY}" in
_LOG_HEALTHY=1 _LOG_HEALTHY=1
;; ;;
*) *)
# do not override hc_arg # do not override hc_arg
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0 (( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
;; ;;
esac esac
@ -320,14 +321,14 @@ then
awk -v f="${_LIMIT_FIELD}" '{ print $f}' 2>/dev/null) awk -v f="${_LIMIT_FIELD}" '{ print $f}' 2>/dev/null)
_MSG_BIT="${_LIMIT_PID}/${_LIMIT_USER}/${_LIMIT_PROCESS}" _MSG_BIT="${_LIMIT_PID}/${_LIMIT_USER}/${_LIMIT_PROCESS}"
;; ;;
"Max processes") "Max processes")
case "${_LIMIT_TYPE}" in case "${_LIMIT_TYPE}" in
soft) soft)
_LIMIT_COMMAND="ulimit -a" _LIMIT_COMMAND="ulimit -a"
;; ;;
hard) hard)
_LIMIT_COMMAND="ulimit -Ha" _LIMIT_COMMAND="ulimit -Ha"
;; ;;
esac esac
_LIMIT_VALUE=$(su - ${_LIMIT_USER} -c "${_LIMIT_COMMAND}" 2>/dev/null |\ _LIMIT_VALUE=$(su - ${_LIMIT_USER} -c "${_LIMIT_COMMAND}" 2>/dev/null |\
grep -i "max user processes" 2>/dev/null | sed -s "s/max user processes//g" 2>/dev/null |\ grep -i "max user processes" 2>/dev/null | sed -s "s/max user processes//g" 2>/dev/null |\
@ -337,8 +338,8 @@ then
warn "${_LIMIT_TYPE}: unable to gather limits information (${_LIMIT_USER})" warn "${_LIMIT_TYPE}: unable to gather limits information (${_LIMIT_USER})"
return 1 return 1
fi fi
_MSG_BIT="${_LIMIT_USER}" _MSG_BIT="${_LIMIT_USER}"
;; ;;
esac esac
# check limit value -> threshold # check limit value -> threshold
if [[ "${_LIMIT_VALUE}" = "unlimited" ]] if [[ "${_LIMIT_VALUE}" = "unlimited" ]]

View File

@ -37,7 +37,7 @@ typeset _VERSION="2018-05-21" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
# rubbish that cmgetconf outputs to STDOUT instead of STDERR # rubbish that cmgetconf outputs to STDOUT instead of STDERR
typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured"
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
# set defaults # set defaults
@ -59,6 +59,7 @@ typeset _CLUSTER_PARAM=""
typeset _CLUSTER_VALUE="" typeset _CLUSTER_VALUE=""
# set local trap for cleanup # set local trap for cleanup
trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 0" 0
trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 trap "rm -f ${_CLUSTER_RUN_FILE}.* ${_CLUSTER_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -67,13 +68,13 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle configuration file # handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -92,7 +93,7 @@ then
fi fi
# check serviceguard status & gather cluster information from running cluster (compressed lines) # check serviceguard status & gather cluster information from running cluster (compressed lines)
if [[ ! -x ${_SG_DAEMON} ]] if [[ ! -x ${_SG_DAEMON} ]]
then then
warn "${_SG_DAEMON} is not installed here" warn "${_SG_DAEMON} is not installed here"
return 1 return 1
@ -118,10 +119,10 @@ do
BEGIN { found = 0; needle = "^\["cluster"\]" } BEGIN { found = 0; needle = "^\["cluster"\]" }
# skip blank lines # skip blank lines
/^\s*$/ { next; } /^\s*$/ { next; }
# skip comment lines # skip comment lines
/^#/ { next; } /^#/ { next; }
# end marker # end marker
( $0 ~ /^\[.*\]/ && found ) { ( $0 ~ /^\[.*\]/ && found ) {
found = 0; found = 0;
@ -160,7 +161,7 @@ do
else else
_MSG="'${_CLUSTER_PARAM} (${_CLUSTER_VALUE} ...)' is configured for ${_CLUSTER_INSTANCE}" _MSG="'${_CLUSTER_PARAM} (${_CLUSTER_VALUE} ...)' is configured for ${_CLUSTER_INSTANCE}"
fi fi
# handle unit result # handle unit result
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
_STC=0 _STC=0

View File

@ -37,7 +37,7 @@ typeset _VERSION="2018-05-21" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
# rubbish that cmgetconf outputs to STDOUT instead of STDERR # rubbish that cmgetconf outputs to STDOUT instead of STDERR
typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured" typeset _SG_CMGETCONF_FILTER="Permission denied|Number of configured"
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
# set defaults # set defaults
@ -59,6 +59,7 @@ typeset _PKG_PARAM=""
typeset _PKG_VALUE="" typeset _PKG_VALUE=""
# set local trap for cleanup # set local trap for cleanup
trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 0" 0
trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15 trap "rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -67,13 +68,13 @@ do
case "${_ARG}" in case "${_ARG}" in
help) help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0 _show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;; ;;
esac esac
done done
# handle config file # handle config file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}" [[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]] if [[ ! -r ${_CONFIG_FILE} ]]
then then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
@ -92,7 +93,7 @@ then
fi fi
# check serviceguard status & gather package information from running cluster (compressed lines) # check serviceguard status & gather package information from running cluster (compressed lines)
if [[ ! -x ${_SG_DAEMON} ]] if [[ ! -x ${_SG_DAEMON} ]]
then then
warn "${_SG_DAEMON} is not installed here" warn "${_SG_DAEMON} is not installed here"
return 1 return 1
@ -118,10 +119,10 @@ do
BEGIN { found = 0; needle = "^\["package"\]" } BEGIN { found = 0; needle = "^\["package"\]" }
# skip blank lines # skip blank lines
/^\s*$/ { next; } /^\s*$/ { next; }
# skip comment lines # skip comment lines
/^#/ { next; } /^#/ { next; }
# end marker # end marker
( $0 ~ /^\[.*\]/ && found ) { ( $0 ~ /^\[.*\]/ && found ) {
found = 0; found = 0;
@ -160,13 +161,13 @@ do
else else
_MSG="'${_PKG_PARAM} (${_PKG_VALUE} ...)' is configured for ${_PKG_INSTANCE}" _MSG="'${_PKG_PARAM} (${_PKG_VALUE} ...)' is configured for ${_PKG_INSTANCE}"
fi fi
# handle unit result # handle unit result
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
_STC=0 _STC=0
done <${_PKG_CFG_FILE}.${_PKG_INSTANCE} done <${_PKG_CFG_FILE}.${_PKG_INSTANCE}
done done
# remove working files # remove working files
rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1 rm -f ${_PKG_RUN_FILE}.* ${_PKG_CFG_FILE}.* >/dev/null 2>&1
@ -181,7 +182,7 @@ NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 CONFIG : $3
PURPOSE : Checks the configuration of Serviceguard package parameters (SG 11.16+) PURPOSE : Checks the configuration of Serviceguard package parameters (SG 11.16+)
(comparing serialized strings from the HC configuration file to the (comparing serialized strings from the HC configuration file to the
running cluster configuration) running cluster configuration)
EOT EOT