Added support for --log-healthy (AIX plugins)

This commit is contained in:
patvdv 2019-03-10 16:31:15 +01:00
parent cced8a893c
commit c3cc87609d
15 changed files with 449 additions and 142 deletions

View File

@ -6,9 +6,18 @@
# [default: indicates hardcoded script values if no value is defined here]
#******************************************************************************
# file (full path); maximum age in minutes since last change
/var/adm/ras/syslog.caa;600
/var/log/ntp.log;30
# specify whether to also log passed health checks
# (warning: this may rapidly grow the HC log)
# [default: no]
log_healthy="no"
# specify file details
# Format:
# file:<file_path>:<max_age_minutes_since_last_change>
# Examples:
#file:/var/log/messages:60
#file:/var/log/ntp.log:30
#******************************************************************************
# End of FILE

View File

@ -6,6 +6,11 @@
# [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="no"
# name of the state file to use (will be relative to /var/opt/hc/state/persistent
# [default: discovered.file_change]
state_file=discovered.file_change

View File

@ -6,10 +6,19 @@
# [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="no"
# list of commands (or strings) that should appear in active cron entries
/opt/cfg2html/bin/cfg2html_aix.sh
/usr/local/bin/run_aix_system_backup.sh
/usr/bin/nmon
# Format:
# cron:<cron_entry>
# Examples:
#cron:/opt/cfg2html/bin/cfg2html_aix.sh
#cron:/usr/local/bin/run_aix_system_backup.sh
#cron:/usr/bin/nmon
#******************************************************************************
# End of FILE

View File

@ -6,29 +6,38 @@
# [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="no"
# list of required active subsystems
sendmail
syslogd
portmap
inetd
snmpd
hostmibd
snmpmibd
aixmibd
#nimsh
biod
rpc.statd
rpc.lockd
automountd
qdaemon
writesrv
sshd
xntpd
cimsys
ctrmc
IBM.ServiceRM
IBM.DRM
IBM.CSMAgentRM
# Format:
# subsys:<subsystem_name>
# Examples:
#subsys:sendmail
#subsys:syslogd
#subsys:portmap
#subsys:inetd
#subsys:snmpd
#subsys:hostmibd
#subsys:snmpmibd
#subsys:aixmibd
#subsys:nimsh
#subsys:biod
#subsys:rpc.statd
#subsys:rpc.lockd
#subsys:qdaemon
#subsys:automountd
#subsys:writesrv
#subsys:sshd
#subsys:xntpd
#subsys:cimsys
#subsys:ctrmc
#subsys:IBM.ServiceRM
#subsys:IBM.DRM
#subsys:IBM.CSMAgentRM
#******************************************************************************
# End of FILE

View File

@ -6,6 +6,11 @@
# [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="no"
# full path to the location of mksysb images, the tool expects sub-directories
# per host underneath this location
backup_path=/export/images
@ -17,6 +22,7 @@ mksysb_log=mksysb.log
# [default: 14]
backup_age=14
#******************************************************************************
# End of FILE
#******************************************************************************

View File

@ -27,6 +27,7 @@
# @(#) 2013-06-24: big fix errpt last check time [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!
#******************************************************************************
@ -35,7 +36,7 @@
function check_aix_errpt
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _LAST_TIME_CHECK=""
typeset _LAST_TIME_FILE=""
typeset _LABEL=""
@ -61,6 +63,20 @@ do
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 for last known check date
_LAST_TIME_FILE="${STATE_DIR}/$0.lasttime"
if [[ -r ${_LAST_TIME_FILE} ]]
@ -79,8 +95,8 @@ then
errpt -A >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
else
errpt -s "${_LAST_TIME_CHECK}" |\
grep -v "${_LAST_TIME_CHECK}" | grep -v "_IDENTIFIER" |\
awk '{ print $1}' | uniq | while read _LABEL
grep -v "${_LAST_TIME_CHECK}" 2>/dev/null | grep -v "_IDENTIFIER" 2>/dev/null |\
awk '{ print $1}' 2>/dev/null | uniq 2>/dev/null | while read _LABEL
do
errpt -a -j ${_LABEL} -s "${_LAST_TIME_CHECK}" \
>>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
@ -99,7 +115,7 @@ fi
# update last known check date/time (potential race condition here,
# but we can live it :-))
_NEW_CHECK_TIME="$(errpt 2>/dev/null | head -n 2 | tail -n 1 | awk '{print $2}')"
_NEW_CHECK_TIME="$(errpt 2>/dev/null | head -n 2 2>/dev/null | tail -n 1 2>/dev/null | awk '{print $2}' 2>/dev/null)"
# blank result indicates either no errpt entries or exist the time call failed
if [[ -n "${_NEW_CHECK_TIME}" ]]
then
@ -110,7 +126,10 @@ else
fi
# handle results
log_hc "$0" ${_STC} "${_MSG}"
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
return 0
}
@ -121,8 +140,8 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3
PURPOSE : Checks AIX errpt for new error(s)
LOG HEALTHY : Supported
EOT

