Fixed (linter) issues
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
# @(#) 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]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@@ -33,7 +34,7 @@
|
||||
function check_aix_errpt
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2013-06-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-10-28" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@@ -47,7 +48,6 @@ typeset _STC=0
|
||||
typeset _LAST_TIME_CHECK=""
|
||||
typeset _LAST_TIME_FILE=""
|
||||
typeset _LABEL=""
|
||||
typeset _IDENTIFIER=""
|
||||
typeset _NEW_CHECK_TIME=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
@@ -56,7 +56,7 @@ do
|
||||
case "${_ARG}" in
|
||||
help)
|
||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||
;;
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@@ -66,7 +66,7 @@ if [[ -r ${_LAST_TIME_FILE} ]]
|
||||
then
|
||||
if [[ -s ${_LAST_TIME_FILE} ]]
|
||||
then
|
||||
_LAST_TIME_CHECK="<${_LAST_TIME_FILE})"
|
||||
_LAST_TIME_CHECK="<${_LAST_TIME_FILE})"
|
||||
else
|
||||
warn "$0: no last known check date/time"
|
||||
fi
|
||||
@@ -100,12 +100,12 @@ fi
|
||||
# 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}" ]]
|
||||
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)"
|
||||
warn "$0: no last check time received from errpt (no entries)"
|
||||
fi
|
||||
|
||||
# handle results
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-27: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@@ -32,7 +33,7 @@ function check_aix_file_age
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2013-05-27" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-10-28" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@@ -44,7 +45,7 @@ typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _ENTRY=""
|
||||
typeset _AGE_CHECK==""
|
||||
typeset _AGE_CHECK=""
|
||||
typeset _FILE_PATH=""
|
||||
typeset _FILE_AGE=""
|
||||
typeset _FILE_NAME=""
|
||||
@@ -56,57 +57,57 @@ 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} ]]
|
||||
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%/*})"
|
||||
|
||||
_FILE_NAME="$(print ${_FILE_PATH##*/})"
|
||||
_FILE_DIR="$(print ${_FILE_PATH%/*})"
|
||||
|
||||
# check config
|
||||
if [ \( -z "${_FILE_PATH}" \) -a \( -z "${_FILE_AGE}" \) ]
|
||||
if [[ -z "${_FILE_PATH}" ]] && [[ -z "${_FILE_AGE}" ]]
|
||||
then
|
||||
warn "missing values in configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
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
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# perform check
|
||||
if [[ ! -r "${_FILE_PATH}" ]]
|
||||
then
|
||||
_MSG="unable to read or access requested file at ${_FILE_PATH}"
|
||||
_STC=1
|
||||
_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
|
||||
return 1
|
||||
fi
|
||||
if [[ -z "${_AGE_CHECK}" ]]
|
||||
then
|
||||
@@ -116,7 +117,7 @@ do
|
||||
_MSG="file age of ${_FILE_AGE} has not expired on ${_FILE_PATH}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
_STC=0
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-05-18: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@@ -33,7 +34,7 @@ function check_aix_file_change
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2017-05-18" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-10-28" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@@ -44,7 +45,6 @@ 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=""
|
||||
@@ -65,11 +65,13 @@ typeset _TMP_EXCL_FILE="${TMP_DIR}/.$0.tmp_excl.$$"
|
||||
set -o noglob # no file globbing
|
||||
|
||||
# set local trap for clean-up
|
||||
# shellcheck disable=SC2064
|
||||
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
|
||||
# shellcheck disable=SC2064
|
||||
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;
|
||||
@@ -133,6 +135,7 @@ fi
|
||||
|
||||
# check state file & TMP_FILEs
|
||||
[[ -r ${_STATE_FILE} ]] || {
|
||||
# shellcheck disable=SC2188
|
||||
>${_STATE_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create new state file at ${_STATE_FILE}"
|
||||
@@ -140,21 +143,25 @@ fi
|
||||
}
|
||||
log "created new state file at ${_STATE_FILE}"
|
||||
}
|
||||
# shellcheck disable=SC2188
|
||||
>${_TMP_INCL_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP_INCL_FILE}"
|
||||
return 1
|
||||
}
|
||||
# shellcheck disable=SC2188
|
||||
>${_TMP_EXCL_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP_EXCL_FILE}"
|
||||
return 1
|
||||
}
|
||||
# shellcheck disable=SC2188
|
||||
>${_TMP1_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP1_FILE}"
|
||||
return 1
|
||||
}
|
||||
# shellcheck disable=SC2188
|
||||
>${_TMP2_FILE}
|
||||
(( $? > 0 )) && {
|
||||
warn "failed to create temporary file at ${_TMP2_FILE}"
|
||||
@@ -163,7 +170,7 @@ fi
|
||||
|
||||
# build list of configured objects: inclusion
|
||||
grep -i '^incl:' ${_CONFIG_FILE} 2>/dev/null |\
|
||||
while IFS=':' read _DUMMY _INCL_OBJECT
|
||||
while IFS=':' read _ _INCL_OBJECT
|
||||
do
|
||||
# check for meta & globbing characters (*?[]{}|)
|
||||
if (( _DO_META_CHECK == 1 ))
|
||||
@@ -187,7 +194,7 @@ done
|
||||
|
||||
# build list of configured objects: exclusion
|
||||
grep -i '^excl:' ${_CONFIG_FILE} 2>/dev/null |\
|
||||
while IFS=':' read _DUMMY _EXCL_OBJECT
|
||||
while IFS=':' read _ _EXCL_OBJECT
|
||||
do
|
||||
# check for meta & globbing characters (*?[]{}|)
|
||||
if (( _DO_META_CHECK == 1 ))
|
||||
@@ -337,12 +344,6 @@ then
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user