Added configuration parameters for the check_linux_httpd_status() plugin to support httpd that were compiled from source (no sysv or systemd)
This commit is contained in:
parent
b460eca52c
commit
f2b4970977
@ -55,6 +55,7 @@ package() {
|
|||||||
install -D -m 644 etc/opt/hc/check_linux_hpacucli.conf.dist ${pkgdir}/etc/opt/hc/check_linux_hpacucli.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_hpacucli.conf.dist ${pkgdir}/etc/opt/hc/check_linux_hpacucli.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_hplog.conf.dist ${pkgdir}/etc/opt/hc/check_linux_hplog.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_hplog.conf.dist ${pkgdir}/etc/opt/hc/check_linux_hplog.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_hpssacli.conf.dist ${pkgdir}/etc/opt/hc/check_linux_hpssacli.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_hpssacli.conf.dist ${pkgdir}/etc/opt/hc/check_linux_hpssacli.conf.dist
|
||||||
|
install -D -m 644 etc/opt/hc/check_linux_httpd_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_httpd_status.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_mysqld_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_mysqld_status.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_mysqld_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_mysqld_status.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_ntp_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_ntp_status.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_ntp_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_ntp_status.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_process_limits.conf.dist ${pkgdir}/etc/opt/hc/check_linux_process_limits.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_process_limits.conf.dist ${pkgdir}/etc/opt/hc/check_linux_process_limits.conf.dist
|
||||||
|
@ -63,6 +63,7 @@ cp ../SOURCES/etc/opt/hc/check_linux_hpasmcli.conf.dist $RPM_BUILD_ROOT/etc/opt/
|
|||||||
cp ../SOURCES/etc/opt/hc/check_linux_hpacucli.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_hpacucli.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_hpacucli.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_hpacucli.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_hplog.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_hplog.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_hplog.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_hplog.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_hpssacli.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_hpssacli.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_hpssacli.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_hpssacli.conf.dist
|
||||||
|
cp ../SOURCES/etc/opt/hc/check_linux_httpd_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_httpd_status.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_mysqld_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_mysqld_status.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_mysqld_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_mysqld_status.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_ntp_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_ntp_status.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_ntp_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_ntp_status.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_process_limits.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_process_limits.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_process_limits.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_process_limits.conf.dist
|
||||||
@ -145,6 +146,7 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(644, root, root) /etc/opt/hc/check_linux_hpacucli.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_hpacucli.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_hplog.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_hplog.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_hpssacli.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_hpssacli.conf.dist
|
||||||
|
%attr(644, root, root) /etc/opt/hc/check_linux_httpd_status.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_mysqld_status.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_mysqld_status.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_ntp_status.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_ntp_status.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_process_limits.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_process_limits.conf.dist
|
||||||
@ -157,6 +159,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
|
||||||
|
* Fri Nov 1 2019 <patrick@kudos.be> - 0.3.2
|
||||||
|
- Added configuration file for check_linux_httpd_status plugin
|
||||||
* Sun Jul 14 2019 <patrick@kudos.be> - 0.3.1
|
* Sun Jul 14 2019 <patrick@kudos.be> - 0.3.1
|
||||||
- Removed check_linux_autofs plugin
|
- Removed check_linux_autofs plugin
|
||||||
* Sat Apr 20 2019 <patrick@kudos.be> - 0.3.0
|
* Sat Apr 20 2019 <patrick@kudos.be> - 0.3.0
|
||||||
|
28
etc/opt/hc/check_linux_httpd_status.conf.dist
Normal file
28
etc/opt/hc/check_linux_httpd_status.conf.dist
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#******************************************************************************
|
||||||
|
# @(#) check_linux_httpd_status.conf
|
||||||
|
#******************************************************************************
|
||||||
|
# This is a configuration file for the check_linux_httpd_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="no"
|
||||||
|
|
||||||
|
# specify which type of process check to use
|
||||||
|
# Format: <auto|pgrep|sysv|systemd>. NULL value equals to "auto"
|
||||||
|
# [default: auto]
|
||||||
|
# Compatibility: >=2019-11-01
|
||||||
|
check_type="auto"
|
||||||
|
|
||||||
|
# specify custom path to the httpd binary
|
||||||
|
# [default: null]
|
||||||
|
# Compatibility: >=2019-11-01
|
||||||
|
httpd_bin=""
|
||||||
|
|
||||||
|
|
||||||
|
#******************************************************************************
|
||||||
|
# End of FILE
|
||||||
|
#******************************************************************************
|
@ -30,6 +30,8 @@
|
|||||||
# @(#) 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]
|
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
|
# @(#) 2019-11-01: added support for configuration parameters 'check_type' and
|
||||||
|
# @(#) 'httpd_bin' [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,9 +40,10 @@
|
|||||||
function check_linux_httpd_status
|
function check_linux_httpd_status
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
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-03-16" # YYYY-MM-DD
|
typeset _VERSION="2019-11-01" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -49,11 +52,15 @@ typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
|||||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
typeset _ARGS=$(data_comma2space "$*")
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
typeset _ARG=""
|
typeset _ARG=""
|
||||||
typeset _CHECK_SYSTEMD_SERVICE=0
|
|
||||||
typeset _HTTPD_BIN=""
|
|
||||||
typeset _MSG=""
|
typeset _MSG=""
|
||||||
typeset _STC=0
|
typeset _STC=0
|
||||||
|
typeset _CHECK_SYSTEMD_SERVICE=0
|
||||||
|
typeset _CFG_HEALTHY=""
|
||||||
typeset _LOG_HEALTHY=0
|
typeset _LOG_HEALTHY=0
|
||||||
|
typeset _CFG_HTTPD_BIN=""
|
||||||
|
typeset _HTTPD_BIN=""
|
||||||
|
typeset _CFG_CHECK_TYPE=""
|
||||||
|
typeset _DO_PGREP=0
|
||||||
typeset _RC=0
|
typeset _RC=0
|
||||||
|
|
||||||
# handle arguments (originally comma-separated)
|
# handle arguments (originally comma-separated)
|
||||||
@ -66,6 +73,40 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
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_CHECK_TYPE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_type')
|
||||||
|
case "${_CFG_CHECK_TYPE}" in
|
||||||
|
pgrep|Pgrep|PGREP)
|
||||||
|
_DO_PGREP=1
|
||||||
|
log "using pgrep process check (config override)"
|
||||||
|
;;
|
||||||
|
sysv|Sysv|SYSV)
|
||||||
|
LINUX_INIT="sysv"
|
||||||
|
log "using init based process check (config override)"
|
||||||
|
;;
|
||||||
|
systemd|Systemd|SYSTEMD)
|
||||||
|
LINUX_INIT="systemd"
|
||||||
|
log "using systemd based process check (config override)"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# no overrides
|
||||||
|
:
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
_CFG_HTTPD_BIN=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'httpd_bin')
|
||||||
|
if [[ -n "${_CFG_HTTPD_BIN}" ]]
|
||||||
|
then
|
||||||
|
_HTTPD_BIN="${_CFG_HTTPD_BIN}"
|
||||||
|
log "setting httpd path to {${_HTTPD_BIN}} (config override)"
|
||||||
|
fi
|
||||||
|
|
||||||
# log_healthy
|
# log_healthy
|
||||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
if (( _LOG_HEALTHY > 0 ))
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
@ -80,44 +121,58 @@ else
|
|||||||
log "not logging/showing passed health checks"
|
log "not logging/showing passed health checks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check httpd (if specified)
|
||||||
|
if [[ -z "${_HTTPD_BIN}" ]]
|
||||||
|
then
|
||||||
|
_HTTPD_BIN="$(command -v httpd 2>>${HC_STDERR_LOG})"
|
||||||
|
fi
|
||||||
|
if [[ ! -x ${_HTTPD_BIN} || -z "${_HTTPD_BIN}" ]]
|
||||||
|
then
|
||||||
|
warn "httpd (apache) is not installed here"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# ---- process state ----
|
# ---- process state ----
|
||||||
# 1) try using the init ways
|
# 1) try using the init ways
|
||||||
linux_get_init
|
if (( _DO_PGREP == 0 ))
|
||||||
case "${LINUX_INIT}" in
|
then
|
||||||
'systemd')
|
[[ -n "${LINUX_INIT}" ]] || linux_get_init
|
||||||
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_HTTPD_SYSTEMD_SERVICE}")
|
case "${LINUX_INIT}" in
|
||||||
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
'systemd')
|
||||||
then
|
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_HTTPD_SYSTEMD_SERVICE}")
|
||||||
systemctl --quiet is-active ${_HTTPD_SYSTEMD_SERVICE} 2>>${HC_STDERR_LOG} || _STC=1
|
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
||||||
else
|
|
||||||
warn "systemd unit file not found {${_HTTPD_SYSTEMD_SERVICE}}"
|
|
||||||
_RC=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'upstart')
|
|
||||||
warn "code for upstart managed systems not implemented, NOOP"
|
|
||||||
_RC=1
|
|
||||||
;;
|
|
||||||
'sysv')
|
|
||||||
# check running SysV
|
|
||||||
if [[ -x ${_HTTPD_INIT_SCRIPT} ]]
|
|
||||||
then
|
|
||||||
if (( $(${_HTTPD_INIT_SCRIPT} status 2>>${HC_STDERR_LOG} | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
|
||||||
then
|
then
|
||||||
_STC=1
|
systemctl --quiet is-active ${_HTTPD_SYSTEMD_SERVICE} 2>>${HC_STDERR_LOG} || _STC=1
|
||||||
|
else
|
||||||
|
warn "systemd unit file not found {${_HTTPD_SYSTEMD_SERVICE}}"
|
||||||
|
_RC=1
|
||||||
fi
|
fi
|
||||||
else
|
;;
|
||||||
warn "sysv init script not found {${_HTTPD_INIT_SCRIPT}}"
|
'upstart')
|
||||||
|
warn "code for upstart managed systems not implemented, NOOP"
|
||||||
_RC=1
|
_RC=1
|
||||||
fi
|
;;
|
||||||
;;
|
'sysv')
|
||||||
*)
|
# check running SysV
|
||||||
_RC=1
|
if [[ -x ${_HTTPD_INIT_SCRIPT} ]]
|
||||||
;;
|
then
|
||||||
esac
|
if (( $(${_HTTPD_INIT_SCRIPT} status 2>>${HC_STDERR_LOG} | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
||||||
|
then
|
||||||
|
_STC=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
warn "sysv init script not found {${_HTTPD_INIT_SCRIPT}}"
|
||||||
|
_RC=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_RC=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
# 2) try the pgrep way (note: old pgreps do not support '-c')
|
# 2) try the pgrep way (note: old pgreps do not support '-c')
|
||||||
if (( _RC > 0 ))
|
if (( _DO_PGREP > 0 || _RC > 0 ))
|
||||||
then
|
then
|
||||||
(( $(pgrep -u root httpd 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1
|
(( $(pgrep -u root httpd 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1
|
||||||
fi
|
fi
|
||||||
@ -140,23 +195,18 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ---- config state ----
|
# ---- config state ----
|
||||||
_HTTPD_BIN="$(command -v httpd 2>>${HC_STDERR_LOG})"
|
${_HTTPD_BIN} -t >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||||
if [[ -x ${_HTTPD_BIN} && -n "${_HTTPD_BIN}" ]]
|
if (( $? == 0 ))
|
||||||
then
|
then
|
||||||
# validate main configuration
|
_MSG="httpd configuration files are syntactically correct"
|
||||||
${_HTTPD_BIN} -t >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
_STC=0
|
||||||
if (( $? == 0 ))
|
else
|
||||||
then
|
_MSG="httpd configuration files have syntax error(s) {httpd -s}"
|
||||||
_MSG="httpd configuration files are syntactically correct"
|
_STC=1
|
||||||
_STC=0
|
fi
|
||||||
else
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
_MSG="httpd configuration files have syntax error(s) {httpd -s}"
|
then
|
||||||
_STC=1
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -168,6 +218,10 @@ function _show_usage
|
|||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
|
CONFIG : $3 with parameters:
|
||||||
|
log_healthy=<yes|no>
|
||||||
|
check_type=<auto|pgrep|sysv|systemd> [compt. >=2019-11-01]
|
||||||
|
httpd_bin=<path_to_httpd> [compt. >=2019-11-01]
|
||||||
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
|
LOG HEALTHY : Supported
|
||||||
|
Loading…
x
Reference in New Issue
Block a user