View File

@ -25,6 +25,8 @@
# @(#) 2013-05-27: 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 code for data_is_numeric(), changed format of configuration
# @(#) file (; -> :) & added support for --log-healthy [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
@ -34,7 +36,7 @@ function check_aix_file_age
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -45,12 +47,14 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _ENTRY=""
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _AGE_CHECK=""
typeset _FILE_PATH=""
typeset _FILE_AGE=""
typeset _FILE_NAME=""
typeset _FILE_DIR=""
typeset _IS_OLD_STYLE=0
# handle arguments (originally comma-separated)
for _ARG in ${_ARGS}
@ -69,14 +73,42 @@ 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 "^file:" ${_CONFIG_FILE} 2>/dev/null)
if (( _IS_OLD_STYLE == 0 ))
then
warn "no 'file:' 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
# perform check
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _ENTRY
grep -E -e "^file:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _FILE_PATH _FILE_AGE
do
# field split
_FILE_PATH="$(print ${_ENTRY%%;*})"
_FILE_AGE="$(print ${_ENTRY##*;})"
# split file/dir
_FILE_NAME="$(print ${_FILE_PATH##*/})"
_FILE_DIR="$(print ${_FILE_PATH%/*})"
@ -87,16 +119,12 @@ do
warn "missing values in configuration file at ${_CONFIG_FILE}"
return 1
fi
case "${_FILE_AGE}" in
+([0-9])*(.)*([0-9]))
# numeric, OK
;;
*)
# not numeric
data_is_numeric "${_FILE_AGE}"
if (( $? > 0 ))
then
warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}"
return 1
;;
esac
fi
# perform check
if [[ ! -r "${_FILE_PATH}" ]]
@ -119,8 +147,11 @@ do
fi
fi
# handle unit result
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0
done
@ -133,10 +164,13 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3 with:
<file_name>;<maximum_age_in_minutes>
CONFIG : $3 with parameters:
log_healthy=<yes|no>
and formatted stanzas:
file:<file_path>:<max_age_in_minutes>
PURPOSE : Checks whether given files have been changed in the last n minutes
Requires {find -mmin}.
LOG HEALTHY : Supported
EOT

View File

