Added --log-healthy
This commit is contained in:
parent
fff83cf99c
commit
67bdb33436
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
# define the version (YYYY-MM-DD)
|
# define the version (YYYY-MM-DD)
|
||||||
typeset -r SCRIPT_VERSION="2018-05-29"
|
typeset -r SCRIPT_VERSION="2018-07-12"
|
||||||
# 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
|
||||||
@ -115,6 +115,7 @@ typeset ARG_LAST=0 # report last events
|
|||||||
typeset ARG_LIST="" # list all by default
|
typeset ARG_LIST="" # list all by default
|
||||||
typeset ARG_LOCK=1 # lock for concurrent script executions is on 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_LOG=1 # logging is on 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_MONITOR=1 # killing long running HC processes is on by default
|
||||||
typeset ARG_NOTIFY="" # notification of problems is off by default
|
typeset ARG_NOTIFY="" # notification of problems is off by default
|
||||||
typeset ARG_REVERSE=0 # show report in reverse date order is off by default
|
typeset ARG_REVERSE=0 # show report in reverse date order is off by default
|
||||||
@ -414,7 +415,12 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
# --log-healthy
|
||||||
|
if (( ARG_LOG_HEALTHY > 0 && ARG_ACTION != 4 ))
|
||||||
|
then
|
||||||
|
print -u2 "ERROR: you can only use '--log-healthy' in combination with '--run'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
# check log location
|
# check log location
|
||||||
if (( ARG_LOG != 0 ))
|
if (( ARG_LOG != 0 ))
|
||||||
then
|
then
|
||||||
@ -514,7 +520,7 @@ 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] | (--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>]) [--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>]
|
||||||
[--report=<method> ( ([--last] | [--today]) | ([--reverse] [--id=<fail_id> [--detail]] [--with-history]) ) ]
|
[--report=<method> ( ([--last] | [--today]) | ([--reverse] [--id=<fail_id> [--detail]] [--with-history]) ) ]
|
||||||
|
|
||||||
@ -553,6 +559,8 @@ Parameters:
|
|||||||
- whether the HC plugin requires a configuration file in ${HC_ETC_DIR}
|
- whether the HC plugin requires a configuration file in ${HC_ETC_DIR}
|
||||||
- whether the HC plugin is scheduled by cron
|
- whether the HC plugin is scheduled by cron
|
||||||
--list-core : show the available core plugins (mail,SMS,...)
|
--list-core : show the available core plugins (mail,SMS,...)
|
||||||
|
--log-healthy : log/show also passed health checks. By default this is off when the plugin support this feature.
|
||||||
|
(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]
|
--mail-to : list of e-mail address(es) to which an e-mail alert will be send to [requires mail core plugin]
|
||||||
--no-lock : disable locking to allow concurrent script executions
|
--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-log : do not log any messages to the script log file or health check results.
|
||||||
@ -873,6 +881,9 @@ do
|
|||||||
list_core
|
list_core
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
-log-healthy|--log-healthy)
|
||||||
|
ARG_LOG_HEALTHY=1
|
||||||
|
;;
|
||||||
-mail-to=*)
|
-mail-to=*)
|
||||||
ARG_MAIL_TO="${CMD_PARAMETER#-mail-to=}"
|
ARG_MAIL_TO="${CMD_PARAMETER#-mail-to=}"
|
||||||
;;
|
;;
|
||||||
|
@ -1477,7 +1477,7 @@ do
|
|||||||
FCONFIG="Yes"
|
FCONFIG="Yes"
|
||||||
if [[ -r ${CONFIG_DIR}/${FNAME#function *}.conf ]]
|
if [[ -r ${CONFIG_DIR}/${FNAME#function *}.conf ]]
|
||||||
then
|
then
|
||||||
# check for log_healthy parameter
|
# check for log_healthy parameter (config file)
|
||||||
HAS_FHEALTHY=$(_CONFIG_FILE="${CONFIG_DIR}/${FNAME#function *}.conf" data_get_lvalue_from_config 'log_healthy')
|
HAS_FHEALTHY=$(_CONFIG_FILE="${CONFIG_DIR}/${FNAME#function *}.conf" data_get_lvalue_from_config 'log_healthy')
|
||||||
case "${HAS_FHEALTHY}" in
|
case "${HAS_FHEALTHY}" in
|
||||||
no|NO|No)
|
no|NO|No)
|
||||||
@ -1487,15 +1487,19 @@ do
|
|||||||
FHEALTHY="Yes"
|
FHEALTHY="Yes"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
FHEALTHY="N/A"
|
FHEALTHY="N/S"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
FHEALTHY="N/A"
|
FHEALTHY="N/S"
|
||||||
fi
|
fi
|
||||||
|
# check for log_healthy support through --hc-args (plugin)
|
||||||
|
elif (( $(grep -c -E -e "_LOG_HEALTHY" "${FFILE}" 2>/dev/null) > 0 ))
|
||||||
|
then
|
||||||
|
FHEALTHY="Yes"
|
||||||
else
|
else
|
||||||
FCONFIG="No"
|
FCONFIG="No"
|
||||||
FHEALTHY="N/A"
|
FHEALTHY="N/S"
|
||||||
fi
|
fi
|
||||||
# check state
|
# check state
|
||||||
DISABLE_FFILE="$(print ${FFILE##*/} | sed 's/\.sh$//')"
|
DISABLE_FFILE="$(print ${FFILE##*/} | sed 's/\.sh$//')"
|
||||||
@ -1559,9 +1563,9 @@ fi
|
|||||||
if [[ "${FACTION}" != "list" ]]
|
if [[ "${FACTION}" != "list" ]]
|
||||||
then
|
then
|
||||||
print
|
print
|
||||||
print "Config?: plugin has a default configuration files (Yes/No)"
|
print "Config?: plugin has a default configuration file (Yes/No)"
|
||||||
print "Sched? : plugin is scheduled through cron (Yes/No)"
|
print "Sched? : plugin is scheduled through cron (Yes/No)"
|
||||||
print "H+? : plugin will log/show passed health checks too (Yes/No/Not applicable)"
|
print "H+? : plugin can log/show passed health checks (Yes/No/Not supported)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -1801,4 +1805,4 @@ return 0
|
|||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# END of script
|
# END of script
|
||||||
#******************************************************************************
|
#******************************************************************************
|
@ -54,9 +54,6 @@ typeset _OVPA_DAEMONS=""
|
|||||||
for _ARG in ${_ARGS}
|
for _ARG in ${_ARGS}
|
||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
log_healthy)
|
|
||||||
_LOG_HEALTHY=1
|
|
||||||
;;
|
|
||||||
help)
|
help)
|
||||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||||
;;
|
;;
|
||||||
@ -64,6 +61,7 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# log_healthy
|
# log_healthy
|
||||||
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
if (( _LOG_HEALTHY > 0 ))
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
then
|
then
|
||||||
if (( ARG_LOG > 0 ))
|
if (( ARG_LOG > 0 ))
|
||||||
@ -129,10 +127,11 @@ return 0
|
|||||||
function _show_usage
|
function _show_usage
|
||||||
{
|
{
|
||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
CONFIG : $3
|
CONFIG : $3
|
||||||
PURPOSE : Checks the status of OVPA processes (OpenView Performance Agent)
|
PURPOSE : Checks the status of OVPA processes (OpenView Performance Agent)
|
||||||
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2018-07-10: original version [Patrick Van der Veken]
|
# @(#) 2018-07-10: original version [Patrick Van der Veken]
|
||||||
# @(#) 2018-07-11: better log_healthy handling [Patrick Van der Veken]
|
# @(#) 2018-07-12: better log_healthy handling [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 +33,7 @@ function check_linux_process_limits
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2018-07-11" # YYYY-MM-DD
|
typeset _VERSION="2018-07-12" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -72,9 +72,6 @@ trap "rm -f ${_INSTANCE_RUN_FILE}.* >/dev/null 2>&1; return 1" 1 2 3 15
|
|||||||
for _ARG in ${_ARGS}
|
for _ARG in ${_ARGS}
|
||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
log_healthy)
|
|
||||||
_LOG_HEALTHY=1
|
|
||||||
;;
|
|
||||||
help)
|
help)
|
||||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||||
;;
|
;;
|
||||||
@ -101,6 +98,7 @@ case "${_CFG_HEALTHY}" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# log_healthy
|
# log_healthy
|
||||||
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
if (( _LOG_HEALTHY > 0 ))
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
then
|
then
|
||||||
if (( ARG_LOG > 0 ))
|
if (( ARG_LOG > 0 ))
|
||||||
@ -391,17 +389,18 @@ return 0
|
|||||||
function _show_usage
|
function _show_usage
|
||||||
{
|
{
|
||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
CONFIG : $3 with:
|
CONFIG : $3 with:
|
||||||
log_healthy=<yes|no>
|
log_healthy=<yes|no>
|
||||||
and formatted stanzas:
|
and formatted stanzas:
|
||||||
user:<user_name>:<limit_name>:<soft_limit_threshold_%>:<hard_limit_threshold_%>
|
user:<user_name>:<limit_name>:<soft_limit_threshold_%>:<hard_limit_threshold_%>
|
||||||
process:<process_name>:<limit_name>:<soft_limit_threshold_%>:<hard_limit_threshold_%>
|
process:<process_name>:<limit_name>:<soft_limit_threshold_%>:<hard_limit_threshold_%>
|
||||||
PURPOSE : Checks the value(s) of the process limits from /proc/*/limits or ulimit
|
PURPOSE : Checks the value(s) of the process limits from /proc/*/limits or ulimit
|
||||||
Currenty following checks are supported:
|
Currenty following checks are supported:
|
||||||
* Max open files (/proc/*/limits)
|
* Max open files (/proc/*/limits)
|
||||||
* Max processes (ulimit)
|
* Max processes (ulimit)
|
||||||
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user