added --log-healthy support to plugins, standardized format of configuration files

This commit is contained in:
patvdv 2019-03-10 11:10:59 +01:00
parent 4919949d4f
commit cf4683d6b8
37 changed files with 1071 additions and 277 deletions

View File

@ -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
install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib/platform/linux 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_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_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_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_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_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_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_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 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 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 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_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_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_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 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
%dir /opt/hc/lib/platform/linux %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_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_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_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_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_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_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_mysqld_status.sh
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_named_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 %attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
%dir /etc/opt/hc %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_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_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_file_change.conf.dist
%attr(644, root, root) /etc/opt/hc/check_linux_fs_usage.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 %attr(644, root, root) /etc/opt/hc/core/templates/mail_body.tpl-check_linux_root_crontab
%changelog %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 * Sun Feb 10 2019 <patrick@kudos.be> - 0.1.4
- Added check_linux_mysqld_status - Added check_linux_mysqld_status
* Thu Feb 07 2019 <patrick@kudos.be> - 0.1.3 * Thu Feb 07 2019 <patrick@kudos.be> - 0.1.3

View File

@ -6,11 +6,18 @@
# [default: indicates hardcoded script values if no value is defined here] # [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: # Examples:
#testclient1;0;10h #client:host1:0:10h
#testclient2;0;2d #client:host2:0:2d
#testclient3;0;5w #client:host3:0:5w
#****************************************************************************** #******************************************************************************

View 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
#******************************************************************************

View File

@ -6,9 +6,18 @@
# [default: indicates hardcoded script values if no value is defined here] # [default: indicates hardcoded script values if no value is defined here]
#****************************************************************************** #******************************************************************************
# file (full path); maximum age in minutes since last change # specify whether to also log passed health checks
/var/log/messages;60 # (warning: this may rapidly grow the HC log)
/var/log/ntp.log;30 # [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 # End of FILE

View File

@ -6,6 +6,11 @@
# [default: indicates hardcoded script values if no value is defined here] # [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 # name of the state file to use (will be relative to /var/opt/hc/state/persistent
# [default: discovered.file_change] # [default: discovered.file_change]
state_file=discovered.file_change state_file=discovered.file_change

View File

@ -6,6 +6,11 @@
# [default: indicates hardcoded script values if no value is defined here] # [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 # location of 'hpacucli' tool
hpacucli_bin="/usr/sbin/hpacucli" 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] # controller slot=X logicaldrive all show status (0=off, 1=on) [default: 1]
do_acu_logical=1 do_acu_logical=1
#****************************************************************************** #******************************************************************************
# End of FILE # End of FILE
#****************************************************************************** #******************************************************************************

View File

@ -6,6 +6,11 @@
# [default: indicates hardcoded script values if no value is defined here] # [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 # location of 'hpasmcli' tool
hpasmcli_bin="/sbin/hpasmcli" hpasmcli_bin="/sbin/hpasmcli"
@ -24,6 +29,7 @@ do_asm_server=1
# SHOW TEMPERATURE (0=off, 1=on) [default: 1] # SHOW TEMPERATURE (0=off, 1=on) [default: 1]
do_asm_temperature=1 do_asm_temperature=1
#****************************************************************************** #******************************************************************************
# End of FILE # End of FILE
#****************************************************************************** #******************************************************************************

View File

@ -6,6 +6,11 @@
# [default: indicates hardcoded script values if no value is defined here] # [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 # location of 'hpacucli' tool
hplog_bin="/sbin/hplog" hplog_bin="/sbin/hplog"

View File

@ -6,6 +6,11 @@
# [default: indicates hardcoded script values if no value is defined here] # [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 # location of 'hpssacli' tool
hpssacli_bin="/usr/sbin/hpssacli" hpssacli_bin="/usr/sbin/hpssacli"

View File

@ -6,8 +6,17 @@
# [default: indicates hardcoded script values if no value is defined here] # [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 # 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 # End of FILE

View File

@ -6,9 +6,16 @@
# [default: indicates hardcoded script values if no value is defined here] # [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: # Examples:
#status=up #sg:status=up
#****************************************************************************** #******************************************************************************

View File

@ -6,9 +6,16 @@
# [default: indicates hardcoded script values if no value is defined here] # [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: # Examples:
#my_package|status=up #sg:my_package:status=up
#****************************************************************************** #******************************************************************************

View File

@ -12,6 +12,7 @@
log_healthy="yes" log_healthy="yes"
# specify properties as displayed by the 'vzlist -a -H -o ctid,status,onboot' command # specify properties as displayed by the 'vzlist -a -H -o ctid,status,onboot' command
# Format:
# [ct:<ct_id>:<runtime_status>:<boot_status>] # [ct:<ct_id>:<runtime_status>:<boot_status>]
# runtime_status should be 'running' or 'stopped' # runtime_status should be 'running' or 'stopped'
# boot_status should be 'yes' or 'no' # boot_status should be 'yes' or 'no'

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_burp_backup # @(#) MAIN: check_linux_burp_backup
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: 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, # GNU date that can calculate UNIX epoch seconds from given date,
# BURP server must be be able to impersonate configured clients # 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-08-25: support for burp v2 [Patrick Van der Veken]
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2019-01-24: arguments fix [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! # 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_SERVER_CONFIG_FILE="/etc/burp/burp-server.conf"
typeset _BURP_CLIENT_CONFIG_FILE="/etc/burp/burp.conf" typeset _BURP_CLIENT_CONFIG_FILE="/etc/burp/burp.conf"
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -51,6 +53,8 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _BURP_BIN="" typeset _BURP_BIN=""
typeset _BURP_AGE="" typeset _BURP_AGE=""
typeset _BURP_BACKUP_DIR="" typeset _BURP_BACKUP_DIR=""
@ -60,6 +64,7 @@ typeset _BURP_VERSION=""
typeset _BURP_WARNINGS="" typeset _BURP_WARNINGS=""
typeset _GNU_DATE="" typeset _GNU_DATE=""
typeset _COUNT=1 typeset _COUNT=1
typeset _IS_OLD_STYLE=0
typeset _NOW="$(date '+%Y%m%d %H%M' 2>/dev/null)" # format: YYYYMMDD HHMM typeset _NOW="$(date '+%Y%m%d %H%M' 2>/dev/null)" # format: YYYYMMDD HHMM
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -79,6 +84,38 @@ then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi 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 # check for capable GNU date
_GNU_DATE=$(date --date="1 day ago" '+%s' 2>/dev/null) _GNU_DATE=$(date --date="1 day ago" '+%s' 2>/dev/null)
@ -146,8 +183,8 @@ case "${_BURP_VERSION}" in
esac esac
# check backup runs of clients # check backup runs of clients
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null |\ grep -E -e "^client:" ${_CONFIG_FILE} 2>/dev/null |\
while IFS=';' read _BURP_CLIENT _BURP_WARNINGS _BURP_AGE while IFS=':' read _ _BURP_CLIENT _BURP_WARNINGS _BURP_AGE
do do
typeset _BACKUP_AGING="" typeset _BACKUP_AGING=""
typeset _BACKUP_DATE="" typeset _BACKUP_DATE=""
@ -278,11 +315,14 @@ do
: :
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
_COUNT=$(( _COUNT + 1 )) _COUNT=$(( _COUNT + 1 ))
# save STDOUT # save STDOUT
if (( _STC =! 0 )) if (( _STC > 0 ))
then then
print "=== ${_BURP_CLIENT}: ${_BACKUP_RUN} ===" >>${HC_STDOUT_LOG} 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} ${_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}
@ -303,10 +343,13 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with: CONFIG : $3 with parameters:
backup_age=<days_till_last_backup> 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. 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) Should only be run only on a burp backup server (supports burp v1 and v2)
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,13 +19,14 @@
# @(#) MAIN: check_linux_burp_status # @(#) MAIN: check_linux_burp_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # 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: # @(#) HISTORY:
# @(#) 2016-12-01: initial version [Patrick Van der Veken] # @(#) 2016-12-01: initial version [Patrick Van der Veken]
# @(#) 2017-05-08: fix fall-back for sysv->pgrep [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] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2019-01-24: arguments 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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -36,7 +37,7 @@ function check_linux_burp_status
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _BURP_INIT_SCRIPT="/etc/init.d/burp" typeset _BURP_INIT_SCRIPT="/etc/init.d/burp"
typeset _BURP_SYSTEMD_SERVICE="burp.service" 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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -47,6 +48,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _RC=0 typeset _RC=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -59,6 +61,20 @@ do
esac esac
done 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 # 1) try using the init ways
linux_get_init linux_get_init
case "${LINUX_INIT}" in case "${LINUX_INIT}" in
@ -104,7 +120,10 @@ case ${_STC} in
_MSG="could not determine status of burp" _MSG="could not determine status of burp"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
return 0 return 0
} }
@ -115,8 +134,8 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether a Burp (backup server daemon) is running PURPOSE : Checks whether a Burp (backup server daemon) is running
LOG HEALTHY : Supported
EOT EOT