@ -27,6 +27,7 @@
# @(#) 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-03-09: added support for --log-healthy [Patrick Van der Veken]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
@ -36,7 +37,7 @@ function check_aix_file_change
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -47,6 +48,8 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _DO_META_CHECK=0
typeset _CFG_STATE_FILE=""
typeset _STATE_FILE=""
@ -111,6 +114,30 @@ case "${_DO_META_CHECK}" in
log "check for meta characters is enabled"
;;
esac
_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 checksum tools
_OPENSSL_BIN="$(which openssl 2>>${HC_STDERR_LOG})"
@ -293,7 +320,7 @@ do
fi
# bounce failures back and jump to next file
if (( _STC > 0 ))
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
continue
@ -319,7 +346,11 @@ do
printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE}
# report with curr/exp values
if (( _LOG_HEALTHY > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}"
continue
fi
done <${_TMP1_FILE}
# update state file (also if TMP2_FILE is empty)
@ -350,7 +381,9 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3 with formatted stanzas:
CONFIG : $3 with parameters:
log_healthy=<yes|no>
and formatted stanzas:
incl:<full path>
excl:<full path>
PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes
@ -365,6 +398,7 @@ PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and exclu
Processing a big number of files is likely to take
ages and probably will cause the plugin to time out
(see HC_TIME_OUT). YMMV.
LOG HEALTHY : Supported
EOT

View File

@ -24,6 +24,7 @@
# @(#) HISTORY:
# @(#) 2013-05-15: initial version [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!
#******************************************************************************
@ -32,7 +33,7 @@
function check_aix_fs_mounts
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -43,6 +44,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _FS=""
typeset _FS_COUNT=""
@ -56,6 +58,20 @@ do
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
# collect data (mount & lsfs output may be safely merged)
mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
(( $? == 0)) || return $?
@ -83,8 +99,11 @@ do
;;
esac
# handle unit result
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0
done
@ -97,8 +116,8 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3
PURPOSE : Checks whether file systems are mounted or not {lsfs/mount}
LOG HEALTHY : Supported
EOT

View File

@ -24,6 +24,7 @@
# @(#) HISTORY:
# @(#) 2013-05-17: initial version [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!
#******************************************************************************
@ -32,7 +33,7 @@
function check_aix_lppchk
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -43,6 +44,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _LOG_HEALTHY=0
# handle arguments (originally comma-separated)
for _ARG in ${_ARGS}
@ -54,6 +56,20 @@ do
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
# collect data
lppchk -v -m1 >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
(( $? == 0)) || return $?
@ -67,8 +83,11 @@ else
_MSG="lppchk passed without errors"
fi
# handle results
log_hc "$0" ${_STC} "${_MSG}"
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
return 0
}
@ -79,8 +98,8 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3
PURPOSE : Run {lppchk -v}
LOG HEALTHY : Supported
EOT

View File

@ -24,6 +24,7 @@
# @(#) HISTORY:
# @(#) 2013-05-07: initial version [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!
#******************************************************************************
@ -32,7 +33,7 @@
function check_aix_paths
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -43,6 +44,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _PATH=""
# handle arguments (originally comma-separated)
@ -55,6 +57,20 @@ do
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
# collect data
lspath >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
(( $? == 0)) || return $?
@ -71,8 +87,11 @@ case ${_PATH} in
;;
esac
# handle results
log_hc "$0" ${_STC} "${_MSG}"
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
return 0
}
@ -83,8 +102,8 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3
PURPOSE : Checks whether any hardware paths are missing {lspath}
LOG HEALTHY : Supported
EOT

View File

@ -24,6 +24,8 @@
# @(#) HISTORY:
# @(#) 2013-09-19: initial version [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]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
@ -33,7 +35,7 @@ function check_aix_root_crontab
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -44,8 +46,11 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _CRON_ENTRY=""
typeset _CRON_MATCH=0
typeset _IS_OLD_STYLE=0
# handle arguments (originally comma-separated)
for _ARG in ${_ARGS}
@ -57,7 +62,6 @@ do
esac
done
# handle configuration file
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
if [[ ! -r ${_CONFIG_FILE} ]]
@ -65,12 +69,44 @@ 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 "^cron:" ${_CONFIG_FILE} 2>/dev/null)
if (( _IS_OLD_STYLE == 0 ))
then
warn "no 'cron:' 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
# collect data
crontab -l >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
# perform check
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _CRON_ENTRY
grep -E -e "^cron:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _CRON_ENTRY
do
_CRON_MATCH=$(grep -v '^#' ${HC_STDOUT_LOG} 2>/dev/null |\
grep -c -E -e "${_CRON_ENTRY}")
@ -87,8 +123,11 @@ do
;;
esac
# handle unit result
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0
done
@ -101,8 +140,12 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3
CONFIG : $3 with parameters:
log_healthy=<yes|no>
and formatted stanzas:
cron:<cron_entry>
PURPOSE : Checks the content of the 'root' user crontab for required entries
LOG HEALTHY : Supported
EOT

View File

