Added code for support of fix/healing logic. Command-line opion --no-fix & global var ARG_NO_FIX
This commit is contained in:
parent
a4868cda09
commit
8e779b6062
@ -38,7 +38,7 @@
|
||||
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
# define the version (YYYY-MM-DD)
|
||||
typeset -r SCRIPT_VERSION="2019-05-19"
|
||||
typeset -r SCRIPT_VERSION="2019-06-18"
|
||||
# location of parent directory containing KSH functions/HC plugins
|
||||
typeset -r FPATH_PARENT="/opt/hc/lib"
|
||||
# location of custom HC configuration files
|
||||
@ -134,6 +134,7 @@ typeset ARG_LAST=0 # report last events
|
||||
typeset ARG_LIST="" # list all by default
|
||||
typeset ARG_LOCK=1 # lock for concurrent script executions is on by default
|
||||
typeset ARG_LOG=1 # logging is on by default
|
||||
typeset ARG_NO_FIX=0 # fix/healing is not disabled by default
|
||||
typeset ARG_LOG_HEALTHY=0 # logging of healthy health checks is off by default
|
||||
typeset ARG_MONITOR=1 # killing long running HC processes is on by default
|
||||
typeset ARG_NEWER=""
|
||||
@ -543,7 +544,7 @@ Execute/report simple health checks (HC) on UNIX hosts.
|
||||
Syntax: ${SCRIPT_DIR}/${SCRIPT_NAME} [--help] | [--help-terse] | [--version] |
|
||||
[--list=<needle>] | [--list-core] | [--list-include] | [--fix-symlinks] | [--show-stats] | (--archive-all | --disable-all | --enable-all) | [--fix-logs [--with-history]] |
|
||||
(--check-host | ((--archive | --check | --enable | --disable | --run [--timeout=<secs>] | --show) --hc=<list_of_checks> [--config-file=<configuration_file>] [hc-args="<arg1,arg2=val,arg3">]))
|
||||
[--display=<method>] ([--debug] [--debug-level=<level>]) [--log-healthy] [--no-monitor] [--no-log] [--no-lock] [[--flip-rc] [--with-rc=<count|max|sum>]]]
|
||||
[--display=<method>] ([--debug] [--debug-level=<level>]) [--log-healthy] [--no-fix] [--no-log] [--no-lock] [--no-monitor] [[--flip-rc] [--with-rc=<count|max|sum>]]]
|
||||
[--notify=<method_list>] [--mail-to=<address_list>] [--sms-to=<sms_rcpt> --sms-provider=<name>]
|
||||
[--report=<method> [--with-history] ( ([--last] | [--today]) | [(--older|--newer)=<date>] | [--reverse] [--id=<fail_id> [--detail]] )]
|
||||
|
||||
@ -588,6 +589,7 @@ Parameters:
|
||||
(can be overridden by --no-log to disable all logging)
|
||||
--mail-to : list of e-mail address(es) to which an e-mail alert will be send to [requires mail core plugin]
|
||||
--newer : show the (failed) events for each HC that are newer than the given date
|
||||
--no-fix : do not apply fix/healing logic for failed health checks (if available)
|
||||
--no-lock : disable locking to allow concurrent script executions
|
||||
--no-log : do not log any messages to the script log file or health check results.
|
||||
--no-monitor : do not stop the execution of a HC after \$HC_TIME_OUT seconds
|
||||
@ -952,8 +954,13 @@ do
|
||||
# shellcheck disable=SC2034
|
||||
ARG_NOTIFY="${CMD_PARAMETER#--notify=}"
|
||||
;;
|
||||
-no-fix|--no-fix)
|
||||
ARG_NO_FIX=1
|
||||
;;
|
||||
-no-log|--no-log)
|
||||
ARG_LOG=0
|
||||
# --no-log always means --no-fix!
|
||||
ARG_NO_FIX=1
|
||||
;;
|
||||
-no-lock|--no-lock)
|
||||
ARG_LOCK=0
|
||||
|
@ -30,7 +30,7 @@
|
||||
# RETURNS: 0
|
||||
function version_include_core
|
||||
{
|
||||
typeset _VERSION="2019-05-19" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-06-18" # YYYY-MM-DD
|
||||
|
||||
print "INFO: $0: ${_VERSION#version_*}"
|
||||
|
||||
@ -1569,6 +1569,7 @@ typeset FCONFIG=""
|
||||
typeset FSTATE=""
|
||||
typeset FFILE=""
|
||||
typeset FHEALTHY=""
|
||||
typeset FFIX=0
|
||||
typeset FSCHEDULED=0
|
||||
typeset FSCRIPT=""
|
||||
typeset HAS_FCONFIG=0
|
||||
@ -1587,9 +1588,9 @@ fi
|
||||
if [[ "${FACTION}" != "list" ]]
|
||||
then
|
||||
# shellcheck disable=SC1117
|
||||
printf "%-40s\t%-8s\t%s\t\t%s\t%s\t%s\n" "Health Check" "State" "Version" "Config?" "Sched?" "H+?"
|
||||
printf "%-40s\t%-8s\t%s\t\t%s\t%s\t%s\t%s\n" "Health Check" "State" "Version" "Config?" "Sched?" "H+?" "Fix?"
|
||||
# shellcheck disable=SC2183,SC1117
|
||||
printf "%100s\n" | tr ' ' -
|
||||
printf "%110s\n" | tr ' ' -
|
||||
fi
|
||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep -v "core$" 2>/dev/null | sort 2>/dev/null |\
|
||||
while read -r FDIR
|
||||
@ -1654,6 +1655,13 @@ do
|
||||
FCONFIG="No"
|
||||
FHEALTHY="N/S"
|
||||
fi
|
||||
# check fix
|
||||
if (( $(print -R "${FSCRIPT}" | grep -c -E -e "_HC_CAN_FIX=1" 2>/dev/null) > 0 ))
|
||||
then
|
||||
FFIX="Yes"
|
||||
else
|
||||
FFIX="No"
|
||||
fi
|
||||
# check state
|
||||
DISABLE_FFILE="$(print ${FFILE##*/} | sed 's/\.sh$//')"
|
||||
if [[ -f "${STATE_PERM_DIR}/${DISABLE_FFILE}.disabled" ]]
|
||||
@ -1678,13 +1686,14 @@ do
|
||||
if [[ "${FACTION}" != "list" ]]
|
||||
then
|
||||
# shellcheck disable=SC1117
|
||||
printf "%-40s\t%-8s\t%s\t%s\t%s\t%s\n" \
|
||||
printf "%-40s\t%-8s\t%s\t%s\t%s\t%s\t%s\n" \
|
||||
"${FNAME#function *}" \
|
||||
"${FSTATE}" \
|
||||
"${FVERSION#typeset _VERSION=*}" \
|
||||
"${FCONFIG}" \
|
||||
"${FSCHEDULED}" \
|
||||
"${FHEALTHY}"
|
||||
"${FHEALTHY}" \
|
||||
"${FFIX}"
|
||||
else
|
||||
# shellcheck disable=SC1117
|
||||
printf "%s\n" "${FNAME#function *}"
|
||||
@ -1723,6 +1732,7 @@ then
|
||||
print "Config?: plugin has a default configuration file (Yes/No)"
|
||||
print "Sched? : plugin is scheduled through cron (Yes/No)"
|
||||
print "H+? : plugin can choose whether to log/show passed health checks (Yes/No/Supported/Not supported)"
|
||||
print "Fix? : plugin contains fix/healing logic (Yes/No) -- not used by default!"
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user