View 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
#******************************************************************************

View File

@ -19,13 +19,16 @@
# @(#) MAIN: check_linux_file_age # @(#) MAIN: check_linux_file_age
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: 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: # @(#) HISTORY:
# @(#) 2013-05-27: initial version [Patrick Van der Veken] # @(#) 2013-05-27: initial version [Patrick Van der Veken]
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2019-01-24: arguments fix [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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -35,7 +38,7 @@ function check_linux_file_age
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -46,12 +49,14 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _ENTRY="" typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _AGE_CHECK="" typeset _AGE_CHECK=""
typeset _FILE_PATH="" typeset _FILE_PATH=""
typeset _FILE_AGE="" typeset _FILE_AGE=""
typeset _FILE_NAME="" typeset _FILE_NAME=""
typeset _FILE_DIR="" typeset _FILE_DIR=""
typeset _IS_OLD_STYLE=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
for _ARG in ${_ARGS} for _ARG in ${_ARGS}
@ -70,14 +75,41 @@ then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi 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 # 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 do
# field split
_FILE_PATH=$(print "${_ENTRY%%;*}")
_FILE_AGE=$(print "${_ENTRY##*;}")
# split file/dir # split file/dir
_FILE_NAME=$(print "${_FILE_PATH##*/}") _FILE_NAME=$(print "${_FILE_PATH##*/}")
_FILE_DIR=$(print "${_FILE_PATH%/*}") _FILE_DIR=$(print "${_FILE_PATH%/*}")
@ -88,16 +120,12 @@ do
warn "missing values in configuration file at ${_CONFIG_FILE}" warn "missing values in configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi fi
case "${_FILE_AGE}" in data_is_numeric "${_FILE_AGE}"
+([0-9])*(.)*([0-9])) if (( $? > 0 ))
# numeric, OK then
;;
*)
# not numeric
warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}" warn "invalid file age value '${_FILE_AGE}' in configuration file at ${_CONFIG_FILE}"
return 1 return 1
;; fi
esac
# perform check # perform check
if [[ ! -r "${_FILE_PATH}" ]] if [[ ! -r "${_FILE_PATH}" ]]
@ -120,8 +148,11 @@ do
fi fi
fi fi
# handle unit result # report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0 _STC=0
done done
@ -134,10 +165,13 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with: CONFIG : $3 with parameters:
<file_name>;<maximum_age_in_minutes> 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 PURPOSE : Checks whether given files have been changed in the last n minutes
(requires GNU find) (requires GNU find)
LOG HEALTHY : Supported
EOT EOT

View File

@ -28,6 +28,8 @@
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2018-11-18: do not trap on signal 0 [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -37,7 +39,7 @@ function check_linux_file_change
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -48,6 +50,8 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _DO_META_CHECK=0 typeset _DO_META_CHECK=0
typeset _CFG_STATE_FILE="" typeset _CFG_STATE_FILE=""
typeset _STATE_FILE="" typeset _STATE_FILE=""
@ -112,6 +116,29 @@ case "${_DO_META_CHECK}" in
log "check for meta characters is enabled" log "check for meta characters is enabled"
;; ;;
esac 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 # check for checksum tools
_OPENSSL_BIN="$(which openssl 2>>${HC_STDERR_LOG})" _OPENSSL_BIN="$(which openssl 2>>${HC_STDERR_LOG})"
@ -294,7 +321,7 @@ do
fi fi
# bounce failures back and jump to next file # bounce failures back and jump to next file
if (( _STC > 0 )) if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
continue continue
@ -351,7 +378,9 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with formatted stanzas: CONFIG : $3 with parameters:
log_healthy=<yes|no>
with formatted stanzas:
incl:<full path> incl:<full path>
excl:<full path> excl:<full path>
PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and excludes
@ -366,7 +395,7 @@ PURPOSE : a KISS file integrity checker (like AIDE). Supports includes and exclu
Processing a big number of files is likely to take Processing a big number of files is likely to take
ages and probably will cause the plugin to time out ages and probably will cause the plugin to time out
(see HC_TIME_OUT). YMMV. (see HC_TIME_OUT). YMMV.
LOG HEALTHY : Supported
EOT EOT

View File

@ -27,6 +27,7 @@
# @(#) 2018-08-25: small fix [Patrick Van der Veken] # @(#) 2018-08-25: small fix [Patrick Van der Veken]
# @(#) 2018-10-02: regex fix [Patrick Van der Veken] # @(#) 2018-10-02: regex fix [Patrick Van der Veken]
# @(#) 2019-01-24: arguments 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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -35,7 +36,7 @@
function check_linux_fs_mounts function check_linux_fs_mounts
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- 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 _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _FS="" typeset _FS=""
typeset _FS_COUNT=0 typeset _FS_COUNT=0
@ -59,6 +61,20 @@ do
esac esac
done 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) # collect data (mount only)
mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} mount >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
if (( $? > 0 )) if (( $? > 0 ))
@ -89,8 +105,11 @@ do
;; ;;
esac esac
# handle unit result # report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0 _STC=0
done done
@ -106,9 +125,9 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether file systems are mounted or not, exclude following FS types: PURPOSE : Checks whether file systems are mounted or not, exclude following FS types:
proc, swap, sysfs, devpts, tmpfs, cdrom & floppy proc, swap, sysfs, devpts, tmpfs, cdrom & floppy
LOG HEALTHY : Supported
EOT EOT