@ -24,6 +24,8 @@
# @(#) HISTORY:
# @(#) 2013-05-07: initial version [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]
# -----------------------------------------------------------------------------
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#******************************************************************************
@ -33,7 +35,7 @@ function check_aix_subsystems
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -44,7 +46,10 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _STATUS=""
typeset _IS_OLD_STYLE=0
# handle arguments (originally comma-separated)
for _ARG in ${_ARGS}
@ -64,13 +69,31 @@ 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 "^subsys:" ${_CONFIG_FILE} 2>/dev/null)
if (( _IS_OLD_STYLE == 0 ))
then
warn "no 'subsys:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
return 1
fi
# collect data
lssrc -a >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
(( $? == 0)) || return $?
# perform check
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _SUBSYS
grep -E -e "^subsys:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _SUBSYS
do
_STATUS="$(grep -E -e ${_SUBSYS} ${HC_STDOUT_LOG} 2>/dev/null)"
case "${_STATUS}" in
@ -86,8 +109,11 @@ do
;;
esac
# handle unit result
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0
done
@ -100,10 +126,12 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3 with:
subsys1
subsys2
CONFIG : $3 with parameters:
log_healthy=<yes|no>
and formatted stanzas:
subsys:<subsystem_name>
PURPOSE : Checks whether subsystem(s) are active/operative {lssrc}
LOG HEALTHY : Supported
EOT

View File

@ -24,6 +24,7 @@
# @(#) HISTORY:
# @(#) 2013-05-28: initial version [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!
#******************************************************************************
@ -35,7 +36,7 @@ function check_aix_sysbackup
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
# mksysb identifier prefix of error code(s)
typeset _MKSYSB_NEEDLE="^0512"
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -46,6 +47,8 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _BACKUP_PATH=""
typeset _BACKUP_HOST=""
typeset _BACKUP_LOG=""
@ -99,9 +102,33 @@ case "${_BACKUP_AGE}" in
_BACKUP_AGE=14
;;
esac
_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
# perform state check on mksysb log files
ls -1 ${_BACKUP_PATH} | while read _BACKUP_HOST
ls -1 ${_BACKUP_PATH} 2>>${HC_STDERR_LOG} | while read -r _BACKUP_HOST
do
_BACKUP_LOG="${_BACKUP_PATH}/${_BACKUP_HOST}/curr/${_MKSYSB_LOG}"
if [[ -r "${_BACKUP_LOG}" ]]
@ -134,13 +161,16 @@ do
continue
fi
# handle unit result
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0
done
# perform age check on mksysb log files
ls -1 ${_BACKUP_PATH} | while read _BACKUP_HOST
ls -1 ${_BACKUP_PATH} 2>>${HC_STDERR_LOG} | while read -r _BACKUP_HOST
do
_BACKUP_LOG="${_BACKUP_PATH}/${_BACKUP_HOST}/curr/${_MKSYSB_LOG}"
if [[ -r "${_BACKUP_LOG}" ]]
@ -163,8 +193,11 @@ do
continue
fi
# handle unit result
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0
done
@ -177,13 +210,15 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3 with:
CONFIG : $3 with parameters:
log_healthy=<yes|no>
backup_path=<location_of_mksysb_images>
mksysb_log=<name_of_standard_standard_mksysb_log>
backup_age=<days_till_last_backup>
PURPOSE : Checks the state of saved mksysb client backups (should typically be
run only on the NIM master or server that is acting as mksysb repo,
do NOT run on a typical client LPAR)
LOG HEALTHY : Supported
EOT

View File

@ -25,6 +25,7 @@
# @(#) 2013-05-07: initial version [Patrick Van der Veken]
# @(#) 2013-08-16: comparison fix [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!
#******************************************************************************
@ -33,7 +34,7 @@
function check_aix_topasrec
{
# ------------------------- CONFIGURATION starts here -------------------------
typeset _VERSION="2019-01-24" # YYYY-MM-DD
typeset _VERSION="2019-03-09" # YYYY-MM-DD
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
@ -44,6 +45,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG=""
typeset _MSG=""
typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _TOPAS=0
typeset _NMON=0
@ -57,6 +59,20 @@ do
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
# collect data
topasrec -l >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
(( $? == 0 )) || return $?
@ -70,8 +86,11 @@ then
_STC=1
fi
# handle results
log_hc "$0" ${_STC} "${_MSG}"
# report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
fi
return 0
}
@ -82,8 +101,8 @@ function _show_usage
cat <<- EOT
NAME : $1
VERSION : $2
CONFIG : $3
PURPOSE : Checks on the active topasrec/nmon processes (only 1 should be running)
LOG HEALTHY : Supported
EOT