Code cleanup

This commit is contained in:
patvdv
2018-11-04 19:57:20 +01:00
parent 0e6469e477
commit ba8f336945
78 changed files with 395 additions and 393 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -38,7 +38,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -104,7 +104,7 @@ do
_STC=1
else
_AGE_CHECK=$(find "${_FILE_DIR}" -type f -name "${_FILE_NAME}" -mmin -"${_FILE_AGE}")
if (( $? != 0 ))
if (( $? > 0 ))
then
warn "unable to execute file age test for ${_FILE_PATH}"
return 1
@@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -297,7 +297,7 @@ do
fi
# bounce failures back and jump to next file
if (( _STC != 0 ))
if (( _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}"
continue
@@ -327,7 +327,7 @@ do
done <${_TMP1_FILE}
# update state file (also if TMP2_FILE is empty)
if (( ARG_LOG != 0 ))
if (( ARG_LOG > 0 ))
then
[[ -s ${_TMP2_FILE} ]] || {
warn "no files found to check, zeroing new state file"
@@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -51,7 +51,7 @@ do
case "${_ARG}" in
help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;;
;;
esac
done
@@ -79,9 +79,9 @@ do
;;
*)
_MSG="${_FS} is multiple times mounted?"
;;
;;
esac
# handle unit result
log_hc "$0" ${_STC} "${_MSG}"
_STC=0
+2 -2
View File
@@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -49,7 +49,7 @@ do
case "${_ARG}" in
help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;;
;;
esac
done
+3 -3
View File
@@ -36,7 +36,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -50,7 +50,7 @@ do
case "${_ARG}" in
help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;;
;;
esac
done
@@ -69,7 +69,7 @@ case ${_PATH} in
_STC=1
;;
esac
# handle results
log_hc "$0" ${_STC} "${_MSG}"
@@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -52,14 +52,14 @@ 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
@@ -77,15 +77,15 @@ do
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
@@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -51,14 +51,14 @@ 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
@@ -82,9 +82,9 @@ do
;;
*)
_MSG="${_SUBSYS} is not on file"
;;
;;
esac
# handle unit result
log_hc "$0" ${_STC} "${_MSG}"
_STC=0
+16 -16
View File
@@ -17,7 +17,7 @@
# DOCUMENTATION (MAIN)
# -----------------------------------------------------------------------------
# @(#) MAIN: check_aix_sysbackup
# DOES: see _show_usage()
# DOES: see _show_usage()
# EXPECTS: see _show_usage()
# REQUIRES: data_space2comma(), init_hc(), log_hc()
#
@@ -39,7 +39,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -59,13 +59,13 @@ 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
@@ -93,7 +93,7 @@ case "${_BACKUP_AGE}" in
+([0-9])*(.)*([0-9]))
# numeric, OK
;;
*)
*)
# not numeric, set default
_BACKUP_AGE=14
;;
@@ -118,21 +118,21 @@ do
# 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
# 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
@@ -148,25 +148,25 @@ do
if (( _COUNT == 0 ))
then
_MSG="sysbackup age for ${_BACKUP_HOST}: <=${_BACKUP_AGE} days"
_STC=0
_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}
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
# 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
}
@@ -180,9 +180,9 @@ 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
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)
do NOT run on a typical client LPAR)
EOT
@@ -37,7 +37,7 @@ typeset _SUPPORTED_PLATFORMS="AIX" # uname -s match
# ------------------------- CONFIGURATION ends here ---------------------------
# set defaults
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
typeset _ARGS=$(data_space2comma "$*")
typeset _ARG=""
@@ -52,7 +52,7 @@ do
case "${_ARG}" in
help)
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
;;
;;
esac
done
@@ -64,11 +64,11 @@ topasrec -l >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
_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 ))
if (( _NMON > 1 || _TOPAS > 1 ))
then
_STC=1
fi
# handle results
log_hc "$0" ${_STC} "${_MSG}"