View File

@ -316,15 +316,15 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with formatted stanzas (optional): CONFIG : $3 with parameters:
fs:<fs_name>:<max_INODES_USAGE_in_%>:<max_space_usage_in%>
Other options:
log_healthy=<yes|no> log_healthy=<yes|no>
check_inodes_usage=<yes|no> check_inodes_usage=<yes|no>
check_space_usage=<yes|no> check_space_usage=<yes|no>
max_inodes_usage=<general_inodes_usage_treshold> max_inodes_usage=<general_inodes_usage_treshold>
max_space_usage=<general_space_usage_treshold> max_space_usage=<general_space_usage_treshold>
EXT OPTS : --hc-args=check_inodes, --hc-args=check_space 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 PURPOSE : Checks the inodes & space usage for the configured or all (local) filesystems
LOG HEALTHY : Supported LOG HEALTHY : Supported

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_hpacucli # @(#) MAIN: check_linux_hpacucli
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: 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: # @(#) HISTORY:
# @(#) 2013-09-09: initial version [Patrick Van der Veken] # @(#) 2013-09-09: initial version [Patrick Van der Veken]
@ -27,6 +27,8 @@
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2018-11-18: do not trap on signal 0 [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -36,7 +38,7 @@ function check_linux_hpacucli
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -47,6 +49,8 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC_COUNT=0 typeset _STC_COUNT=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$" typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$"
typeset _HPACUCLI_BIN="" typeset _HPACUCLI_BIN=""
typeset _ACU_LINE="" typeset _ACU_LINE=""
@ -138,6 +142,29 @@ then
log "switching setting 'do_acu_controller' to 1 to fetch slot info" log "switching setting 'do_acu_controller' to 1 to fetch slot info"
_DO_ACU_CTRL=1 _DO_ACU_CTRL=1
fi 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 # check for HP tools
if [[ ! -x ${_HPACUCLI_BIN} || -z "${_HPACUCLI_BIN}" ]] if [[ ! -x ${_HPACUCLI_BIN} || -z "${_HPACUCLI_BIN}" ]]
@ -158,7 +185,6 @@ then
do do
_MSG="failure in controller" _MSG="failure in controller"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU controller(s) ===" >>${HC_STDOUT_LOG} 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 cat ${_TMP_FILE} | grep "in Slot [0-9]" 2>/dev/null | while read _ACU_LINE
do do
_SLOT_NUM="$(print ${_ACU_LINE} | cut -f6 -d' ' 2>/dev/null)" _SLOT_NUM="$(print ${_ACU_LINE} | cut -f6 -d' ' 2>/dev/null)"
case "${_DO_ACU_LOGL}" in data_is_numeric "${_SLOT_NUM}"
+([0-9])*([0-9])) if (( $? == 0 ))
# numeric OK then
_SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}" _SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}"
;; else
*)
# non-numeric
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}" warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
;; fi
esac
done done
else else
warn "${_HPACUCLI_BIN}: do_acu_controller check is not enabled" warn "${_HPACUCLI_BIN}: do_acu_controller check is not enabled"
@ -197,7 +220,6 @@ then
do do
_MSG="failure in enclosure for controller ${_CTRL_SLOT}" _MSG="failure in enclosure for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU enclosure(s) ===" >>${HC_STDOUT_LOG} print "=== ACU enclosure(s) ===" >>${HC_STDOUT_LOG}
@ -222,7 +244,6 @@ then
do do
_MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU physical drive(s) ===" >>${HC_STDOUT_LOG} print "=== ACU physical drive(s) ===" >>${HC_STDOUT_LOG}
@ -247,7 +268,6 @@ then
do do
_MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ACU logical drive(s) ===" >>${HC_STDOUT_LOG} print "=== ACU logical drive(s) ===" >>${HC_STDOUT_LOG}
@ -258,7 +278,7 @@ else
fi fi
# report OK situation # report OK situation
if (( _STC_COUNT == 0 )) if (( _LOG_HEALTHY > 0 && _STC_COUNT == 0 ))
then then
_MSG="no problems detected by {${_HPACUCLI_BIN}}" _MSG="no problems detected by {${_HPACUCLI_BIN}}"
log_hc "$0" 0 "${_MSG}" log_hc "$0" 0 "${_MSG}"
@ -276,14 +296,16 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with: CONFIG : $3 with parameters:
log_healthy=<yes|no>
hpacucli_bin=<location_of_hpacucli_tool> hpacucli_bin=<location_of_hpacucli_tool>
do_acu_controller=0|1 do_acu_controller=<0|1>
do_acu_enclosure=0|1 do_acu_enclosure=<0|1>
do_acu_physical=0|1 do_acu_physical=<0|1>
do_acu_logical=0|1 do_acu_logical=<0|1>
PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant
support pack (PSP)) support pack (PSP))
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_hpasmcli # @(#) MAIN: check_linux_hpasmcli
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: see _show_usage() # EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), init_hc(), log_hc() # REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
# #
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2013-09-07: initial version [Patrick Van der Veken] # @(#) 2013-09-07: initial version [Patrick Van der Veken]
@ -28,6 +28,7 @@
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2018-11-18: do not trap on signal 0 [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -37,7 +38,7 @@ function check_linux_hpasmcli
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -48,6 +49,8 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC_COUNT=0 typeset _STC_COUNT=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$" typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$"
typeset _HPASMCLI_BIN="" typeset _HPASMCLI_BIN=""
typeset _ASM_LINE="" typeset _ASM_LINE=""
@ -146,6 +149,30 @@ case "${_DO_ASM_TEMP}" in
_DO_ASM_TEMP=1 _DO_ASM_TEMP=1
;; ;;
esac 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 # check for HP tools
if [[ ! -x ${_HPASMCLI_BIN} || -z "${_HPASMCLI_BIN}" ]] if [[ ! -x ${_HPASMCLI_BIN} || -z "${_HPASMCLI_BIN}" ]]
@ -167,7 +194,6 @@ then
_FAN_UNIT="$(print ${_ASM_LINE} | cut -f1 -d' ')" _FAN_UNIT="$(print ${_ASM_LINE} | cut -f1 -d' ')"
_MSG="failure in 'SHOW FANS', unit ${_FAN_UNIT}" _MSG="failure in 'SHOW FANS', unit ${_FAN_UNIT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ASM fans ===" >>${HC_STDOUT_LOG} print "=== ASM fans ===" >>${HC_STDOUT_LOG}
@ -187,7 +213,6 @@ then
do do
_MSG="failure in 'SHOW DIMM'" _MSG="failure in 'SHOW DIMM'"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ASM DIMMs ===" >>${HC_STDOUT_LOG} print "=== ASM DIMMs ===" >>${HC_STDOUT_LOG}
@ -207,7 +232,6 @@ then
do do
_MSG="failure in 'SHOW POWERSUPPLY'" _MSG="failure in 'SHOW POWERSUPPLY'"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ASM power supply ===" >>${HC_STDOUT_LOG} print "=== ASM power supply ===" >>${HC_STDOUT_LOG}
@ -227,7 +251,6 @@ then
do do
_MSG="failure in 'SHOW SERVER'" _MSG="failure in 'SHOW SERVER'"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== ASM server ===" >>${HC_STDOUT_LOG} print "=== ASM server ===" >>${HC_STDOUT_LOG}
@ -257,7 +280,6 @@ then
_MSG="failure in 'SHOW TEMP', unit ${_TEMP_UNIT}" _MSG="failure in 'SHOW TEMP', unit ${_TEMP_UNIT}"
_MSG="${_MSG} has ${_TEMP_VALUE} >= ${_THRES_VALUE}" _MSG="${_MSG} has ${_TEMP_VALUE} >= ${_THRES_VALUE}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" "${_TEMP_VALUE}" "${_THRES_VALUE}" log_hc "$0" 1 "${_MSG}" "${_TEMP_VALUE}" "${_THRES_VALUE}"
fi fi
fi fi
@ -269,7 +291,7 @@ else
fi fi
# report OK situation # report OK situation
if (( _STC_COUNT == 0 )) if (( _LOG_HEALTHY > 0 && _STC_COUNT == 0 ))
then then
_MSG="no problems detected by {${_HPASMCLI_BIN}}" _MSG="no problems detected by {${_HPASMCLI_BIN}}"
log_hc "$0" 0 "${_MSG}" log_hc "$0" 0 "${_MSG}"
@ -287,15 +309,17 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with: CONFIG : $3 with paramets:
log_healthy=<yes|no>
hpasmcli_bin=<location_of_hpasmcli_tool> hpasmcli_bin=<location_of_hpasmcli_tool>
do_asm_fans=0|1 do_asm_fans=<0|1>
do_asm_dimm=0|1 do_asm_dimm=<0|1>
do_asm_powersupply=0|1 do_asm_powersupply=<0|1>
do_asm_server=0|1 do_asm_server=<0|1>
do_asm_temperature=0|1 do_asm_temperature=<0|1>
PURPOSE : Checks for errors from the HP Proliant 'hpasmcli' tool (see HP Proliant PURPOSE : Checks for errors from the HP Proliant 'hpasmcli' tool (see HP Proliant
support pack (PSP)) support pack (PSP))
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_hplog # @(#) MAIN: check_linux_hplog
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: 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: # @(#) HISTORY:
# @(#) 2017-04-22: initial version [Patrick Van der Veken] # @(#) 2017-04-22: initial version [Patrick Van der Veken]
@ -27,6 +27,7 @@
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2018-11-18: do not trap on signal 0 [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -49,6 +50,8 @@ typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _STC_COUNT=0 typeset _STC_COUNT=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _TMP1_FILE="${TMP_DIR}/.$0.tmp1.$$" typeset _TMP1_FILE="${TMP_DIR}/.$0.tmp1.$$"
typeset _TMP2_FILE="${TMP_DIR}/.$0.tmp2.$$" typeset _TMP2_FILE="${TMP_DIR}/.$0.tmp2.$$"
typeset _HPLOG_BIN="" typeset _HPLOG_BIN=""
@ -102,6 +105,29 @@ else
# delete last 'OR' # delete last 'OR'
_HPLOG_SEVERITIES=${_HPLOG_SEVERITIES%?} _HPLOG_SEVERITIES=${_HPLOG_SEVERITIES%?}
fi 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 # check hplog utility
if [[ ! -x ${_HPLOG_BIN} || -z "${_HPLOG_BIN}" ]] 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}" log_hc "$0" 1 "${_MSG}"
# dump debug info # dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 0 return 1
} }
# check state file # check state file
@ -142,7 +168,6 @@ while read -r _EVENT_ENTRY
do do
_MSG="${_EVENT_ENTRY}" _MSG="${_EVENT_ENTRY}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done <${_TMP2_FILE} done <${_TMP2_FILE}
if (( _STC_COUNT > 0 )) if (( _STC_COUNT > 0 ))
@ -158,7 +183,10 @@ then
else else
_MSG="no new HPLOG messages found" _MSG="no new HPLOG messages found"
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
# do cleanup # do cleanup
[[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1 [[ -f ${_TMP1_FILE} ]] && rm -f ${_TMP1_FILE} >/dev/null 2>&1
@ -173,11 +201,13 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with: CONFIG : $3 with parameters:
log_healthy=<yes|no>
hplog_bin=<location_of_hplog_tool> hplog_bin=<location_of_hplog_tool>
hplog_severities=<list_of_severities_to_search_for> hplog_severities=<list_of_severities_to_search_for>
PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant PURPOSE : Checks for errors from the HP Proliant 'hpacucli' tool (see HP Proliant
support pack (PSP)) support pack (PSP))
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_hpssacli # @(#) MAIN: check_linux_hpssacli
# DOES: _show_usage() # DOES: _show_usage()
# EXPECTS: _show_usage() # EXPECTS: _show_usage()
# REQUIRES: data_comma2space(), init_hc(), log_hc() # REQUIRES: data_comma2space(), data_is_numeric(), init_hc(), log_hc(), warn()
# #
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2016-04-01: initial version [Patrick Van der Veken] # @(#) 2016-04-01: initial version [Patrick Van der Veken]
@ -27,6 +27,8 @@
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2018-11-18: do not trap on signal 0 [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -36,7 +38,7 @@ function check_linux_hpssacli
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -47,6 +49,8 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC_COUNT=0 typeset _STC_COUNT=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$" typeset _TMP_FILE="${TMP_DIR}/.$0.tmp.$$"
typeset _HPSSACLI_BIN="" typeset _HPSSACLI_BIN=""
typeset _SSA_LINE="" typeset _SSA_LINE=""
@ -138,6 +142,29 @@ then
log "switching setting 'do_ssa_controller' to 1 to fetch slot info" log "switching setting 'do_ssa_controller' to 1 to fetch slot info"
_DO_SSA_CTRL=1 _DO_SSA_CTRL=1
fi 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 # check for HP tools
if [[ ! -x ${_HPSSACLI_BIN} || -z "${_HPSSACLI_BIN}" ]] if [[ ! -x ${_HPSSACLI_BIN} || -z "${_HPSSACLI_BIN}" ]]
@ -158,7 +185,6 @@ then
do do
_MSG="failure in controller" _MSG="failure in controller"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA controller(s) ===" >>${HC_STDOUT_LOG} 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 cat ${_TMP_FILE} | grep "in Slot [0-9]" 2>/dev/null | while read _SSA_LINE
do do
_SLOT_NUM="$(print ${_SSA_LINE} | cut -f6 -d' ' 2>/dev/null)" _SLOT_NUM="$(print ${_SSA_LINE} | cut -f6 -d' ' 2>/dev/null)"
case "${_DO_SSA_LOGL}" in data_is_numeric "${_SLOT_NUM}"
+([0-9])*([0-9])) if (( $? == 0 ))
# numeric OK then
_SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}" _SLOT_NUMS="${_SLOT_NUMS} ${_SLOT_NUM}"
;; else
*)
# non-numeric
warn "found RAID controller at illegal slot?: ${_SLOT_NUM}" warn "found RAID controller at illegal slot?: ${_SLOT_NUM}"
;; fi
esac
done done
else else
warn "${_HPSSACLI_BIN}: do_ssa_controller check is not enabled" warn "${_HPSSACLI_BIN}: do_ssa_controller check is not enabled"
@ -197,7 +220,6 @@ then
do do
_MSG="failure in enclosure for controller ${_CTRL_SLOT}" _MSG="failure in enclosure for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA enclosure(s) ===" >>${HC_STDOUT_LOG} print "=== SSA enclosure(s) ===" >>${HC_STDOUT_LOG}
@ -222,7 +244,6 @@ then
do do
_MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in physical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA physical drive(s) ===" >>${HC_STDOUT_LOG} print "=== SSA physical drive(s) ===" >>${HC_STDOUT_LOG}
@ -247,7 +268,6 @@ then
do do
_MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}" _MSG="failure in logical drive(s) for controller ${_CTRL_SLOT}"
_STC_COUNT=$(( _STC_COUNT + 1 )) _STC_COUNT=$(( _STC_COUNT + 1 ))
# handle unit result
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
done done
print "=== SSA logical drive(s) ===" >>${HC_STDOUT_LOG} print "=== SSA logical drive(s) ===" >>${HC_STDOUT_LOG}
@ -258,7 +278,7 @@ else
fi fi
# report OK situation # report OK situation
if (( _STC_COUNT == 0 )) if (( _LOG_HEALTHY > 0 && _STC_COUNT > 0 ))
then then
_MSG="no problems detected by {${_HPSSACLI_BIN}}" _MSG="no problems detected by {${_HPSSACLI_BIN}}"
log_hc "$0" 0 "${_MSG}" log_hc "$0" 0 "${_MSG}"
@ -275,14 +295,16 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 with: CONFIG : $3 with parameters:
log_healthy=<yes|no>
hpssacli_bin=<location_of_hpssacli_tool> hpssacli_bin=<location_of_hpssacli_tool>
do_ssa_controller=0|1 do_ssa_controller=<0|1>
do_ssa_enclosure=0|1 do_ssa_enclosure=<0|1>
do_ssa_physical=0|1 do_ssa_physical=<0|1>
do_ssa_logical=0|1 do_ssa_logical=<0|1>
PURPOSE : Checks for errors from the HP Proliant 'hpssacli' tool (see HP Proliant PURPOSE : Checks for errors from the HP Proliant 'hpssacli' tool (see HP Proliant
support pack (PSP)) support pack (PSP))
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_httpd_status # @(#) MAIN: check_linux_httpd_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # 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: # @(#) HISTORY:
# @(#) 2017-04-23: initial version [Patrick Van der Veken] # @(#) 2017-04-23: initial version [Patrick Van der Veken]
@ -28,6 +28,7 @@
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-11-18: add linux_has_systemd_service() [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -38,7 +39,7 @@ function check_linux_httpd_status
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _HTTPD_INIT_SCRIPT="/etc/init.d/httpd" typeset _HTTPD_INIT_SCRIPT="/etc/init.d/httpd"
typeset _HTTPD_SYSTEMD_SERVICE="httpd.service" 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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -51,6 +52,7 @@ typeset _CHECK_SYSTEMD_SERVICE=0
typeset _HTTPD_BIN="" typeset _HTTPD_BIN=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _RC=0 typeset _RC=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -63,6 +65,20 @@ do
esac esac
done 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 ---- # ---- process state ----
# 1) try using the init ways # 1) try using the init ways
linux_get_init linux_get_init
@ -117,7 +133,10 @@ case ${_STC} in
_MSG="could not determine status of httpd" _MSG="could not determine status of httpd"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
# ---- config state ---- # ---- config state ----
_HTTPD_BIN="$(which httpd 2>>${HC_STDERR_LOG})" _HTTPD_BIN="$(which httpd 2>>${HC_STDERR_LOG})"
@ -133,8 +152,11 @@ then
_MSG="httpd configuration files have syntax error(s) {httpd -s}" _MSG="httpd configuration files have syntax error(s) {httpd -s}"
_STC=1 _STC=1
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi fi
fi
return 0 return 0
} }
@ -145,9 +167,9 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether httpd (apache service) is running and whether the PURPOSE : Checks whether httpd (apache service) is running and whether the
httpd configuration files are syntactically correct httpd configuration files are syntactically correct
LOG HEALTHY : Supported
EOT EOT

