added --log-healthy support to plugins, standardized format of configuration files
This commit is contained in:
parent
4919949d4f
commit
cf4683d6b8
@ -28,11 +28,12 @@ install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib
|
||||
install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib/platform
|
||||
install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib/platform/linux
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_burp_backup.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_burp_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_es_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_es_status.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_file_age.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_file_change.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_fs_mounts.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_fs_usage.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fs_usage.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_burp_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_httpd_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_httpd_status.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_mysqld_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_mysqld_status.sh
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_named_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_named_status.sh
|
||||
@ -57,6 +58,7 @@ cp ../SOURCES/lib/platform/linux/check_linux_vz_ct_counters.sh $RPM_BUILD_ROOT/o
|
||||
cp ../SOURCES/lib/platform/linux/check_linux_vz_ct_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc
|
||||
cp ../SOURCES/etc/check_linux_burp_backup.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_burp_backup.conf.dist
|
||||
cp ../SOURCES/etc/check_linux_es_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_es_status.conf.dist
|
||||
cp ../SOURCES/etc/check_linux_file_age.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_age.conf.dist
|
||||
cp ../SOURCES/etc/check_linux_file_change.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_change.conf.dist
|
||||
cp ../SOURCES/etc/check_linux_fs_usage.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fs_usage.conf.dist
|
||||
@ -115,11 +117,12 @@ echo "INFO: finished post-uninstall script"
|
||||
%dir /opt/hc/lib/platform
|
||||
%dir /opt/hc/lib/platform/linux
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_es_status.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_file_age.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_file_change.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fs_usage.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_httpd_status.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_mysqld_status.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_named_status.sh
|
||||
@ -144,6 +147,7 @@ echo "INFO: finished post-uninstall script"
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||
%dir /etc/opt/hc
|
||||
%attr(644, root, root) /etc/opt/hc/check_linux_burp_backup.conf.dist
|
||||
%attr(644, root, root) /etc/opt/hc/check_linux_es_status.conf.dist
|
||||
%attr(644, root, root) /etc/opt/hc/check_linux_file_age.conf.dist
|
||||
%attr(644, root, root) /etc/opt/hc/check_linux_file_change.conf.dist
|
||||
%attr(644, root, root) /etc/opt/hc/check_linux_fs_usage.conf.dist
|
||||
@ -167,6 +171,8 @@ echo "INFO: finished post-uninstall script"
|
||||
%attr(644, root, root) /etc/opt/hc/core/templates/mail_body.tpl-check_linux_root_crontab
|
||||
|
||||
%changelog
|
||||
* Sat Mar 09 2019 <patrick@kudos.be> - 0.1.5
|
||||
- Added check_linux_es_status
|
||||
* Sun Feb 10 2019 <patrick@kudos.be> - 0.1.4
|
||||
- Added check_linux_mysqld_status
|
||||
* Thu Feb 07 2019 <patrick@kudos.be> - 0.1.3
|
||||
|
@ -6,11 +6,18 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# client name; maximum amount of warnings allowed; maximum backup age (hours/days/weeks)
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# specify client & backup details
|
||||
# Format:
|
||||
# client:<client_name>:<max_warnings_allowed>:<max_backup_age>(d|h|w)
|
||||
# Examples:
|
||||
#testclient1;0;10h
|
||||
#testclient2;0;2d
|
||||
#testclient3;0;5w
|
||||
#client:host1:0:10h
|
||||
#client:host2:0:2d
|
||||
#client:host3:0:5w
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
|
21
configs/etc/check_linux_es_status.conf.dist
Normal file
21
configs/etc/check_linux_es_status.conf.dist
Normal file
@ -0,0 +1,21 @@
|
||||
#******************************************************************************
|
||||
# @(#) check_linux_es_status.conf
|
||||
#******************************************************************************
|
||||
# This is a configuration file for the check_linux_es_status HC plugin.
|
||||
# All lines starting with a '#' are comment lines.
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# specify the URL of the Elasticsearch instance (host:port)
|
||||
# [default: http://localhost:9200]
|
||||
es_url="http://localhost:9200"
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
@ -6,10 +6,19 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# file (full path); maximum age in minutes since last change
|
||||
/var/log/messages;60
|
||||
/var/log/ntp.log;30
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# specify file details
|
||||
# Format:
|
||||
# file:<file_path>:<max_age_minutes_since_last_change>
|
||||
# Examples:
|
||||
#file:/var/log/messages:60
|
||||
#file:/var/log/ntp.log:30
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
||||
#******************************************************************************
|
||||
|
@ -6,6 +6,11 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# name of the state file to use (will be relative to /var/opt/hc/state/persistent
|
||||
# [default: discovered.file_change]
|
||||
state_file=discovered.file_change
|
||||
|
@ -6,6 +6,11 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# location of 'hpacucli' tool
|
||||
hpacucli_bin="/usr/sbin/hpacucli"
|
||||
|
||||
@ -21,6 +26,7 @@ do_acu_physical=1
|
||||
# controller slot=X logicaldrive all show status (0=off, 1=on) [default: 1]
|
||||
do_acu_logical=1
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
||||
#******************************************************************************
|
||||
|
@ -6,6 +6,11 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# location of 'hpasmcli' tool
|
||||
hpasmcli_bin="/sbin/hpasmcli"
|
||||
|
||||
@ -24,6 +29,7 @@ do_asm_server=1
|
||||
# SHOW TEMPERATURE (0=off, 1=on) [default: 1]
|
||||
do_asm_temperature=1
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
||||
#******************************************************************************
|
||||
|
@ -6,6 +6,11 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# location of 'hpacucli' tool
|
||||
hplog_bin="/sbin/hplog"
|
||||
|
||||
|
@ -6,6 +6,11 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# location of 'hpssacli' tool
|
||||
hpssacli_bin="/usr/sbin/hpssacli"
|
||||
|
||||
@ -23,4 +28,4 @@ do_ssa_logical=1
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
||||
#******************************************************************************
|
||||
|
@ -6,8 +6,17 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# list of commands (or strings) that should appear in active cron entries
|
||||
/usr/bin/cfg2html-linux
|
||||
# Format:
|
||||
# cron:<cron_entry>
|
||||
# Examples:
|
||||
#cron:/usr/bin/cfg2html-linux
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
|
@ -6,9 +6,16 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# list of required cluster statuses (format : "parameter=value")
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# list of required cluster statuses
|
||||
# Format:
|
||||
# sg:<parameter>=<value>
|
||||
# Examples:
|
||||
#status=up
|
||||
#sg:status=up
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
|
@ -6,9 +6,16 @@
|
||||
# [default: indicates hardcoded script values if no value is defined here]
|
||||
#******************************************************************************
|
||||
|
||||
# list of required package statuses (format : "package_name:parameter=value")
|
||||
# specify whether to also log passed health checks
|
||||
# (warning: this may rapidly grow the HC log)
|
||||
# [default: no]
|
||||
log_healthy="yes"
|
||||
|
||||
# list of required package statuses
|
||||
# Format:
|
||||
# sg:<package_name>:<parameter>=<value>
|
||||
# Examples:
|
||||
#my_package|status=up
|
||||
#sg:my_package:status=up
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
|
@ -13,9 +13,9 @@ log_healthy="yes"
|
||||
|
||||
# specify containers for which to check the UBC
|
||||
# Format:
|
||||
# [ct:<ct_id>]
|
||||
# [ct:<ct_id>]
|
||||
# Examples:
|
||||
# ct:100
|
||||
#ct:100
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
|
@ -12,7 +12,8 @@
|
||||
log_healthy="yes"
|
||||
|
||||
# specify properties as displayed by the 'vzlist -a -H -o ctid,status,onboot' command
|
||||
# [ct:<ct_id>:<runtime_status>:<boot_status>]
|
||||
# Format:
|
||||
# [ct:<ct_id>:<runtime_status>:<boot_status>]
|
||||
# runtime_status should be 'running' or 'stopped'
|
||||
# boot_status should be 'yes' or 'no'
|
||||
# Examples:
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_burp_backup
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(),init_hc(), log_hc(),
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
|
||||
# GNU date that can calculate UNIX epoch seconds from given date,
|
||||
# BURP server must be be able to impersonate configured clients
|
||||
#
|
||||
@ -29,6 +29,8 @@
|
||||
# @(#) 2018-08-25: support for burp v2 [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: changed format of stanzas in configuration file &
|
||||
# @(#) added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -40,7 +42,7 @@ function check_linux_burp_backup
|
||||
typeset _BURP_SERVER_CONFIG_FILE="/etc/burp/burp-server.conf"
|
||||
typeset _BURP_CLIENT_CONFIG_FILE="/etc/burp/burp.conf"
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -51,6 +53,8 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _BURP_BIN=""
|
||||
typeset _BURP_AGE=""
|
||||
typeset _BURP_BACKUP_DIR=""
|
||||
@ -60,6 +64,7 @@ typeset _BURP_VERSION=""
|
||||
typeset _BURP_WARNINGS=""
|
||||
typeset _GNU_DATE=""
|
||||
typeset _COUNT=1
|
||||
typeset _IS_OLD_STYLE=0
|
||||
typeset _NOW="$(date '+%Y%m%d %H%M' 2>/dev/null)" # format: YYYYMMDD HHMM
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
@ -79,6 +84,38 @@ then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# check for old-style configuration file (non-prefixed stanzas)
|
||||
_IS_OLD_STYLE=$(grep -c -E -e "^client:" ${_CONFIG_FILE} 2>/dev/null)
|
||||
if (( _IS_OLD_STYLE > 0 ))
|
||||
then
|
||||
warn "no 'client:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check for capable GNU date
|
||||
_GNU_DATE=$(date --date="1 day ago" '+%s' 2>/dev/null)
|
||||
@ -146,8 +183,8 @@ case "${_BURP_VERSION}" in
|
||||
esac
|
||||
|
||||
# check backup runs of clients
|
||||
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null |\
|
||||
while IFS=';' read _BURP_CLIENT _BURP_WARNINGS _BURP_AGE
|
||||
grep -E -e "^client:" ${_CONFIG_FILE} 2>/dev/null |\
|
||||
while IFS=':' read _ _BURP_CLIENT _BURP_WARNINGS _BURP_AGE
|
||||
do
|
||||
typeset _BACKUP_AGING=""
|
||||
typeset _BACKUP_DATE=""
|
||||
@ -278,11 +315,14 @@ do
|
||||
:
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
_COUNT=$(( _COUNT + 1 ))
|
||||
|
||||
# save STDOUT
|
||||
if (( _STC =! 0 ))
|
||||
if (( _STC > 0 ))
|
||||
then
|
||||
print "=== ${_BURP_CLIENT}: ${_BACKUP_RUN} ===" >>${HC_STDOUT_LOG}
|
||||
${_BURP_BIN} -c ${_BURP_SERVER_CONFIG_FILE} -a S -C ${_BURP_CLIENT} -b ${_BACKUP_RUN} -z log.gz >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
@ -301,12 +341,15 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
backup_age=<days_till_last_backup>
|
||||
PURPOSE : Checks the status and age of saved burp client backups.
|
||||
Should only berun only on a burp backup server (supports burp v1 and v2)
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
and formatted stanzas:
|
||||
client:<client_name>:<max_warnings_allowed>:<max_backup_age>(d|h|w)
|
||||
PURPOSE : Checks the status and age of saved burp client backups.
|
||||
Should only be run only on a burp backup server (supports burp v1 and v2)
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,13 +19,14 @@
|
||||
# @(#) MAIN: check_linux_burp_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-12-01: initial version [Patrick Van der Veken]
|
||||
# @(#) 2017-05-08: fix fall-back for sysv->pgrep [Patrick Van der Veken]
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -36,7 +37,7 @@ function check_linux_burp_status
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _BURP_INIT_SCRIPT="/etc/init.d/burp"
|
||||
typeset _BURP_SYSTEMD_SERVICE="burp.service"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -47,6 +48,7 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _RC=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
@ -59,6 +61,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# 1) try using the init ways
|
||||
linux_get_init
|
||||
case "${LINUX_INIT}" in
|
||||
@ -67,7 +83,7 @@ case "${LINUX_INIT}" in
|
||||
;;
|
||||
'upstart')
|
||||
warn "code for upstart managed systems not implemented, NOOP"
|
||||
return 1
|
||||
return 1
|
||||
;;
|
||||
'sysv')
|
||||
if [[ -x ${_BURP_INIT_SCRIPT} ]]
|
||||
@ -104,7 +120,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of burp"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -113,10 +132,10 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether a Burp (backup server daemon) is running
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether a Burp (backup server daemon) is running
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
162
sources/lib/platform/linux/check_linux_es_status.sh
Normal file
162
sources/lib/platform/linux/check_linux_es_status.sh
Normal file
@ -0,0 +1,162 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_linux_es_status.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2019 by KUDOS BVBA (info@kudos.be). All rights reserved.
|
||||
#
|
||||
# This program is a free software; you can redistribute it and/or modify
|
||||
# it under the same terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
|
||||
#******************************************************************************
|
||||
#
|
||||
# DOCUMENTATION (MAIN)
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) MAIN: check_linux_es_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: curl, data_comma2space(), dump_logs(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2019-03-09: initial version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_linux_es_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _CFG_ES_URL=""
|
||||
typeset _API_URL=""
|
||||
typeset _ES_STATUS=""
|
||||
typeset _ES_URL=""
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
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} ]]
|
||||
then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
# read configuration values
|
||||
_CFG_ES_URL=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'es_url')
|
||||
if [[ -z "${_CFG_ES_URL}" ]]
|
||||
then
|
||||
warn "no value for 'es_url' specified in ${_CONFIG_FILE}, using localhost default"
|
||||
_ES_URL="http://localhost:9200"
|
||||
else
|
||||
_ES_URL="${_CFG_ES_URL}"
|
||||
fi
|
||||
_API_URL="${_ES_URL}/_cat/health?h=status"
|
||||
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check curl
|
||||
_CURL_BIN="$(which curl 2>>${HC_STDERR_LOG})"
|
||||
if [[ ! -x ${_CURL_BIN} || -z "${_CURL_BIN}" ]]
|
||||
then
|
||||
warn "curl is not installed here"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# get cluster check_linux_es_status
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && debug "curl command: ${_CURL_BIN} -XGET '${_API_URL}'"
|
||||
_ES_STATUS=$(${_CURL_BIN} -XGET "${_API_URL}" 2>>${HC_STDERR_LOG})
|
||||
if (( $? > 0 )) || [[ -z "${_ES_STATUS}" ]]
|
||||
then
|
||||
_MSG="unable to run command {${_CURL_BIN} -XGET '${_API_URL}'}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
fi
|
||||
|
||||
# parse status results
|
||||
case "${_ES_STATUS}" in
|
||||
green)
|
||||
_MSG="state of ES instance at ${_ES_URL} is OK [${_ES_STATUS}]"
|
||||
_STC=0
|
||||
;;
|
||||
*)
|
||||
_MSG="state of ES instance at ${_ES_URL} is NOK [${_ES_STATUS}]"
|
||||
_STC=1
|
||||
;;
|
||||
esac
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}" "${_ES_STATUS}" "green"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
es_url=<url_of_es_api>
|
||||
PURPOSE : Checks the status of an Elastich search instance (green)
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
@ -19,13 +19,16 @@
|
||||
# @(#) MAIN: check_linux_file_age
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||
# REQUIRES: GNU find, data_comma2space(), data_is_numeric(), init_hc(),
|
||||
# log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-27: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added code for data_is_numeric(), changed format of configuration
|
||||
# @(#) file (; -> :) & added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -35,7 +38,7 @@ function check_linux_file_age
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -46,12 +49,14 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _ENTRY=""
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _AGE_CHECK=""
|
||||
typeset _FILE_PATH=""
|
||||
typeset _FILE_AGE=""
|
||||
typeset _FILE_NAME=""
|
||||
typeset _FILE_DIR=""
|
||||
typeset _IS_OLD_STYLE=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
@ -70,14 +75,41 @@ then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# check for old-style configuration file (non-prefixed stanzas)
|
||||
_IS_OLD_STYLE=$(grep -c -E -e "^file:" ${_CONFIG_FILE} 2>/dev/null)
|
||||
if (( _IS_OLD_STYLE > 0 ))
|
||||
then
|
||||
warn "no 'file:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# perform check
|
||||
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _ENTRY
|
||||
grep -E -e "^file:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _FILE_PATH _FILE_AGE
|
||||
do
|
||||
# field split
|
||||
_FILE_PATH=$(print "${_ENTRY%%;*}")
|
||||
_FILE_AGE=$(print "${_ENTRY##*;}")
|
||||
|
||||
# split file/dir
|
||||
_FILE_NAME=$(print "${_FILE_PATH##*/}")
|
||||
_FILE_DIR=$(print "${_FILE_PATH%/*}")
|
||||
@ -88,16 +120,12 @@ do
|
||||
warn "missing values in configuration file at ${_CONFIG_FILE}"
|
||||
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
|
||||
;;
|
||||
esac
|
||||
data_is_numeric "${_FILE_AGE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# perform check
|
||||
if [[ ! -r "${_FILE_PATH}" ]]
|
||||
@ -120,8 +148,11 @@ do
|
||||
fi
|
||||
fi
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
# report result
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
_STC=0
|
||||
done
|
||||
|
||||
@ -132,12 +163,15 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
<file_name>;<maximum_age_in_minutes>
|
||||
PURPOSE : Checks whether given files have been changed in the last n minutes
|
||||
(requires GNU find)
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
and formatted stanzas:
|
||||
file:<file_path>:<max_age_in_minutes>
|
||||
PURPOSE : Checks whether given files have been changed in the last n minutes
|
||||
(requires GNU find)
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: change format of stanzas in configuration file &
|
||||
# @(#) added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +39,7 @@ function check_linux_file_change
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -48,6 +50,8 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _DO_META_CHECK=0
|
||||
typeset _CFG_STATE_FILE=""
|
||||
typeset _STATE_FILE=""
|
||||
@ -112,6 +116,29 @@ case "${_DO_META_CHECK}" in
|
||||
log "check for meta characters is enabled"
|
||||
;;
|
||||
esac
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check for checksum tools
|
||||
_OPENSSL_BIN="$(which openssl 2>>${HC_STDERR_LOG})"
|
||||
@ -294,7 +321,7 @@ do
|
||||
fi
|
||||
|
||||
# bounce failures back and jump to next file
|
||||
if (( _STC > 0 ))
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
continue
|
||||
@ -349,24 +376,26 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with formatted stanzas:
|
||||
incl:<full path>
|
||||
excl:<full path>
|
||||
PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes
|
||||
of files and directories (automatically expanded). Excludes have a higher
|
||||
priority than includes. Integrity checks will only be performed on files.
|
||||
Will detect changed, new & deleted files (but not when deleted files
|
||||
occur in an expanded directory tree). If you wish to detect deleted files:
|
||||
use only direct file references in the configuration file. Uses by preference
|
||||
openssl for hash calculation, with cksum as fall-back).
|
||||
Updated and deleted files will cause a HC failure, new files will not.
|
||||
CAVEAT EMPTOR: use only to check a relatively small number of files.
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
with formatted stanzas:
|
||||
incl:<full path>
|
||||
excl:<full path>
|
||||
PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes
|
||||
of files and directories (automatically expanded). Excludes have a higher
|
||||
priority than includes. Integrity checks will only be performed on files.
|
||||
Will detect changed, new & deleted files (but not when deleted files
|
||||
occur in an expanded directory tree). If you wish to detect deleted files:
|
||||
use only direct file references in the configuration file. Uses by preference
|
||||
openssl for hash calculation, with cksum as fall-back).
|
||||
Updated and deleted files will cause a HC failure, new files will not.
|
||||
CAVEAT EMPTOR: use only to check a relatively small number of files.
|
||||
Processing a big number of files is likely to take
|
||||
ages and probably will cause the plugin to time out
|
||||
(see HC_TIME_OUT). YMMV.
|
||||
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
# @(#) 2018-08-25: small fix [Patrick Van der Veken]
|
||||
# @(#) 2018-10-02: regex fix [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -35,7 +36,7 @@
|
||||
function check_linux_fs_mounts
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _FS=""
|
||||
typeset _FS_COUNT=0
|
||||
|
||||
@ -59,6 +61,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# collect data (mount only)
|
||||
mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
if (( $? > 0 ))
|
||||
@ -89,8 +105,11 @@ do
|
||||
;;
|
||||
esac
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
# report result
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
_STC=0
|
||||
done
|
||||
|
||||
@ -104,11 +123,11 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether file systems are mounted or not, exclude following FS types:
|
||||
proc, swap, sysfs, devpts, tmpfs, cdrom & floppy
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether file systems are mounted or not, exclude following FS types:
|
||||
proc, swap, sysfs, devpts, tmpfs, cdrom & floppy
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -316,15 +316,15 @@ function _show_usage
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with formatted stanzas (optional):
|
||||
fs:<fs_name>:<max_INODES_USAGE_in_%>:<max_space_usage_in%>
|
||||
Other options:
|
||||
log_healthy=<yes|no>
|
||||
check_inodes_usage=<yes|no>
|
||||
check_space_usage=<yes|no>
|
||||
max_inodes_usage=<general_inodes_usage_treshold>
|
||||
max_space_usage=<general_space_usage_treshold>
|
||||
EXT OPTS : --hc-args=check_inodes, --hc-args=check_space
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
check_inodes_usage=<yes|no>
|
||||
check_space_usage=<yes|no>
|
||||
max_inodes_usage=<general_inodes_usage_treshold>
|
||||
max_space_usage=<general_space_usage_treshold>
|
||||
with formatted stanzas (optional):
|
||||
fs:<fs_name>:<max_inodes_usage_%>:<max_space_usage_%>
|
||||
EXT OPTIONS : --hc-args=check_inodes, --hc-args=check_space
|
||||
PURPOSE : Checks the inodes & space usage for the configured or all (local) filesystems
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_hpacucli
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), data_is_numeric(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-09-09: initial version [Patrick Van der Veken]
|
||||
@ -27,6 +27,8 @@
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added code for data_is_numeric() & support for
|
||||
# @(#) --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -36,7 +38,7 @@ function check_linux_hpacucli
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -47,6 +49,8 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC_COUNT=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$"
|
||||
typeset _HPACUCLI_BIN=""
|
||||
typeset _ACU_LINE=""
|
||||
@ -138,6 +142,29 @@ then
|
||||
log "switching setting 'do_acu_controller' to 1 to fetch slot info"
|
||||
_DO_ACU_CTRL=1
|
||||
fi
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check for HP tools
|
||||
if [[ ! -x ${_HPACUCLI_BIN} || -z "${_HPACUCLI_BIN}" ]]
|
||||
@ -158,7 +185,6 @@ then
|
||||
do
|
||||
_MSG="failure in controller"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ACU controller(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -167,16 +193,13 @@ then
|
||||
cat ${_TMP_FILE} | grep "in Slot [0-9]" 2>/dev/null | while read _ACU_LINE
|
||||
do
|
||||
_SLOT_NUM="$(print ${_ACU_LINE} | cut -f6 -d' ' 2>/dev/null)"
|
||||
case "${_DO_ACU_LOGL}" in
|
||||
+([0-9])*([0-9]))
|
||||
# numeric OK
|
||||
_SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}"
|
||||
;;
|
||||
*)
|
||||
# non-numeric
|
||||
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
|
||||
;;
|
||||
esac
|
||||
data_is_numeric "${_SLOT_NUM}"
|
||||
if (( $? == 0 ))
|
||||
then
|
||||
_SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}"
|
||||
else
|
||||
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
warn "${_HPACUCLI_BIN}: do_acu_controller check is not enabled"
|
||||
@ -197,7 +220,6 @@ then
|
||||
do
|
||||
_MSG="failure in enclosure for controller ${_CTRL_SLOT}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ACU enclosure(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -222,7 +244,6 @@ then
|
||||
do
|
||||
_MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ACU physical drive(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -247,7 +268,6 @@ then
|
||||
do
|
||||
_MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ACU logical drive(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -258,7 +278,7 @@ else
|
||||
fi
|
||||
|
||||
# report OK situation
|
||||
if (( _STC_COUNT == 0 ))
|
||||
if (( _LOG_HEALTHY > 0 && _STC_COUNT == 0 ))
|
||||
then
|
||||
_MSG="no problems detected by {${_HPACUCLI_BIN}}"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
@ -274,16 +294,18 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
hpacucli_bin=<location_of_hpacucli_tool>
|
||||
do_acu_controller=0|1
|
||||
do_acu_enclosure=0|1
|
||||
do_acu_physical=0|1
|
||||
do_acu_logical=0|1
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
hpacucli_bin=<location_of_hpacucli_tool>
|
||||
do_acu_controller=<0|1>
|
||||
do_acu_enclosure=<0|1>
|
||||
do_acu_physical=<0|1>
|
||||
do_acu_logical=<0|1>
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_hpasmcli
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-09-07: initial version [Patrick Van der Veken]
|
||||
@ -28,6 +28,7 @@
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +38,7 @@ function check_linux_hpasmcli
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -48,6 +49,8 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC_COUNT=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$"
|
||||
typeset _HPASMCLI_BIN=""
|
||||
typeset _ASM_LINE=""
|
||||
@ -146,6 +149,30 @@ case "${_DO_ASM_TEMP}" in
|
||||
_DO_ASM_TEMP=1
|
||||
;;
|
||||
esac
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
|
||||
# check for HP tools
|
||||
if [[ ! -x ${_HPASMCLI_BIN} || -z "${_HPASMCLI_BIN}" ]]
|
||||
@ -167,7 +194,6 @@ then
|
||||
_FAN_UNIT="$(print ${_ASM_LINE} | cut -f1 -d' ')"
|
||||
_MSG="failure in 'SHOW FANS', unit ${_FAN_UNIT}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ASM fans ===" >>${HC_STDOUT_LOG}
|
||||
@ -187,7 +213,6 @@ then
|
||||
do
|
||||
_MSG="failure in 'SHOW DIMM'"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ASM DIMMs ===" >>${HC_STDOUT_LOG}
|
||||
@ -207,7 +232,6 @@ then
|
||||
do
|
||||
_MSG="failure in 'SHOW POWERSUPPLY'"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ASM power supply ===" >>${HC_STDOUT_LOG}
|
||||
@ -227,7 +251,6 @@ then
|
||||
do
|
||||
_MSG="failure in 'SHOW SERVER'"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== ASM server ===" >>${HC_STDOUT_LOG}
|
||||
@ -257,7 +280,6 @@ then
|
||||
_MSG="failure in 'SHOW TEMP', unit ${_TEMP_UNIT}"
|
||||
_MSG="${_MSG} has ${_TEMP_VALUE} >= ${_THRES_VALUE}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}" "${_TEMP_VALUE}" "${_THRES_VALUE}"
|
||||
fi
|
||||
fi
|
||||
@ -269,7 +291,7 @@ else
|
||||
fi
|
||||
|
||||
# report OK situation
|
||||
if (( _STC_COUNT == 0 ))
|
||||
if (( _LOG_HEALTHY > 0 && _STC_COUNT == 0 ))
|
||||
then
|
||||
_MSG="no problems detected by {${_HPASMCLI_BIN}}"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
@ -285,17 +307,19 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
hpasmcli_bin=<location_of_hpasmcli_tool>
|
||||
do_asm_fans=0|1
|
||||
do_asm_dimm=0|1
|
||||
do_asm_powersupply=0|1
|
||||
do_asm_server=0|1
|
||||
do_asm_temperature=0|1
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpasmcli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with paramets:
|
||||
log_healthy=<yes|no>
|
||||
hpasmcli_bin=<location_of_hpasmcli_tool>
|
||||
do_asm_fans=<0|1>
|
||||
do_asm_dimm=<0|1>
|
||||
do_asm_powersupply=<0|1>
|
||||
do_asm_server=<0|1>
|
||||
do_asm_temperature=<0|1>
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpasmcli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_hplog
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-04-22: initial version [Patrick Van der Veken]
|
||||
@ -27,6 +27,7 @@
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -49,6 +50,8 @@ typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _STC_COUNT=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _TMP1_FILE="${TMP_DIR}/.$0.tmp1.$$"
|
||||
typeset _TMP2_FILE="${TMP_DIR}/.$0.tmp2.$$"
|
||||
typeset _HPLOG_BIN=""
|
||||
@ -102,6 +105,29 @@ else
|
||||
# delete last 'OR'
|
||||
_HPLOG_SEVERITIES=${_HPLOG_SEVERITIES%?}
|
||||
fi
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check hplog utility
|
||||
if [[ ! -x ${_HPLOG_BIN} || -z "${_HPLOG_BIN}" ]]
|
||||
@ -117,7 +143,7 @@ ${_HPLOG_BIN} -v >${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
# check state file
|
||||
@ -142,7 +168,6 @@ while read -r _EVENT_ENTRY
|
||||
do
|
||||
_MSG="${_EVENT_ENTRY}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done <${_TMP2_FILE}
|
||||
if (( _STC_COUNT > 0 ))
|
||||
@ -158,7 +183,10 @@ then
|
||||
else
|
||||
_MSG="no new HPLOG messages found"
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
# do cleanup
|
||||
[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1
|
||||
@ -171,13 +199,15 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
hplog_bin=<location_of_hplog_tool>
|
||||
hplog_severities=<list_of_severities_to_search_for>
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
hplog_bin=<location_of_hplog_tool>
|
||||
hplog_severities=<list_of_severities_to_search_for>
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_hpssacli
|
||||
# DOES: _show_usage()
|
||||
# EXPECTS: _show_usage()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), data_is_numeric(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-04-01: initial version [Patrick Van der Veken]
|
||||
@ -27,6 +27,8 @@
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: do not trap on signal 0 [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added code for data_is_numeric() & support for
|
||||
# @(#) --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -36,7 +38,7 @@ function check_linux_hpssacli
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -47,6 +49,8 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC_COUNT=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$"
|
||||
typeset _HPSSACLI_BIN=""
|
||||
typeset _SSA_LINE=""
|
||||
@ -138,6 +142,29 @@ then
|
||||
log "switching setting 'do_ssa_controller' to 1 to fetch slot info"
|
||||
_DO_SSA_CTRL=1
|
||||
fi
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check for HP tools
|
||||
if [[ ! -x ${_HPSSACLI_BIN} || -z "${_HPSSACLI_BIN}" ]]
|
||||
@ -158,7 +185,6 @@ then
|
||||
do
|
||||
_MSG="failure in controller"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== SSA controller(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -167,16 +193,13 @@ then
|
||||
cat ${_TMP_FILE} | grep "in Slot [0-9]" 2>/dev/null | while read _SSA_LINE
|
||||
do
|
||||
_SLOT_NUM="$(print ${_SSA_LINE} | cut -f6 -d' ' 2>/dev/null)"
|
||||
case "${_DO_SSA_LOGL}" in
|
||||
+([0-9])*([0-9]))
|
||||
# numeric OK
|
||||
_SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}"
|
||||
;;
|
||||
*)
|
||||
# non-numeric
|
||||
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
|
||||
;;
|
||||
esac
|
||||
data_is_numeric "${_SLOT_NUM}"
|
||||
if (( $? == 0 ))
|
||||
then
|
||||
_SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}"
|
||||
else
|
||||
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
warn "${_HPSSACLI_BIN}: do_ssa_controller check is not enabled"
|
||||
@ -197,7 +220,6 @@ then
|
||||
do
|
||||
_MSG="failure in enclosure for controller ${_CTRL_SLOT}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== SSA enclosure(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -222,7 +244,6 @@ then
|
||||
do
|
||||
_MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== SSA physical drive(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -247,7 +268,6 @@ then
|
||||
do
|
||||
_MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}"
|
||||
_STC_COUNT=$(( _STC_COUNT + 1 ))
|
||||
# handle unit result
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
done
|
||||
print "=== SSA logical drive(s) ===" >>${HC_STDOUT_LOG}
|
||||
@ -258,7 +278,7 @@ else
|
||||
fi
|
||||
|
||||
# report OK situation
|
||||
if (( _STC_COUNT == 0 ))
|
||||
if (( _LOG_HEALTHY > 0 && _STC_COUNT > 0 ))
|
||||
then
|
||||
_MSG="no problems detected by {${_HPSSACLI_BIN}}"
|
||||
log_hc "$0" 0 "${_MSG}"
|
||||
@ -273,16 +293,18 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
hpssacli_bin=<location_of_hpssacli_tool>
|
||||
do_ssa_controller=0|1
|
||||
do_ssa_enclosure=0|1
|
||||
do_ssa_physical=0|1
|
||||
do_ssa_logical=0|1
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpssacli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
hpssacli_bin=<location_of_hpssacli_tool>
|
||||
do_ssa_controller=<0|1>
|
||||
do_ssa_enclosure=<0|1>
|
||||
do_ssa_physical=<0|1>
|
||||
do_ssa_logical=<0|1>
|
||||
PURPOSE : Checks for errors from the HP Proliant 'hpssacli' tool (see HP Proliant
|
||||
support pack (PSP))
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_httpd_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-04-23: initial version [Patrick Van der Veken]
|
||||
@ -28,6 +28,7 @@
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: add linux_has_systemd_service() [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -38,7 +39,7 @@ function check_linux_httpd_status
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _HTTPD_INIT_SCRIPT="/etc/init.d/httpd"
|
||||
typeset _HTTPD_SYSTEMD_SERVICE="httpd.service"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -51,6 +52,7 @@ typeset _CHECK_SYSTEMD_SERVICE=0
|
||||
typeset _HTTPD_BIN=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _RC=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
@ -63,6 +65,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# ---- process state ----
|
||||
# 1) try using the init ways
|
||||
linux_get_init
|
||||
@ -117,7 +133,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of httpd"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
# ---- config state ----
|
||||
_HTTPD_BIN="$(which httpd 2>>${HC_STDERR_LOG})"
|
||||
@ -133,7 +152,10 @@ then
|
||||
_MSG="httpd configuration files have syntax error(s) {httpd -s}"
|
||||
_STC=1
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -143,11 +165,11 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether httpd (apache service) is running and whether the
|
||||
httpd configuration files are syntactically correct
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether httpd (apache service) is running and whether the
|
||||
httpd configuration files are syntactically correct
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2019-02-10: initial version [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: text files [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +38,7 @@ typeset _MYSQLD_INIT_SCRIPT="/etc/init.d/mysqld"
|
||||
typeset _MYSQLD_SYSTEMD_SERVICE="mysqld.service"
|
||||
typeset _MARIADB_INIT_SCRIPT="/etc/init.d/mariadb"
|
||||
typeset _MARIADB_SYSTEMD_SERVICE="mariadb.service"
|
||||
typeset _VERSION="2019-02-10" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -100,7 +101,7 @@ esac
|
||||
_CFG_MYSQL_USER=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_user')
|
||||
if [[ -z "${_CFG_MYSQL_USER}" ]]
|
||||
then
|
||||
warn "no value for 'mysql_user specified in ${_CONFIG_FILE}"
|
||||
warn "no value for 'mysql_user' specified in ${_CONFIG_FILE}"
|
||||
_DO_MYSQLCHECK=0
|
||||
else
|
||||
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --user=${_CFG_MYSQL_USER}"
|
||||
@ -110,7 +111,7 @@ fi
|
||||
_CFG_MYSQL_PASSWORD=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_password')
|
||||
if [[ -z "${_CFG_MYSQL_PASSWORD}" ]]
|
||||
then
|
||||
warn "no value for 'mysql_password specified in ${_CONFIG_FILE}"
|
||||
warn "no value for 'mysql_password' specified in ${_CONFIG_FILE}"
|
||||
_DO_MYSQLCHECK=0
|
||||
else
|
||||
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --password=${_CFG_MYSQL_PASSWORD}"
|
||||
@ -120,7 +121,7 @@ fi
|
||||
_CFG_MYSQL_HOST=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_host')
|
||||
if [[ -z "${_CFG_MYSQL_HOST}" ]]
|
||||
then
|
||||
warn "no value for 'mysql_host specified in ${_CONFIG_FILE}, using localhost"
|
||||
warn "no value for 'mysql_host' specified in ${_CONFIG_FILE}, using localhost"
|
||||
else
|
||||
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --host=${_CFG_MYSQL_HOST}"
|
||||
_MYSQLSHOW_OPTS="${_MYSQLSHOW_OPTS} --host=${_CFG_MYSQL_HOST}"
|
||||
@ -129,7 +130,7 @@ fi
|
||||
_CFG_MYSQL_PORT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_port')
|
||||
if [[ -z "${_CFG_MYSQL_PORT}" ]]
|
||||
then
|
||||
warn "no value for 'mysql_port specified in ${_CONFIG_FILE}, using 3306"
|
||||
warn "no value for 'mysql_port' specified in ${_CONFIG_FILE}, using 3306"
|
||||
else
|
||||
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --port=${_CFG_MYSQL_PORT}"
|
||||
_MYSQLSHOW_OPTS="${_MYSQLSHOW_OPTS} --port=${_CFG_MYSQL_PORT}"
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_named_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-12-01: initial version [Patrick Van der Veken]
|
||||
@ -27,6 +27,7 @@
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: add linux_has_systemd_service() [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -35,7 +36,7 @@
|
||||
function check_linux_named_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _CHECK_SYSTEMD_SERVICE=0
|
||||
typeset _NAMED_CHECKCONF_BIN=""
|
||||
typeset _NAMED_INIT_SCRIPT=""
|
||||
@ -62,6 +64,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# set init script & systemd service
|
||||
case "${LINUX_DISTRO}" in
|
||||
Debian)
|
||||
@ -128,7 +144,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of named"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
# ---- config state ----
|
||||
_NAMED_CHECKCONF_BIN="$(which named-checkconf 2>>${HC_STDERR_LOG})"
|
||||
@ -144,7 +163,10 @@ then
|
||||
_MSG="named configuration and/or zone files have syntax error(s) {named-checkconf -z}"
|
||||
_STC=1
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
@ -155,11 +177,11 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether named (BIND) is running and whether the named zone
|
||||
files are syntactically correct.
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether named (BIND) is running and whether the named zone
|
||||
files are syntactically correct.
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_postfix_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn')
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-12-01: initial version [Patrick Van der Veken]
|
||||
@ -28,6 +28,7 @@
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: add linux_has_systemd_service() [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -50,6 +51,7 @@ typeset _ARG=""
|
||||
typeset _POSTFIX_BIN=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _RC=0
|
||||
typeset _CHECK_SYSTEMD_SERVICE=0
|
||||
|
||||
@ -63,6 +65,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# 1) try using the init ways
|
||||
linux_get_init
|
||||
case "${LINUX_INIT}" in
|
||||
@ -126,7 +142,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of postfix"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -135,10 +154,10 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether postfix (mail system) is running
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether postfix (mail system) is running
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,12 +19,14 @@
|
||||
# @(#) MAIN: check_linux_root_crontab
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-09-19: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: changed format of stanzas in configuration file &
|
||||
# @(#) added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -34,7 +36,7 @@ function check_linux_root_crontab
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -45,9 +47,12 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _CRON_LINE=""
|
||||
typeset _CRON_ENTRY=""
|
||||
typeset _CRON_MATCH=0
|
||||
typeset _IS_OLD_STYLE=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
@ -66,6 +71,37 @@ then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# check for old-style configuration file (non-prefixed stanzas)
|
||||
_IS_OLD_STYLE=$(grep -c -E -e "^cron:" ${_CONFIG_FILE} 2>/dev/null)
|
||||
if (( _IS_OLD_STYLE > 0 ))
|
||||
then
|
||||
warn "no 'cron:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# collect data, since Linux can have multiple cron sources we will
|
||||
# squash them all together, standard cron, vixie, anacron, you name it :)
|
||||
@ -85,7 +121,7 @@ print "=== /etc/cron.(hourly|daily|weekly|monthly) ===" >>${HC_STDOUT_LOG}
|
||||
print "=== /etc/cron.d ===" >>${HC_STDOUT_LOG}
|
||||
if [[ -d /etc/cron.d ]]
|
||||
then
|
||||
cat /etc/cron.d/* | while read _CRON_LINE
|
||||
cat /etc/cron.d/* 2>/dev/null | while read _CRON_LINE
|
||||
do
|
||||
if [[ $(print "${_CRON_LINE}" | awk '{print $6}' 2>/dev/null) == "root" ]]
|
||||
then
|
||||
@ -95,7 +131,7 @@ then
|
||||
fi
|
||||
|
||||
# perform check
|
||||
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | while read _CRON_ENTRY
|
||||
grep -E -e "^cron:" ${_CONFIG_FILE} 2>/dev/null | while IFS=":" read -r _ _CRON_ENTRY
|
||||
do
|
||||
_CRON_MATCH=$(grep -v '^#' ${HC_STDOUT_LOG} 2>/dev/null |\
|
||||
grep -c -E -e "${_CRON_ENTRY}" 2>/dev/null)
|
||||
@ -112,8 +148,11 @@ do
|
||||
;;
|
||||
esac
|
||||
|
||||
# handle unit result
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
# report result
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
_STC=0
|
||||
done
|
||||
|
||||
@ -124,10 +163,14 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks the content of the 'root' user crontab for required entries
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
and formatted stanzas:
|
||||
cron:<cron_entry>
|
||||
PURPOSE : Checks the content of the 'root' user crontab for required entries
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_samba_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-17: initial version [Patrick Van der Veken]
|
||||
@ -29,6 +29,7 @@
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: add linux_has_systemd_service() [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -40,7 +41,7 @@ function check_linux_samba_status
|
||||
typeset _SMB_INIT_SCRIPT="/etc/init.d/samba"
|
||||
typeset _SMB_SYSTEMD_SERVICE="smb.service"
|
||||
typeset _NMB_SYSTEMD_SERVICE="nmb.service"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -51,6 +52,7 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _RC=0
|
||||
typeset _CHECK_SYSTEMD_SERVICE=0
|
||||
|
||||
@ -64,6 +66,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# 1) try using the init ways
|
||||
linux_get_init
|
||||
case "${LINUX_INIT}" in
|
||||
@ -139,7 +155,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of NMB/SMB"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -148,10 +167,10 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether SAMBA daemons are running
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether SAMBA daemons are running
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: changed format of stanzas in configuration file &
|
||||
# @(#) added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +39,7 @@ function check_linux_sg_cluster_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
@ -50,11 +52,14 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _SG_ENTRY=""
|
||||
typeset _SG_MATCH=""
|
||||
typeset _SG_CFG_PARAM=""
|
||||
typeset _SG_CFG_VALUE=""
|
||||
typeset _SG_RUN_VALUE=""
|
||||
typeset _IS_OLD_STYLE=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
@ -73,6 +78,38 @@ then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# check for old-style configuration file (non-prefixed stanzas)
|
||||
_IS_OLD_STYLE=$(grep -c -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null)
|
||||
if (( _IS_OLD_STYLE > 0 ))
|
||||
then
|
||||
warn "no 'sg:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check & get serviceguard status
|
||||
if [[ ! -x ${_SG_DAEMON} ]]
|
||||
@ -86,14 +123,14 @@ else
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# do cluster status checks
|
||||
# (replace ':' by '|' for cmcviewcl output)
|
||||
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
|
||||
while read _SG_ENTRY
|
||||
grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
|
||||
while read -r _ _SG_ENTRY
|
||||
do
|
||||
# field split
|
||||
_SG_CFG_PARAM="$(print ${_SG_ENTRY} | cut -f1 -d'=' 2>/dev/null)" # field 1
|
||||
@ -113,7 +150,10 @@ do
|
||||
_MSG="cluster parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]"
|
||||
_STC=1
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}"
|
||||
fi
|
||||
else
|
||||
warn "could not determine status for ${_SG_CFG_PARAM} from command output {cmviewcl}"
|
||||
fi
|
||||
@ -126,10 +166,14 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+)
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
and formatted stanzas:
|
||||
sg:<param>=<value>
|
||||
PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+)
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: changed format of stanzas in configuration file &
|
||||
# @(#) added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +39,7 @@ function check_linux_sg_package_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
@ -50,12 +52,15 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _CFG_HEALTHY=""
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _SG_ENTRY=""
|
||||
typeset _SG_MATCH=""
|
||||
typeset _SG_PACKAGE=""
|
||||
typeset _SG_CFG_PARAM=""
|
||||
typeset _SG_CFG_VALUE=""
|
||||
typeset _SG_RUN_VALUE=""
|
||||
typeset _IS_OLD_STYLE=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
@ -74,6 +79,38 @@ then
|
||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
||||
return 1
|
||||
fi
|
||||
_CFG_HEALTHY=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'log_healthy')
|
||||
case "${_CFG_HEALTHY}" in
|
||||
yes|YES|Yes)
|
||||
_LOG_HEALTHY=1
|
||||
;;
|
||||
*)
|
||||
# do not override hc_arg
|
||||
(( _LOG_HEALTHY > 0 )) || _LOG_HEALTHY=0
|
||||
;;
|
||||
esac
|
||||
|
||||
# check for old-style configuration file (non-prefixed stanzas)
|
||||
_IS_OLD_STYLE=$(grep -c -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null)
|
||||
if (( _IS_OLD_STYLE > 0 ))
|
||||
then
|
||||
warn "no 'sg:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check & get serviceguard status
|
||||
if [[ ! -x ${_SG_DAEMON} ]]
|
||||
@ -87,13 +124,14 @@ else
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
return 1
|
||||
}
|
||||
fi
|
||||
|
||||
# do package status checks
|
||||
# (replace ':' by '|' for cmcviewcl output)
|
||||
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null | while read _SG_ENTRY
|
||||
grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
|
||||
while read -r _ _SG_ENTRY
|
||||
do
|
||||
# field split
|
||||
_SG_PACKAGE="$(print ${_SG_ENTRY} | cut -f1 -d':')"
|
||||
@ -114,7 +152,10 @@ do
|
||||
_MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]"
|
||||
_STC=1
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}"
|
||||
fi
|
||||
else
|
||||
warn "could not determine status for ${_SG_PACKAGE}/${_SG_CFG_PARAM} from command output {cmviewcl}"
|
||||
fi
|
||||
@ -127,10 +168,14 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
and formatted stanzas:
|
||||
sg:<package_name>:<parameter>=<value>
|
||||
PURPOSE : Checks the status of Serviceguard package parameters (SG 11.16+)
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,12 +19,13 @@
|
||||
# @(#) MAIN: check_linux_sg_qs_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-05-01: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -33,7 +34,7 @@
|
||||
function check_linux_sg_qs_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
typeset _QS_BIN="/opt/qs/bin/qsc"
|
||||
typeset _QS_AUTH_FILE="/opt/qs/conf/qs_authfile"
|
||||
@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
@ -57,6 +59,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check QS presence
|
||||
if [[ ! -x ${_QS_BIN} ]]
|
||||
then
|
||||
@ -79,7 +95,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of QS"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
# ---- config state ----
|
||||
if [[ -s ${_QS_AUTH_FILE} ]]
|
||||
@ -90,7 +109,10 @@ else
|
||||
_MSG="QS authorizations file is missing or empty (${_QS_AUTH_FILE})"
|
||||
_STC=1
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -99,10 +121,10 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether the Serviceguard quorum server is running
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether the Serviceguard quorum server is running
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-12-01: initial version [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -33,7 +34,7 @@ function check_linux_shorewall_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _SHOREWALL_BIN="/sbin/shorewall"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -44,6 +45,7 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
for _ARG in ${_ARGS}
|
||||
@ -55,6 +57,19 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# check status
|
||||
if [[ -x ${_SHOREWALL_BIN} && -n "${_SHOREWALL_BIN}" ]]
|
||||
@ -69,7 +84,10 @@ then
|
||||
_MSG="shorewall is not running {shorewall status}"
|
||||
_STC=1
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
# check compile
|
||||
${_SHOREWALL_BIN} check >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
@ -81,7 +99,10 @@ then
|
||||
_MSG="shorewall rules do not compile correctly {shorewall check}"
|
||||
_STC=1
|
||||
fi
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
else
|
||||
warn "shorewall is not installed here"
|
||||
return 1
|
||||
@ -94,11 +115,11 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether shorewall (firewall) service is running and whether
|
||||
shorewall rules compile correctly
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether shorewall (firewall) service is running and whether
|
||||
shorewall rules compile correctly
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_sshd_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-12-01: initial version [Patrick Van der Veken]
|
||||
@ -28,6 +28,7 @@
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2018-11-18: add linux_has_systemd_service() [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -36,7 +37,7 @@
|
||||
function check_linux_sshd_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -50,6 +51,7 @@ typeset _SSHD_INIT_SCRIPT=""
|
||||
typeset _SSHD_SYSTEMD_SERVICE=""
|
||||
typeset _CHECK_SYSTEMD_SERVICE=0
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _RC=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
@ -62,6 +64,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# set init script & systemd service
|
||||
case "${LINUX_DISTRO}" in
|
||||
Debian)
|
||||
@ -126,7 +142,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of sshd"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -135,10 +154,10 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether sshd (Secure Shell daemon) is running
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether sshd (Secure Shell daemon) is running
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_linux_winbind_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: n/a
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc()
|
||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-05-17: initial version [Patrick Van der Veken]
|
||||
@ -27,6 +27,7 @@
|
||||
# @(#) 2017-05-08: fix fall-back for sysv->pgrep [Patrick Van der Veken]
|
||||
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
|
||||
# @(#) 2019-01-24: arguments fix [Patrick Van der Veken]
|
||||
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +38,7 @@ function check_linux_winbind_status
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _WINBIND_INIT_SCRIPT="/etc/init.d/winbind"
|
||||
typeset _WINBIND_SYSTEMD_SERVICE="winbind.service"
|
||||
typeset _VERSION="2019-01-24" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -48,6 +49,7 @@ typeset _ARGS=$(data_comma2space "$*")
|
||||
typeset _ARG=""
|
||||
typeset _MSG=""
|
||||
typeset _STC=0
|
||||
typeset _LOG_HEALTHY=0
|
||||
typeset _RC=0
|
||||
|
||||
# handle arguments (originally comma-separated)
|
||||
@ -60,6 +62,20 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# log_healthy
|
||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||
if (( _LOG_HEALTHY > 0 ))
|
||||
then
|
||||
if (( ARG_LOG > 0 ))
|
||||
then
|
||||
log "logging/showing passed health checks"
|
||||
else
|
||||
log "showing passed health checks (but not logging)"
|
||||
fi
|
||||
else
|
||||
log "not logging/showing passed health checks"
|
||||
fi
|
||||
|
||||
# 1) try using the init ways
|
||||
linux_get_init
|
||||
case "${LINUX_INIT}" in
|
||||
@ -105,7 +121,10 @@ case ${_STC} in
|
||||
_MSG="could not determine status of winbind"
|
||||
;;
|
||||
esac
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -114,10 +133,10 @@ return 0
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3
|
||||
PURPOSE : Checks whether Winbind (AD) is running
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
PURPOSE : Checks whether Winbind (AD) is running
|
||||
LOG HEALTHY : Supported
|
||||
|
||||
EOT
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user