Import
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_errpt.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_errpt
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-15: initial version [Patrick Van der Veken]
|
||||
# @(#) 2013-05-29: small fix errpt last check time [Patrick Van der Veken]
|
||||
# @(#) 2013-06-24: big fix errpt last check time [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_errpt
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2013-06-24" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _LAST_TIME_CHECK=""
|
||||
typeset _LAST_TIME_FILE=""
|
||||
typeset _LABEL=""
|
||||
typeset _IDENTIFIER=""
|
||||
typeset _NEW_CHECK_TIME=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# check for last known check date
|
||||
_LAST_TIME_FILE="${STATE_DIR}/$0.lasttime"
|
||||
if [[ -r ${_LAST_TIME_FILE} ]]
|
||||
then
|
||||
if [[ -s ${_LAST_TIME_FILE} ]]
|
||||
then
|
||||
_LAST_TIME_CHECK="<${_LAST_TIME_FILE})"
|
||||
else
|
||||
warn "$0: no last known check date/time"
|
||||
fi
|
||||
fi
|
||||
|
||||
# collect data
|
||||
if [[ -z "${_LAST_TIME_CHECK}" ]]
|
||||
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
|
||||
do
|
||||
errpt -a -j ${_LABEL} -s "${_LAST_TIME_CHECK}" \
|
||||
>>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
done
|
||||
(( $? == 0)) || return $?
|
||||
fi
|
||||
|
||||
# do we have errors?
|
||||
if [[ -s ${HC_STDOUT_LOG} ]]
|
||||
then
|
||||
_MSG="new entries found in errpt: {$(grep -c '^LABEL' ${HC_STDOUT_LOG} 2>/dev/null)}"
|
||||
_STC=1
|
||||
else
|
||||
_MSG="no new entries found in {errpt}"
|
||||
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}')"
|
||||
# blank result indicates either no errpt entries or exist the time call failed
|
||||
if [[ -n "${_NEW_CHECK_TIME}" ]]
|
||||
then
|
||||
print "${_NEW_CHECK_TIME}" >${_LAST_TIME_FILE}
|
||||
(( $? == 0)) || warn "$0: unable to write last check time to ${_LAST_TIME_FILE}"
|
||||
else
|
||||
warn "$0: no last check time received from errpt (no entries)"
|
||||
fi
|
||||
|
||||
# handle results
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks AIX errpt for new error(s)
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_file_age.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_file_age
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-27: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_file_age
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2013-05-27" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _ENTRY=""
|
||||
typeset _AGE_CHECK==""
|
||||
typeset _FILE_PATH=""
|
||||
typeset _FILE_AGE=""
|
||||
typeset _FILE_NAME=""
|
||||
typeset _FILE_DIR=""
|
||||
|
||||
# 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
|
||||
|
||||
# perform check
|
||||
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _ENTRY
|
||||
do
|
||||
# field split
|
||||
_FILE_PATH="$(print ${_ENTRY%%;*})"
|
||||
_FILE_AGE="$(print ${_ENTRY##*;})"
|
||||
|
||||
# split file/dir
|
||||
_FILE_NAME="$(print ${_FILE_PATH##*/})"
|
||||
_FILE_DIR="$(print ${_FILE_PATH%/*})"
|
||||
|
||||
# check config
|
||||
if [ \( -z "${_FILE_PATH}" \) -a \( -z "${_FILE_AGE}" \) ]
|
||||
then
|
||||
warn "missing values in configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
case "${_FILE_AGE}" in
|
||||
+([0-9])*(.)*([0-9]))
|
||||
# numeric, OK
|
||||
;;
|
||||
*)
|
||||
# not numeric
|
||||
warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# perform check
|
||||
if [[ ! -r "${_FILE_PATH}" ]]
|
||||
then
|
||||
_MSG="unable to read or access requested file at ${_FILE_PATH}"
|
||||
_STC=1
|
||||
else
|
||||
_AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -mmin -"${_FILE_AGE}")
|
||||
if (( $? != 0 ))
|
||||
then
|
||||
warn "unable to execute file age test for ${_FILE_PATH}"
|
||||
return 1
|
||||
fi
|
||||
if [[ -z "${_AGE_CHECK}" ]]
|
||||
then
|
||||
_MSG="file age of ${_FILE_AGE} has expired on ${_FILE_PATH}"
|
||||
_STC=1
|
||||
else
|
||||
_MSG="file age of ${_FILE_AGE} has not expired on ${_FILE_PATH}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
<file_name>;<maximum_age_in_minutes>
|
||||
PURPOSE : Checks whether given files have been changed in the last n minutes
|
||||
Requires {find -mmin}.
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,373 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_file_change.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2017 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_aix_file_change
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn(),
|
||||
# openssl (sha256 digest) OR cksum (CRC32 digest)
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-05-18: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_file_change
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2017-05-18" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
typeset _ARGS=$(data_space2comma "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _STC_COUNT=0
|
||||
typeset _DO_META_CHECK=0
|
||||
typeset _CFG_STATE_FILE=""
|
||||
typeset _STATE_FILE=""
|
||||
typeset _STATE_FILE_LINE=""
|
||||
typeset _FILE_TO_CHECK=""
|
||||
typeset _EXCL_OBJECT=""
|
||||
typeset _INCL_OBJECT=""
|
||||
typeset _HAS_OPENSSL=0
|
||||
typeset _HAS_CKSUM=0
|
||||
typeset _OPENSSL_BIN=""
|
||||
typeset _CKSUM_BIN=""
|
||||
typeset _USE_OPENSSL=0
|
||||
typeset _USE_CKSUM=0
|
||||
typeset _TMP1_FILE="${TMP_DIR}/.$0.tmp1.$$"
|
||||
typeset _TMP2_FILE="${TMP_DIR}/.$0.tmp2.$$"
|
||||
typeset _TMP_INCL_FILE="${TMP_DIR}/.$0.tmp_incl.$$"
|
||||
typeset _TMP_EXCL_FILE="${TMP_DIR}/.$0.tmp_excl.$$"
|
||||
set -o noglob # no file globbing
|
||||
|
||||
# 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 1" 1 2 3 15
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# handle configuration file
|
||||
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||
then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
# read required configuration values
|
||||
_CFG_STATE_FILE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'state_file')
|
||||
if [[ -z "${_CFG_STATE_FILE}" ]]
|
||||
then
|
||||
_STATE_FILE="${STATE_PERM_DIR}/discovered.file_change"
|
||||
else
|
||||
_STATE_FILE="${STATE_PERM_DIR}/${_CFG_STATE_FILE}"
|
||||
fi
|
||||
log "using state file ${_STATE_FILE}"
|
||||
_DO_META_CHECK=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'do_meta_check')
|
||||
case "${_DO_META_CHECK}" in
|
||||
no|NO|No)
|
||||
_DO_META_CHECK=0
|
||||
log "check for meta characters is disabled"
|
||||
;;
|
||||
*)
|
||||
_DO_META_CHECK=1
|
||||
log "check for meta characters is enabled"
|
||||
;;
|
||||
esac
|
||||
|
||||
# check for checksum tools
|
||||
_OPENSSL_BIN="$(which openssl 2>>${HC_STDERR_LOG})"
|
||||
[[ -x ${_OPENSSL_BIN} && -n "${_OPENSSL_BIN}" ]] && _HAS_OPENSSL=1
|
||||
_CKSUM_BIN="$(which cksum 2>>${HC_STDERR_LOG})"
|
||||
[[ -x ${_CKSUM_BIN} && -n "${_CKSUM_BIN}" ]] && _HAS_CKSUM=1
|
||||
# prefer openssl (for sha256)
|
||||
if (( _HAS_OPENSSL == 1 ))
|
||||
then
|
||||
_USE_OPENSSL=1
|
||||
elif (( _HAS_CKSUM == 1 ))
|
||||
then
|
||||
_USE_CKSUM=1
|
||||
else
|
||||
warn "unable to find the 'openssl/cksum' tools"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check state file & TMP_FILEs
|
||||
[[ -r ${_STATE_FILE} ]] || {
|
||||
>${_STATE_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create new state file at ${_STATE_FILE}"
|
||||
return 1
|
||||
}
|
||||
log "created new state file at ${_STATE_FILE}"
|
||||
}
|
||||
>${_TMP_INCL_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP_INCL_FILE}"
|
||||
return 1
|
||||
}
|
||||
>${_TMP_EXCL_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP_EXCL_FILE}"
|
||||
return 1
|
||||
}
|
||||
>${_TMP1_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP1_FILE}"
|
||||
return 1
|
||||
}
|
||||
>${_TMP2_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP2_FILE}"
|
||||
return 1
|
||||
}
|
||||
|
||||
# build list of configured objects: inclusion
|
||||
grep -i '^incl:' ${_CONFIG_FILE} 2>/dev/null |\
|
||||
while IFS=':' read _DUMMY _INCL_OBJECT
|
||||
do
|
||||
# check for meta & globbing characters (*?[]{}|)
|
||||
if (( _DO_META_CHECK == 1 ))
|
||||
then
|
||||
case "${_INCL_OBJECT}" in
|
||||
*\**|*\?*|*\[*|*\]*|*\{*|*\}*|*\|*)
|
||||
warn "meta characters are not supported in the entry (incl:${_INCL_OBJECT})"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# expand directories
|
||||
if [[ -d ${_INCL_OBJECT} ]]
|
||||
then
|
||||
find ${_INCL_OBJECT} -type f -xdev >>${_TMP_INCL_FILE} 2>>${HC_STDERR_LOG}
|
||||
else
|
||||
print ${_INCL_OBJECT} >>${_TMP_INCL_FILE}
|
||||
fi
|
||||
done
|
||||
|
||||
# build list of configured objects: exclusion
|
||||
grep -i '^excl:' ${_CONFIG_FILE} 2>/dev/null |\
|
||||
while IFS=':' read _DUMMY _EXCL_OBJECT
|
||||
do
|
||||
# check for meta & globbing characters (*?[]{}|)
|
||||
if (( _DO_META_CHECK == 1 ))
|
||||
then
|
||||
case "${_EXCL_OBJECT}" in
|
||||
*\**|*\?*|*\[*|*\]*|*\{*|*\}*|*\|*)
|
||||
warn "meta characters are not supported in the entry (excl:${_EXCL_OBJECT})"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# expand directories
|
||||
if [[ -d ${_EXCL_OBJECT} ]]
|
||||
then
|
||||
find ${_EXCL_OBJECT} -type f -xdev >>${_TMP_EXCL_FILE} 2>>${HC_STDERR_LOG}
|
||||
else
|
||||
print ${_EXCL_OBJECT} >>${_TMP_EXCL_FILE}
|
||||
fi
|
||||
done
|
||||
|
||||
# subtract exclusion from inclusion (exclusion has higher priority)
|
||||
sort ${_TMP_INCL_FILE} -o ${_TMP_INCL_FILE} 2>>${HC_STDERR_LOG}
|
||||
sort ${_TMP_EXCL_FILE} -o ${_TMP_EXCL_FILE} 2>>${HC_STDERR_LOG}
|
||||
comm -23 ${_TMP_INCL_FILE} ${_TMP_EXCL_FILE} 2>>${HC_STDERR_LOG} >${_TMP1_FILE}
|
||||
|
||||
# check discovered objects
|
||||
while read _FILE_TO_CHECK
|
||||
do
|
||||
# reset variables
|
||||
_STC=0
|
||||
_MSG=""
|
||||
_IS_NEW=0
|
||||
|
||||
# object to check must be a file (and be present)
|
||||
if [[ ! -f ${_FILE_TO_CHECK} ]]
|
||||
then
|
||||
_MSG="${_FILE_TO_CHECK} is not a file or has disappeared"
|
||||
_STC=1
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
continue
|
||||
fi
|
||||
|
||||
# read entry from state file
|
||||
_STATE_FILE_LINE=$(grep -E -e "^${_FILE_TO_CHECK}\|" ${_STATE_FILE})
|
||||
if [[ -n "${_STATE_FILE_LINE}" ]]
|
||||
then
|
||||
# field 1 is the file name
|
||||
_STATE_FILE_TYPE=$(print "${_STATE_FILE_LINE}" | cut -f2 -d'|')
|
||||
_STATE_FILE_CKSUM=$(print "${_STATE_FILE_LINE}" | cut -f3 -d'|')
|
||||
else
|
||||
_IS_NEW=1
|
||||
fi
|
||||
|
||||
# compute new checksum (keep the same type as before)
|
||||
if (( _IS_NEW == 0 ))
|
||||
then
|
||||
case "${_STATE_FILE_TYPE}" in
|
||||
openssl-sha256)
|
||||
if (( _USE_OPENSSL == 1 ))
|
||||
then
|
||||
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
||||
_FILE_TYPE="openssl-sha256"
|
||||
else
|
||||
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
||||
_STC=1
|
||||
fi
|
||||
;;
|
||||
cksum-crc32)
|
||||
if (( _USE_CKSUM == 1 ))
|
||||
then
|
||||
_FILE_CKSUM=$(${_CKSUM_BIN} ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
||||
_FILE_TYPE="cksum-crc32"
|
||||
else
|
||||
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
||||
_STC=1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
_MSG="cannot compute checksum (unknown checksum type) for ${_FILE_TO_CHECK}"
|
||||
_STC=1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# new file
|
||||
if (( _USE_OPENSSL == 1 ))
|
||||
then
|
||||
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
||||
_FILE_TYPE="openssl-sha256"
|
||||
elif (( _USE_CKSUM == 1 ))
|
||||
then
|
||||
_FILE_CKSUM=$(${_CKSUM_BIN} ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
||||
_FILE_TYPE="cksum-crc32"
|
||||
else
|
||||
_MSG="cannot compute checksum (openssl/cksum) for ${_FILE_TO_CHECK}"
|
||||
_STC=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# check for failed checksums
|
||||
if [[ -z "${_FILE_CKSUM}" ]]
|
||||
then
|
||||
_MSG="did not receive checksum (openssl/cksum) for ${_FILE_TO_CHECK}"
|
||||
_STC=1
|
||||
fi
|
||||
|
||||
# bounce failures back and jump to next file
|
||||
if (( _STC != 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
continue
|
||||
fi
|
||||
|
||||
if (( _IS_NEW == 0 ))
|
||||
then
|
||||
# compare old vs new checksums
|
||||
if [[ "${_STATE_FILE_CKSUM}" != "${_FILE_CKSUM}" ]]
|
||||
then
|
||||
_MSG="${_FILE_TO_CHECK} has a changed checksum [${_FILE_TYPE}]"
|
||||
_STC=1
|
||||
else
|
||||
_MSG="${_FILE_TO_CHECK} has the same checksum [${_FILE_TYPE}]"
|
||||
_STC=0
|
||||
fi
|
||||
else
|
||||
_MSG="${_FILE_TO_CHECK} is a new file [${_FILE_TYPE}]"
|
||||
_STC=0
|
||||
fi
|
||||
|
||||
# save entry to temp file
|
||||
printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE}
|
||||
|
||||
# report with curr/exp values
|
||||
log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}"
|
||||
done <${_TMP1_FILE}
|
||||
|
||||
# update state file (also if TMP2_FILE is empty)
|
||||
if (( ARG_LOG != 0 ))
|
||||
then
|
||||
[[ -s ${_TMP2_FILE} ]] || {
|
||||
warn "no files found to check, zeroing new state file"
|
||||
}
|
||||
mv ${_TMP2_FILE} ${_STATE_FILE} >/dev/null 2>&1
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to move temporary state file"
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# clean up temporary files
|
||||
[[ -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
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with formatted stanzas:
|
||||
incl:<full path>
|
||||
excl:<full path>
|
||||
PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes
|
||||
of files and directories (automatically expanded). Excludes have a higher
|
||||
priority than includes. Integrity checks will only be performed on 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:
|
||||
use only direct file references in the configuration file. Uses by preference
|
||||
openssl for hash calculation, with cksum as fall-back).
|
||||
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.
|
||||
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.
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_fs_mounts.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_fs_mounts
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-15: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_fs_mounts
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2013-05-15" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _FS=""
|
||||
typeset _FS_COUNT=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# collect data (mount & lsfs output may be safely merged)
|
||||
mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? == 0)) || return $?
|
||||
lsfs -ac >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? == 0)) || return $?
|
||||
|
||||
# check for each auto-mount configured file system (except /)
|
||||
lsfs -ac |\
|
||||
grep -v -E -e '^#' -e '^\/:' |\
|
||||
grep -E -e '.*:.*:.*:.*:.*:.*:.*:yes:.*' |\
|
||||
cut -f1 -d':' |\
|
||||
while read _FS
|
||||
do
|
||||
_FS_COUNT=$(grep -c -E -e ".*[ \t]*+${_FS}[ \t].*" ${HC_STDOUT_LOG} 2>/dev/null)
|
||||
case ${_FS_COUNT} in
|
||||
0)
|
||||
_MSG="${_FS} is not mounted"
|
||||
_STC=1
|
||||
;;
|
||||
1)
|
||||
_MSG="${_FS} is mounted"
|
||||
;;
|
||||
*)
|
||||
_MSG="${_FS} is multiple times mounted?"
|
||||
;;
|
||||
esac
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether file systems are mounted or not {lsfs/mount}
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_lppchk.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_lppchk
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-17: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_lppchk
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2013-05-17" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# collect data
|
||||
lppchk -v -m1 >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? == 0)) || return $?
|
||||
|
||||
# perform check
|
||||
if [[ -s ${HC_STDOUT_LOG} ]]
|
||||
then
|
||||
_MSG="lppchk detected errors {lppchk -v -m1}"
|
||||
_STC=1
|
||||
else
|
||||
_MSG="lppchk passed without errors"
|
||||
fi
|
||||
|
||||
# handle results
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Run {lppchk -v}
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_paths.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_paths
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-07: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_paths
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2013-05-07" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _PATH=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# collect data
|
||||
lspath >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? == 0)) || return $?
|
||||
|
||||
# perform check
|
||||
_PATH=$(grep -v -c "Enabled" ${HC_STDOUT_LOG} 2>/dev/null)
|
||||
case ${_PATH} in
|
||||
0)
|
||||
_MSG="all paths are enabled"
|
||||
;;
|
||||
*)
|
||||
_MSG="failure in some paths detected {lspath}"
|
||||
_STC=1
|
||||
;;
|
||||
esac
|
||||
|
||||
# handle results
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether any hardware paths are missing {lspath}
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_root_crontab
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_root_crontab
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-09-19: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_root_crontab
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2013-09-19" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _CRON_ENTRY=""
|
||||
typeset _CRON_MATCH=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# handle configuration file
|
||||
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||
then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# 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
|
||||
do
|
||||
_CRON_MATCH=$(grep -v '^#' ${HC_STDOUT_LOG} 2>/dev/null |\
|
||||
grep -c -E -e "${_CRON_ENTRY}")
|
||||
case ${_CRON_MATCH} in
|
||||
0)
|
||||
_MSG="'${_CRON_ENTRY}' is not configured in cron"
|
||||
_STC=1
|
||||
;;
|
||||
1)
|
||||
_MSG="'${_CRON_ENTRY}' is configured in cron"
|
||||
;;
|
||||
+([0-9])*([0-9]))
|
||||
_MSG="'${_CRON_ENTRY}' is configured multiple times in cron"
|
||||
;;
|
||||
esac
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks the content of the 'root' user crontab for required entries
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_subsystems.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_subsystems
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-07: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_subsystems
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2013-05-07" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _STATUS=""
|
||||
|
||||
# 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
|
||||
|
||||
# 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
|
||||
do
|
||||
_STATUS="$(grep -E -e ${_SUBSYS} ${HC_STDOUT_LOG} 2>/dev/null)"
|
||||
case "${_STATUS}" in
|
||||
*active*)
|
||||
_MSG="${_SUBSYS} is running"
|
||||
;;
|
||||
*inoperative*)
|
||||
_MSG="${_SUBSYS} is not running"
|
||||
_STC=1
|
||||
;;
|
||||
*)
|
||||
_MSG="${_SUBSYS} is not on file"
|
||||
;;
|
||||
esac
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
subsys1
|
||||
subsys2
|
||||
PURPOSE : Checks whether subsystem(s) are active/operative {lssrc}
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,194 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_sysbackup.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_sysbackup
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-28: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_sysbackup
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
# mksysb identifier prefix of error code(s)
|
||||
typeset _MKSYSB_NEEDLE="^0512"
|
||||
typeset _VERSION="2013-05-28" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _BACKUP_PATH=""
|
||||
typeset _BACKUP_HOST=""
|
||||
typeset _BACKUP_LOG=""
|
||||
typeset _BACKUP_AGE=0
|
||||
typeset _MKSYSB_LOG=""
|
||||
typeset _MKSYSB_CODE=""
|
||||
typeset _COUNT=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# handle configuration file
|
||||
[[ -n "${ARG_CONFIG_FILE}" ]] && _CONFIG_FILE="${ARG_CONFIG_FILE}"
|
||||
if [[ ! -r ${_CONFIG_FILE} ]]
|
||||
then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
# read required configuration values
|
||||
_BACKUP_PATH=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'backup_path')
|
||||
if [[ -z "${_BACKUP_PATH}" ]]
|
||||
then
|
||||
warn "ERROR: no value for the _BACKUP_PATH setting in ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
if [[ ! -d ${_BACKUP_PATH} ]]
|
||||
then
|
||||
warn "ERROR: ${_BACKUP_PATH} does not exist"
|
||||
return 1
|
||||
fi
|
||||
_MKSYSB_LOG=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mksysb_log')
|
||||
if [[ -z "${_MKSYSB_LOG}" ]]
|
||||
then
|
||||
warn "ERROR: no value for the _MKSYSB_LOG setting in ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
_BACKUP_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'backup_age')
|
||||
case "${_BACKUP_AGE}" in
|
||||
+([0-9])*(.)*([0-9]))
|
||||
# numeric, OK
|
||||
;;
|
||||
*)
|
||||
# not numeric, set default
|
||||
_BACKUP_AGE=14
|
||||
;;
|
||||
esac
|
||||
|
||||
# perform state check on mksysb log files
|
||||
ls -1 ${_BACKUP_PATH} | while read _BACKUP_HOST
|
||||
do
|
||||
_BACKUP_LOG="${_BACKUP_PATH}/${_BACKUP_HOST}/curr/${_MKSYSB_LOG}"
|
||||
if [[ -r "${_BACKUP_LOG}" ]]
|
||||
then
|
||||
# read status from log file
|
||||
_MKSYSB_CODE=$(grep -E -e "${_MKSYSB_NEEDLE}" ${_BACKUP_LOG} 2>/dev/null)
|
||||
case "${_MKSYSB_CODE}" in
|
||||
# 0512-038 mksysb: Backup Completed Successfully
|
||||
0512-038*)
|
||||
_MSG="sysbackup status for ${_BACKUP_HOST}: completed successfully"
|
||||
;;
|
||||
# 0512-003 mksysb may not have been able to archive some files
|
||||
0512-003*)
|
||||
_MSG="sysbackup status for ${_BACKUP_HOST}: completed with warnings"
|
||||
# save log
|
||||
print "=== ${_BACKUP_HOST} ===" >>${HC_STDOUT_LOG}
|
||||
cat ${_BACKUP_LOG} >>${HC_STDOUT_LOG}
|
||||
;;
|
||||
*)
|
||||
_MSG="sysbackup status for ${_BACKUP_HOST}: failed"
|
||||
_STC=1
|
||||
print "=== ${_BACKUP_HOST} ===" >>${HC_STDOUT_LOG}
|
||||
cat ${_BACKUP_LOG} >>${HC_STDOUT_LOG}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
# don't flag this as erroneous, we could drop into this fork for
|
||||
# VIO servers for example without mksysb but having backupios instead
|
||||
# caveat emptor: also means that hosts *without* backup go undetected
|
||||
continue
|
||||
fi
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done
|
||||
|
||||
# perform age check on mksysb log files
|
||||
ls -1 ${_BACKUP_PATH} | while read _BACKUP_HOST
|
||||
do
|
||||
_BACKUP_LOG="${_BACKUP_PATH}/${_BACKUP_HOST}/curr/${_MKSYSB_LOG}"
|
||||
if [[ -r "${_BACKUP_LOG}" ]]
|
||||
then
|
||||
_COUNT=$(find "${_BACKUP_LOG}" -mtime +${_BACKUP_AGE} | wc -l)
|
||||
if (( _COUNT == 0 ))
|
||||
then
|
||||
_MSG="sysbackup age for ${_BACKUP_HOST}: <=${_BACKUP_AGE} days"
|
||||
_STC=0
|
||||
else
|
||||
_MSG="sysbackup age for ${_BACKUP_HOST}: >${_BACKUP_AGE} days"
|
||||
_STC=1
|
||||
print "=== ${_BACKUP_HOST} ===" >>${HC_STDOUT_LOG}
|
||||
print "age: $(ls -l ${_BACKUP_LOG})" >>${HC_STDOUT_LOG}
|
||||
fi
|
||||
else
|
||||
# don't flag this as erroneous, we could drop into this fork for
|
||||
# VIO servers for example without mksysb but having backupios instead
|
||||
# caveat emptor: also means that hosts *without* backup go undetected
|
||||
continue
|
||||
fi
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
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)
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_aix_topasrec.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2014 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_aix_topasrec
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-07: initial version [Patrick Van der Veken]
|
||||
# @(#) 2013-08-16: comparison fix [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_aix_topasrec
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2013-08-16" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _TOPAS=0
|
||||
typeset _NMON=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# collect data
|
||||
topasrec -l >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? == 0 )) || return $?
|
||||
|
||||
# perform check
|
||||
_TOPAS=$(grep -c "bin" ${HC_STDOUT_LOG} 2>/dev/null)
|
||||
_NMON=$(grep -c "nmon" ${HC_STDOUT_LOG} 2>/dev/null)
|
||||
_MSG="process checks: nmon=${_NMON}; topasrec=${_TOPAS}"
|
||||
if (( _NMON != 1 || _TOPAS != 1 ))
|
||||
then
|
||||
_STC=1
|
||||
fi
|
||||
|
||||
# handle results
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks on the active topasrec/nmon processes (only 1 should be running)
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
Reference in New Issue
Block a user