View File

@ -24,6 +24,7 @@
# #
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2019-02-10: initial version [Patrick Van der Veken] # @(#) 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! # 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 _MYSQLD_SYSTEMD_SERVICE="mysqld.service"
typeset _MARIADB_INIT_SCRIPT="/etc/init.d/mariadb" typeset _MARIADB_INIT_SCRIPT="/etc/init.d/mariadb"
typeset _MARIADB_SYSTEMD_SERVICE="mariadb.service" 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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -100,7 +101,7 @@ esac
_CFG_MYSQL_USER=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_user') _CFG_MYSQL_USER=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_user')
if [[ -z "${_CFG_MYSQL_USER}" ]] if [[ -z "${_CFG_MYSQL_USER}" ]]
then then
warn "no value for 'mysql_user specified in ${_CONFIG_FILE}" warn "no value for 'mysql_user' specified in ${_CONFIG_FILE}"
_DO_MYSQLCHECK=0 _DO_MYSQLCHECK=0
else else
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --user=${_CFG_MYSQL_USER}" _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') _CFG_MYSQL_PASSWORD=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_password')
if [[ -z "${_CFG_MYSQL_PASSWORD}" ]] if [[ -z "${_CFG_MYSQL_PASSWORD}" ]]
then then
warn "no value for 'mysql_password specified in ${_CONFIG_FILE}" warn "no value for 'mysql_password' specified in ${_CONFIG_FILE}"
_DO_MYSQLCHECK=0 _DO_MYSQLCHECK=0
else else
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --password=${_CFG_MYSQL_PASSWORD}" _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') _CFG_MYSQL_HOST=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_host')
if [[ -z "${_CFG_MYSQL_HOST}" ]] if [[ -z "${_CFG_MYSQL_HOST}" ]]
then 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 else
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --host=${_CFG_MYSQL_HOST}" _MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --host=${_CFG_MYSQL_HOST}"
_MYSQLSHOW_OPTS="${_MYSQLSHOW_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') _CFG_MYSQL_PORT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'mysql_port')
if [[ -z "${_CFG_MYSQL_PORT}" ]] if [[ -z "${_CFG_MYSQL_PORT}" ]]
then 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 else
_MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --port=${_CFG_MYSQL_PORT}" _MYSQLCHECK_OPTS="${_MYSQLCHECK_OPTS} --port=${_CFG_MYSQL_PORT}"
_MYSQLSHOW_OPTS="${_MYSQLSHOW_OPTS} --port=${_CFG_MYSQL_PORT}" _MYSQLSHOW_OPTS="${_MYSQLSHOW_OPTS} --port=${_CFG_MYSQL_PORT}"

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_named_status # @(#) MAIN: check_linux_named_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # 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: # @(#) HISTORY:
# @(#) 2013-12-01: initial version [Patrick Van der Veken] # @(#) 2013-12-01: initial version [Patrick Van der Veken]
@ -27,6 +27,7 @@
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-11-18: add linux_has_systemd_service() [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -35,7 +36,7 @@
function check_linux_named_status function check_linux_named_status
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- 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 _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _CHECK_SYSTEMD_SERVICE=0 typeset _CHECK_SYSTEMD_SERVICE=0
typeset _NAMED_CHECKCONF_BIN="" typeset _NAMED_CHECKCONF_BIN=""
typeset _NAMED_INIT_SCRIPT="" typeset _NAMED_INIT_SCRIPT=""
@ -62,6 +64,20 @@ do
esac esac
done 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 # set init script & systemd service
case "${LINUX_DISTRO}" in case "${LINUX_DISTRO}" in
Debian) Debian)
@ -128,7 +144,10 @@ case ${_STC} in
_MSG="could not determine status of named" _MSG="could not determine status of named"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
# ---- config state ---- # ---- config state ----
_NAMED_CHECKCONF_BIN="$(which named-checkconf 2>>${HC_STDERR_LOG})" _NAMED_CHECKCONF_BIN="$(which named-checkconf 2>>${HC_STDERR_LOG})"
@ -144,8 +163,11 @@ then
_MSG="named configuration and/or zone files have syntax error(s) {named-checkconf -z}" _MSG="named configuration and/or zone files have syntax error(s) {named-checkconf -z}"
_STC=1 _STC=1
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi fi
fi
return 0 return 0
} }
@ -157,9 +179,9 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether named (BIND) is running and whether the named zone PURPOSE : Checks whether named (BIND) is running and whether the named zone
files are syntactically correct. files are syntactically correct.
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_postfix_status # @(#) MAIN: check_linux_postfix_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # 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: # @(#) HISTORY:
# @(#) 2016-12-01: initial version [Patrick Van der Veken] # @(#) 2016-12-01: initial version [Patrick Van der Veken]
@ -28,6 +28,7 @@
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-11-18: add linux_has_systemd_service() [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -50,6 +51,7 @@ typeset _ARG=""
typeset _POSTFIX_BIN="" typeset _POSTFIX_BIN=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _RC=0 typeset _RC=0
typeset _CHECK_SYSTEMD_SERVICE=0 typeset _CHECK_SYSTEMD_SERVICE=0
@ -63,6 +65,20 @@ do
esac esac
done 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 # 1) try using the init ways
linux_get_init linux_get_init
case "${LINUX_INIT}" in case "${LINUX_INIT}" in
@ -126,7 +142,10 @@ case ${_STC} in
_MSG="could not determine status of postfix" _MSG="could not determine status of postfix"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
return 0 return 0
} }
@ -137,8 +156,8 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether postfix (mail system) is running PURPOSE : Checks whether postfix (mail system) is running
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,12 +19,14 @@
# @(#) MAIN: check_linux_root_crontab # @(#) MAIN: check_linux_root_crontab
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: see _show_usage() # EXPECTS: see _show_usage()
# REQUIRES: data_comma2space(), init_hc(), log_hc() # REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
# #
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2013-09-19: initial version [Patrick Van der Veken] # @(#) 2013-09-19: initial version [Patrick Van der Veken]
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2019-01-24: arguments fix [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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -34,7 +36,7 @@ function check_linux_root_crontab
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -45,9 +47,12 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _CRON_LINE="" typeset _CRON_LINE=""
typeset _CRON_ENTRY="" typeset _CRON_ENTRY=""
typeset _CRON_MATCH=0 typeset _CRON_MATCH=0
typeset _IS_OLD_STYLE=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
for _ARG in ${_ARGS} for _ARG in ${_ARGS}
@ -66,6 +71,37 @@ then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi 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 # collect data, since Linux can have multiple cron sources we will
# squash them all together, standard cron, vixie, anacron, you name it :) # 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} print "=== /etc/cron.d ===" >>${HC_STDOUT_LOG}
if [[ -d /etc/cron.d ]] if [[ -d /etc/cron.d ]]
then then
cat /etc/cron.d/* | while read _CRON_LINE cat /etc/cron.d/* 2>/dev/null | while read _CRON_LINE
do do
if [[ $(print "${_CRON_LINE}" | awk '{print $6}' 2>/dev/null) == "root" ]] if [[ $(print "${_CRON_LINE}" | awk '{print $6}' 2>/dev/null) == "root" ]]
then then
@ -95,7 +131,7 @@ then
fi fi
# perform check # 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 do
_CRON_MATCH=$(grep -v '^#' ${HC_STDOUT_LOG} 2>/dev/null |\ _CRON_MATCH=$(grep -v '^#' ${HC_STDOUT_LOG} 2>/dev/null |\
grep -c -E -e "${_CRON_ENTRY}" 2>/dev/null) grep -c -E -e "${_CRON_ENTRY}" 2>/dev/null)
@ -112,8 +148,11 @@ do
;; ;;
esac esac
# handle unit result # report result
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
_STC=0 _STC=0
done done
@ -126,8 +165,12 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 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 PURPOSE : Checks the content of the 'root' user crontab for required entries
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_samba_status # @(#) MAIN: check_linux_samba_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # 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: # @(#) HISTORY:
# @(#) 2013-05-17: initial version [Patrick Van der Veken] # @(#) 2013-05-17: initial version [Patrick Van der Veken]
@ -29,6 +29,7 @@
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-11-18: add linux_has_systemd_service() [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-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! # 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_INIT_SCRIPT="/etc/init.d/samba"
typeset _SMB_SYSTEMD_SERVICE="smb.service" typeset _SMB_SYSTEMD_SERVICE="smb.service"
typeset _NMB_SYSTEMD_SERVICE="nmb.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -51,6 +52,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _RC=0 typeset _RC=0
typeset _CHECK_SYSTEMD_SERVICE=0 typeset _CHECK_SYSTEMD_SERVICE=0
@ -64,6 +66,20 @@ do
esac esac
done 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 # 1) try using the init ways
linux_get_init linux_get_init
case "${LINUX_INIT}" in case "${LINUX_INIT}" in
@ -139,7 +155,10 @@ case ${_STC} in
_MSG="could not determine status of NMB/SMB" _MSG="could not determine status of NMB/SMB"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
return 0 return 0
} }
@ -150,8 +169,8 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether SAMBA daemons are running PURPOSE : Checks whether SAMBA daemons are running
LOG HEALTHY : Supported
EOT EOT

View File

@ -28,6 +28,8 @@
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2019-01-24: arguments fix [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! # 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 ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -50,11 +52,14 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _SG_ENTRY="" typeset _SG_ENTRY=""
typeset _SG_MATCH="" typeset _SG_MATCH=""
typeset _SG_CFG_PARAM="" typeset _SG_CFG_PARAM=""
typeset _SG_CFG_VALUE="" typeset _SG_CFG_VALUE=""
typeset _SG_RUN_VALUE="" typeset _SG_RUN_VALUE=""
typeset _IS_OLD_STYLE=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
for _ARG in ${_ARGS} for _ARG in ${_ARGS}
@ -73,6 +78,38 @@ then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi 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 # check & get serviceguard status
if [[ ! -x ${_SG_DAEMON} ]] if [[ ! -x ${_SG_DAEMON} ]]
@ -86,14 +123,14 @@ else
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
# dump debug info # dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 0 return 1
} }
fi fi
# do cluster status checks # do cluster status checks
# (replace ':' by '|' for cmcviewcl output) # (replace ':' by '|' for cmcviewcl output)
grep -v -E -e '^$' -e '^#' ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\ grep -E -e "^sg:" ${_CONFIG_FILE} 2>/dev/null | tr '|' ':' 2>/dev/null |\
while read _SG_ENTRY while read -r _ _SG_ENTRY
do do
# field split # field split
_SG_CFG_PARAM="$(print ${_SG_ENTRY} | cut -f1 -d'=' 2>/dev/null)" # field 1 _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}]" _MSG="cluster parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]"
_STC=1 _STC=1
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}"
fi
else else
warn "could not determine status for ${_SG_CFG_PARAM} from command output {cmviewcl}" warn "could not determine status for ${_SG_CFG_PARAM} from command output {cmviewcl}"
fi fi
@ -128,8 +168,12 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 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+) PURPOSE : Checks the status of Serviceguard cluster parameters (SG 11.16+)
LOG HEALTHY : Supported
EOT EOT

View File

@ -28,6 +28,8 @@
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken] # @(#) 2018-10-28: fixed (linter) errors [Patrick Van der Veken]
# @(#) 2019-01-24: arguments fix [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! # 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 ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld" typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -50,12 +52,15 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _CFG_HEALTHY=""
typeset _LOG_HEALTHY=0
typeset _SG_ENTRY="" typeset _SG_ENTRY=""
typeset _SG_MATCH="" typeset _SG_MATCH=""
typeset _SG_PACKAGE="" typeset _SG_PACKAGE=""
typeset _SG_CFG_PARAM="" typeset _SG_CFG_PARAM=""
typeset _SG_CFG_VALUE="" typeset _SG_CFG_VALUE=""
typeset _SG_RUN_VALUE="" typeset _SG_RUN_VALUE=""
typeset _IS_OLD_STYLE=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
for _ARG in ${_ARGS} for _ARG in ${_ARGS}
@ -74,6 +79,38 @@ then
warn "unable to read configuration file at ${_CONFIG_FILE}" warn "unable to read configuration file at ${_CONFIG_FILE}"
return 1 return 1
fi 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 # check & get serviceguard status
if [[ ! -x ${_SG_DAEMON} ]] if [[ ! -x ${_SG_DAEMON} ]]
@ -87,13 +124,14 @@ else
log_hc "$0" 1 "${_MSG}" log_hc "$0" 1 "${_MSG}"
# dump debug info # dump debug info
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs (( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
return 0 return 1
} }
fi fi
# do package status checks # do package status checks
# (replace ':' by '|' for cmcviewcl output) # (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 do
# field split # field split
_SG_PACKAGE="$(print ${_SG_ENTRY} | cut -f1 -d':')" _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}]" _MSG="package ${_SG_PACKAGE} parameter ${_SG_CFG_PARAM} has a wrong value [${_SG_RUN_VALUE}]"
_STC=1 _STC=1
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}" log_hc "$0" ${_STC} "${_MSG}" "${_SG_RUN_VALUE}" "${_SG_CFG_VALUE}"
fi
else else
warn "could not determine status for ${_SG_PACKAGE}/${_SG_CFG_PARAM} from command output {cmviewcl}" warn "could not determine status for ${_SG_PACKAGE}/${_SG_CFG_PARAM} from command output {cmviewcl}"
fi fi
@ -129,8 +170,12 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3 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+) PURPOSE : Checks the status of Serviceguard package parameters (SG 11.16+)
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,12 +19,13 @@
# @(#) MAIN: check_linux_sg_qs_status # @(#) MAIN: check_linux_sg_qs_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # EXPECTS: n/a
# REQUIRES: data_comma2space(), init_hc(), log_hc() # REQUIRES: data_comma2space(), init_hc(), log_hc(), warn()
# #
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2017-05-01: initial version [Patrick Van der Veken] # @(#) 2017-05-01: initial version [Patrick Van der Veken]
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2019-01-24: arguments 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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -33,7 +34,7 @@
function check_linux_sg_qs_status function check_linux_sg_qs_status
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- 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 _SUPPORTED_PLATFORMS="Linux" # uname -s match
typeset _QS_BIN="/opt/qs/bin/qsc" typeset _QS_BIN="/opt/qs/bin/qsc"
typeset _QS_AUTH_FILE="/opt/qs/conf/qs_authfile" typeset _QS_AUTH_FILE="/opt/qs/conf/qs_authfile"
@ -46,6 +47,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
for _ARG in ${_ARGS} for _ARG in ${_ARGS}
@ -57,6 +59,20 @@ do
esac esac
done 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 # check QS presence
if [[ ! -x ${_QS_BIN} ]] if [[ ! -x ${_QS_BIN} ]]
then then
@ -79,7 +95,10 @@ case ${_STC} in
_MSG="could not determine status of QS" _MSG="could not determine status of QS"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
# ---- config state ---- # ---- config state ----
if [[ -s ${_QS_AUTH_FILE} ]] if [[ -s ${_QS_AUTH_FILE} ]]
@ -90,7 +109,10 @@ else
_MSG="QS authorizations file is missing or empty (${_QS_AUTH_FILE})" _MSG="QS authorizations file is missing or empty (${_QS_AUTH_FILE})"
_STC=1 _STC=1
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
return 0 return 0
} }
@ -101,8 +123,8 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether the Serviceguard quorum server is running PURPOSE : Checks whether the Serviceguard quorum server is running
LOG HEALTHY : Supported
EOT EOT

View File

@ -24,6 +24,7 @@
# @(#) HISTORY: # @(#) HISTORY:
# @(#) 2016-12-01: initial version [Patrick Van der Veken] # @(#) 2016-12-01: initial version [Patrick Van der Veken]
# @(#) 2019-01-24: arguments 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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -33,7 +34,7 @@ function check_linux_shorewall_status
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _SHOREWALL_BIN="/sbin/shorewall" 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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -44,6 +45,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
for _ARG in ${_ARGS} for _ARG in ${_ARGS}
@ -55,6 +57,19 @@ do
esac esac
done 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 # check status
if [[ -x ${_SHOREWALL_BIN} && -n "${_SHOREWALL_BIN}" ]] if [[ -x ${_SHOREWALL_BIN} && -n "${_SHOREWALL_BIN}" ]]
@ -69,7 +84,10 @@ then
_MSG="shorewall is not running {shorewall status}" _MSG="shorewall is not running {shorewall status}"
_STC=1 _STC=1
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
# check compile # check compile
${_SHOREWALL_BIN} check >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG} ${_SHOREWALL_BIN} check >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
@ -81,7 +99,10 @@ then
_MSG="shorewall rules do not compile correctly {shorewall check}" _MSG="shorewall rules do not compile correctly {shorewall check}"
_STC=1 _STC=1
fi fi
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
else else
warn "shorewall is not installed here" warn "shorewall is not installed here"
return 1 return 1
@ -96,9 +117,9 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether shorewall (firewall) service is running and whether PURPOSE : Checks whether shorewall (firewall) service is running and whether
shorewall rules compile correctly shorewall rules compile correctly
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_sshd_status # @(#) MAIN: check_linux_sshd_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # 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: # @(#) HISTORY:
# @(#) 2016-12-01: initial version [Patrick Van der Veken] # @(#) 2016-12-01: initial version [Patrick Van der Veken]
@ -28,6 +28,7 @@
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2018-11-18: add linux_has_systemd_service() [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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -36,7 +37,7 @@
function check_linux_sshd_status function check_linux_sshd_status
{ {
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- 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 _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -50,6 +51,7 @@ typeset _SSHD_INIT_SCRIPT=""
typeset _SSHD_SYSTEMD_SERVICE="" typeset _SSHD_SYSTEMD_SERVICE=""
typeset _CHECK_SYSTEMD_SERVICE=0 typeset _CHECK_SYSTEMD_SERVICE=0
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _RC=0 typeset _RC=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -62,6 +64,20 @@ do
esac esac
done 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 # set init script & systemd service
case "${LINUX_DISTRO}" in case "${LINUX_DISTRO}" in
Debian) Debian)
@ -126,7 +142,10 @@ case ${_STC} in
_MSG="could not determine status of sshd" _MSG="could not determine status of sshd"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
return 0 return 0
} }
@ -137,8 +156,8 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether sshd (Secure Shell daemon) is running PURPOSE : Checks whether sshd (Secure Shell daemon) is running
LOG HEALTHY : Supported
EOT EOT

View File

@ -19,7 +19,7 @@
# @(#) MAIN: check_linux_winbind_status # @(#) MAIN: check_linux_winbind_status
# DOES: see _show_usage() # DOES: see _show_usage()
# EXPECTS: n/a # 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: # @(#) HISTORY:
# @(#) 2013-05-17: initial version [Patrick Van der Veken] # @(#) 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] # @(#) 2017-05-08: fix fall-back for sysv->pgrep [Patrick Van der Veken]
# @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken] # @(#) 2018-05-21: STDERR fixes [Patrick Van der Veken]
# @(#) 2019-01-24: arguments 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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -37,7 +38,7 @@ function check_linux_winbind_status
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
typeset _WINBIND_INIT_SCRIPT="/etc/init.d/winbind" typeset _WINBIND_INIT_SCRIPT="/etc/init.d/winbind"
typeset _WINBIND_SYSTEMD_SERVICE="winbind.service" 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 typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
# ------------------------- CONFIGURATION ends here --------------------------- # ------------------------- CONFIGURATION ends here ---------------------------
@ -48,6 +49,7 @@ typeset _ARGS=$(data_comma2space "$*")
typeset _ARG="" typeset _ARG=""
typeset _MSG="" typeset _MSG=""
typeset _STC=0 typeset _STC=0
typeset _LOG_HEALTHY=0
typeset _RC=0 typeset _RC=0
# handle arguments (originally comma-separated) # handle arguments (originally comma-separated)
@ -60,6 +62,20 @@ do
esac esac
done 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 # 1) try using the init ways
linux_get_init linux_get_init
case "${LINUX_INIT}" in case "${LINUX_INIT}" in
@ -105,7 +121,10 @@ case ${_STC} in
_MSG="could not determine status of winbind" _MSG="could not determine status of winbind"
;; ;;
esac esac
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
then
log_hc "$0" ${_STC} "${_MSG}" log_hc "$0" ${_STC} "${_MSG}"
fi
return 0 return 0
} }
@ -116,8 +135,8 @@ function _show_usage
cat <<- EOT cat <<- EOT
NAME : $1 NAME : $1
VERSION : $2 VERSION : $2
CONFIG : $3
PURPOSE : Checks whether Winbind (AD) is running PURPOSE : Checks whether Winbind (AD) is running
LOG HEALTHY : Supported
EOT EOT