* Added feature for mass archiving (--archive-all)
* Smaller fixes in HP-UX plugins
This commit is contained in:
parent
a642cdf32d
commit
ef266c72e6
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
# define the version (YYYY-MM-DD)
|
# define the version (YYYY-MM-DD)
|
||||||
typeset -r SCRIPT_VERSION="2019-02-10"
|
typeset -r SCRIPT_VERSION="2019-02-13"
|
||||||
# location of parent directory containing KSH functions/HC plugins
|
# location of parent directory containing KSH functions/HC plugins
|
||||||
typeset -r FPATH_PARENT="/opt/hc/lib"
|
typeset -r FPATH_PARENT="/opt/hc/lib"
|
||||||
# location of custom HC configuration files
|
# location of custom HC configuration files
|
||||||
@ -86,6 +86,11 @@ typeset EXIT_CODE=0
|
|||||||
typeset FDIR=""
|
typeset FDIR=""
|
||||||
typeset FFILE=""
|
typeset FFILE=""
|
||||||
typeset FPATH=""
|
typeset FPATH=""
|
||||||
|
typeset HC_ARCHIVE=""
|
||||||
|
typeset HC_CHECK=""
|
||||||
|
typeset HC_DISABLE=""
|
||||||
|
typeset HC_ENABLE=""
|
||||||
|
typeset HC_RUN=""
|
||||||
typeset HC_FAIL_ID=""
|
typeset HC_FAIL_ID=""
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
typeset HC_FILE_LINE=""
|
typeset HC_FILE_LINE=""
|
||||||
@ -370,14 +375,14 @@ if (( ARG_CHECK_HOST == 0 ))
|
|||||||
then
|
then
|
||||||
if (( ARG_ACTION < 6 || ARG_ACTION == 10 )) && [[ -z "${ARG_HC}" ]]
|
if (( ARG_ACTION < 6 || ARG_ACTION == 10 )) && [[ -z "${ARG_HC}" ]]
|
||||||
then
|
then
|
||||||
print -u2 "ERROR: you specify a value for parameter '--hc'"
|
print -u2 "ERROR: you must specify a value for the '--hc' parameter"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if (( ARG_ACTION == 5 )) || [[ -n "${ARG_HC_ARGS}" ]]
|
if (( ARG_ACTION == 5 )) || [[ -n "${ARG_HC_ARGS}" ]]
|
||||||
then
|
then
|
||||||
case "${ARG_HC}" in
|
case "${ARG_HC}" in
|
||||||
*,*)
|
*,*)
|
||||||
print -u2 "ERROR: you can only specify a value for '--hc' in combination with '--show'"
|
print -u2 "ERROR: you can only specify a single value for '--hc' in combination with '--show'"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -386,7 +391,7 @@ then
|
|||||||
then
|
then
|
||||||
case "${ARG_HC}" in
|
case "${ARG_HC}" in
|
||||||
*,*)
|
*,*)
|
||||||
print -u2 "ERROR: you can only specify a value for '--hc' in combination with '--archive'"
|
print -u2 "ERROR: you can only specify a single value for '--hc' in combination with '--archive'"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -534,7 +539,7 @@ cat << EOT
|
|||||||
Execute/report simple health checks (HC) on UNIX hosts.
|
Execute/report simple health checks (HC) on UNIX hosts.
|
||||||
|
|
||||||
Syntax: ${SCRIPT_DIR}/${SCRIPT_NAME} [--help] | [--help-terse] | [--version] |
|
Syntax: ${SCRIPT_DIR}/${SCRIPT_NAME} [--help] | [--help-terse] | [--version] |
|
||||||
[--list=<needle>] | [--list-core] | [--fix-symlinks] | [--show-stats] | (--disable-all | enable-all) | [--fix-logs [--with-history]] |
|
[--list=<needle>] | [--list-core] | [--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">]))
|
(--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]
|
[--display=<method>] ([--debug] [--debug-level=<level>]) [--log-healthy] [--no-monitor] [--no-log] [--no-lock] [--flip-rc]
|
||||||
[--notify=<method_list>] [--mail-to=<address_list>] [--sms-to=<sms_rcpt> --sms-provider=<name>]
|
[--notify=<method_list>] [--mail-to=<address_list>] [--sms-to=<sms_rcpt> --sms-provider=<name>]
|
||||||
@ -547,7 +552,8 @@ then
|
|||||||
cat << EOT
|
cat << EOT
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
--archive : move events from the HC log file into archive log files
|
--archive : move events from the HC log file into archive log files (one HC)
|
||||||
|
--archive-all : move events for all HCs from the HC log file into archive log files
|
||||||
--check : display HC state.
|
--check : display HC state.
|
||||||
--check-host : execute all configured HC(s) (see check_host.conf)
|
--check-host : execute all configured HC(s) (see check_host.conf)
|
||||||
--config-file : custom configuration file for a HC (may only be specified when executing a single HC plugin)
|
--config-file : custom configuration file for a HC (may only be specified when executing a single HC plugin)
|
||||||
@ -726,6 +732,15 @@ do
|
|||||||
fi
|
fi
|
||||||
ARG_LOCK=1
|
ARG_LOCK=1
|
||||||
;;
|
;;
|
||||||
|
-archive-all|--archive-all)
|
||||||
|
if (( ARG_ACTION > 0 ))
|
||||||
|
then
|
||||||
|
print -u2 "ERROR: you cannot request two actions at the same time"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
ARG_ACTION=13
|
||||||
|
fi
|
||||||
|
;;
|
||||||
-check|--check)
|
-check|--check)
|
||||||
ARG_ACTION=1
|
ARG_ACTION=1
|
||||||
;;
|
;;
|
||||||
@ -1351,9 +1366,9 @@ case ${ARG_ACTION} in
|
|||||||
9) # list HC plugins
|
9) # list HC plugins
|
||||||
list_hc "" "${ARG_LIST}"
|
list_hc "" "${ARG_LIST}"
|
||||||
;;
|
;;
|
||||||
10) # archive log entries
|
10) # archive current log entries for a HC
|
||||||
exists_hc "${ARG_HC}" && die "cannot find HC: ${ARG_HC}"
|
exists_hc "${ARG_HC}" && die "cannot find HC: ${ARG_HC}"
|
||||||
log "archiving log entries for ${ARG_HC}..."
|
log "archiving current log entries for ${ARG_HC}..."
|
||||||
archive_hc "${ARG_HC}"
|
archive_hc "${ARG_HC}"
|
||||||
ARCHIVE_RC=$?
|
ARCHIVE_RC=$?
|
||||||
case ${ARCHIVE_RC} in
|
case ${ARCHIVE_RC} in
|
||||||
@ -1389,6 +1404,28 @@ case ${ARG_ACTION} in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
13) # archive current log entries for all HCs
|
||||||
|
list_hc "list" | while read -r HC_ARCHIVE
|
||||||
|
do
|
||||||
|
# check for HC (function)
|
||||||
|
exists_hc "${HC_ARCHIVE}" && die "cannot find HC: ${HC_ARCHIVE}"
|
||||||
|
log "archiving current log entries for HC: ${HC_ARCHIVE}"
|
||||||
|
archive_hc "${HC_ARCHIVE}"
|
||||||
|
ARCHIVE_RC=$?
|
||||||
|
case ${ARCHIVE_RC} in
|
||||||
|
0)
|
||||||
|
log "no archiving needed for ${HC_ARCHIVE}"
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
log "successfully archived log entries for ${HC_ARCHIVE}"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
log "failed to archive log entries for ${HC_ARCHIVE} [RC=${ARCHIVE_RC}]"
|
||||||
|
EXIT_CODE=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# finish up work
|
# finish up work
|
||||||
|
@ -22,7 +22,8 @@
|
|||||||
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2018-02-08: initial version [Patrick Van der Veken]
|
# @(#) 2018-02-08: initial version [Patrick Van der Veken]µ
|
||||||
|
# @(#) 2018-02-13: fix to avoid log check if cron is not active [Patrick Van der Veken]
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -33,7 +34,7 @@ function check_hpux_cron_status
|
|||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CRON_LOG_FILE="/var/adm/cron/log"
|
typeset _CRON_LOG_FILE="/var/adm/cron/log"
|
||||||
typeset _WAIT_TIME=10
|
typeset _WAIT_TIME=10
|
||||||
typeset _VERSION="2019-02-08" # YYYY-MM-DD
|
typeset _VERSION="2019-02-13" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -92,6 +93,8 @@ esac
|
|||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
# return if cron is not running
|
||||||
|
(( _STC > 0 )) && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---- log state ----
|
# ---- log state ----
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2018-02-08: initial version [Patrick Van der Veken]
|
# @(#) 2018-02-08: initial version [Patrick Van der Veken]
|
||||||
|
# @(#) 2018-02-13: fix to avoid log check if syslogd is not active [Patrick Van der Veken]
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -33,7 +34,7 @@ function check_hpux_syslogd_status
|
|||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _SYSLOGD_PID_FILE="/var/run/syslog.pid"
|
typeset _SYSLOGD_PID_FILE="/var/run/syslog.pid"
|
||||||
typeset _SYSLOGD_LOG_FILE="/var/adm/syslog.log"
|
typeset _SYSLOGD_LOG_FILE="/var/adm/syslog.log"
|
||||||
typeset _VERSION="2019-02-08" # YYYY-MM-DD
|
typeset _VERSION="2019-02-13" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -113,6 +114,8 @@ esac
|
|||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
|
# return if syslogd is not running
|
||||||
|
(( _STC > 0 )) && return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---- log state ----
|
# ---- log state ----
|
||||||
|
Loading…
x
Reference in New Issue
Block a user