Added check_linux_autofs + check_hpux_autofs plugins (w/ healing code)
This commit is contained in:
parent
f7975c73cd
commit
976f1f8b84
@ -59,6 +59,7 @@ This is the OS/platform plugin package"
|
||||
file_permissions -u 0222 -o root -g sys
|
||||
|
||||
directory ../../../opt/hc/lib/platform/hp-ux=/opt/hc/lib/platform/hp-ux
|
||||
file -m 755 check_hpux_autofs.sh
|
||||
file -m 755 check_hpux_autopath.sh
|
||||
file -m 755 check_hpux_cdsf_cluster.sh
|
||||
file -m 755 check_hpux_cron_status.sh
|
||||
@ -102,6 +103,7 @@ This is the OS/platform plugin package"
|
||||
file_permissions -u 0222 -o root -g sys
|
||||
|
||||
directory ../../../etc/opt/hc/=/etc/opt/hc
|
||||
file -m 644 check_hpux_autofs.conf.dist
|
||||
file -m 644 check_hpux_drd_status.conf.dist
|
||||
file -m 644 check_hpux_file_age.conf.dist
|
||||
file -m 644 check_hpux_file_change.conf.dist
|
||||
|
@ -19,6 +19,7 @@ package() {
|
||||
install -d -m 755 ${pkgdir}/opt/hc/lib
|
||||
install -d -m 755 ${pkgdir}/opt/hc/lib/platform
|
||||
install -d -m 755 ${pkgdir}/opt/hc/lib/platform/linux
|
||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_autofs.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_autofs.sh
|
||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_burp_backup.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_burp_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_es_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_es_status.sh
|
||||
@ -44,6 +45,7 @@ package() {
|
||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||
install -d -m 755 ${pkgdir}/etc/opt/hc
|
||||
install -D -m 644 etc/opt/hc/check_linux_autofs.conf.dist ${pkgdir}/etc/opt/hc/check_linux_autofs.conf.dist
|
||||
install -D -m 644 etc/opt/hc/check_linux_burp_backup.conf.dist ${pkgdir}/etc/opt/hc/check_linux_burp_backup.conf.dist
|
||||
install -D -m 644 etc/opt/hc/check_linux_es_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_es_status.conf.dist
|
||||
install -D -m 644 etc/opt/hc/check_linux_file_age.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_age.conf.dist
|
||||
|
@ -27,6 +27,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib
|
||||
install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib/platform
|
||||
install -d -m 755 $RPM_BUILD_ROOT/opt/hc/lib/platform/linux
|
||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_autofs.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_autofs.sh
|
||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_burp_backup.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_backup.sh
|
||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_burp_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_burp_status.sh
|
||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_es_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_es_status.sh
|
||||
@ -52,6 +53,7 @@ cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_root_crontab.sh $RPM_BUILD_R
|
||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc
|
||||
cp ../SOURCES/etc/opt/hc/check_linux_autofs.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_autofs.conf.dist
|
||||
cp ../SOURCES/etc/opt/hc/check_linux_burp_backup.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_burp_backup.conf.dist
|
||||
cp ../SOURCES/etc/opt/hc/check_linux_es_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_es_status.conf.dist
|
||||
cp ../SOURCES/etc/opt/hc/check_linux_file_age.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_age.conf.dist
|
||||
@ -107,6 +109,7 @@ echo "INFO: finished post-uninstall script"
|
||||
%dir /opt/hc/lib
|
||||
%dir /opt/hc/lib/platform
|
||||
%dir /opt/hc/lib/platform/linux
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_autofs.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
|
||||
@ -132,6 +135,7 @@ echo "INFO: finished post-uninstall script"
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_counters.sh
|
||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_vz_ct_status.sh
|
||||
%dir /etc/opt/hc
|
||||
%attr(644, root, root) /etc/opt/hc/check_linux_autofs.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
|
||||
@ -153,6 +157,8 @@ echo "INFO: finished post-uninstall script"
|
||||
%attr(644, root, root) /etc/opt/hc/core/templates/mail_body.tpl-check_linux_root_crontab
|
||||
|
||||
%changelog
|
||||
* Sun Jul 14 2019 <patrick@kudos.be> - 0.3.1
|
||||
- Removed check_linux_autofs plugin
|
||||
* Sat Apr 20 2019 <patrick@kudos.be> - 0.3.0
|
||||
- Removed Serviceguard plugins
|
||||
* Tue Mar 26 2019 <patrick@kudos.be> - 0.2.0
|
||||
|
31
etc/opt/hc/check_hpux_autofs.conf.dist
Normal file
31
etc/opt/hc/check_hpux_autofs.conf.dist
Normal file
@ -0,0 +1,31 @@
|
||||
#******************************************************************************
|
||||
# @(#) check_linux_autofs.conf
|
||||
#******************************************************************************
|
||||
# This is a configuration file for the check_linux_autofs 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 whether to extend the current ELDO FS (if needed)
|
||||
# [default: no]
|
||||
fix_autofs="no"
|
||||
|
||||
# number of times to attempt to restart the autofs daemon
|
||||
# (requires fix_autofs=yes)
|
||||
# [default: 3]
|
||||
retry_start=3
|
||||
|
||||
# number of seconds to sleep between daemon restart attempts
|
||||
# (requires fix_autofs=yes)
|
||||
# [default: 5]
|
||||
sleep_time=5
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
31
etc/opt/hc/check_linux_autofs.conf.dist
Normal file
31
etc/opt/hc/check_linux_autofs.conf.dist
Normal file
@ -0,0 +1,31 @@
|
||||
#******************************************************************************
|
||||
# @(#) check_linux_autofs.conf
|
||||
#******************************************************************************
|
||||
# This is a configuration file for the check_linux_autofs 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 whether to extend the current ELDO FS (if needed)
|
||||
# [default: no]
|
||||
fix_autofs="no"
|
||||
|
||||
# number of times to attempt to restart the autofs daemon
|
||||
# (requires fix_autofs=yes)
|
||||
# [default: 3]
|
||||
retry_start=3
|
||||
|
||||
# number of seconds to sleep between daemon restart attempts
|
||||
# (requires fix_autofs=yes)
|
||||
# [default: 5]
|
||||
sleep_time=5
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# End of FILE
|
||||
#******************************************************************************
|
@ -30,7 +30,7 @@
|
||||
# RETURNS: 0
|
||||
function version_include_data
|
||||
{
|
||||
typeset _VERSION="2019-04-20" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-07-14" # YYYY-MM-DD
|
||||
|
||||
print "INFO: $0: ${_VERSION#version_*}"
|
||||
|
||||
@ -199,7 +199,7 @@ return 0
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_magic_quote()
|
||||
# DOES: magically quotes a needle in a string (default needle is: %)
|
||||
# EXPECTS: to be magically quoted [string]; $2=needle [string]
|
||||
# EXPECTS: $1=to be magically quoted [string]; $2=needle [string]
|
||||
# OUTPUTS: magically quoted [string]
|
||||
# RETURNS: n/a
|
||||
# REQUIRES: n/a
|
||||
@ -217,7 +217,7 @@ return 0
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_magic_unquote()
|
||||
# DOES: magically unquotes a needle in a string (default needle is: %)
|
||||
# EXPECTS: to be magically unquoted [string]; $2=needle [string]
|
||||
# EXPECTS: $1=to be magically unquoted [string]; $2=needle [string]
|
||||
# OUTPUTS: magically unquoted [string]
|
||||
# RETURNS: n/a
|
||||
# REQUIRES: n/a
|
||||
|
@ -30,13 +30,107 @@
|
||||
# RETURNS: 0
|
||||
function version_include_os
|
||||
{
|
||||
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||
typeset _VERSION="2019-07-14" # YYYY-MM-DD
|
||||
|
||||
print "INFO: $0: ${_VERSION#version_*}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: linux_change_service()
|
||||
# DOES: restarts a specific service
|
||||
# EXPECTS: $1=name of service [string]; $2=action [stop/start/restart]
|
||||
# OUTPUTS: n/a
|
||||
# RETURNS: 0=success; 1=error
|
||||
# REQUIRES: linux_get_init(), linux_has_systemd_service()
|
||||
function linux_change_service
|
||||
{
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _SERVICE="${1}"
|
||||
typeset _ACTION="${2}"
|
||||
|
||||
# linux only
|
||||
check_platform 'Linux' || {
|
||||
(( ARG_DEBUG > 0 )) && debug "may only run on platform(s): Linux"
|
||||
return 1
|
||||
}
|
||||
|
||||
# check action
|
||||
case "${_ACTION}" in
|
||||
start|START|Start)
|
||||
(( ARG_DEBUG > 0 )) && debug "requesting service start"
|
||||
;;
|
||||
stop|STOP|Stop)
|
||||
(( ARG_DEBUG > 0 )) && debug "requesting service stop"
|
||||
;;
|
||||
restart|RESTART|Restart)
|
||||
(( ARG_DEBUG > 0 )) && debug "requesting service restart"
|
||||
;;
|
||||
*)
|
||||
(( ARG_DEBUG > 0 )) && debug "requesting unknown service action"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ -n "${LINUX_INIT}" ]] || linux_get_init
|
||||
case "${LINUX_INIT}" in
|
||||
'systemd')
|
||||
(( ARG_DEBUG > 0 )) && debug "is a systemd managed host"
|
||||
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_SERVICE}")
|
||||
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
||||
then
|
||||
systemctl --quiet ${_ACTION} ${_SERVICE} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
return $?
|
||||
else
|
||||
warn "systemd unit file not found {${_SERVICE}}"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
'upstart')
|
||||
(( ARG_DEBUG > 0 )) && debug "is an upstart managed host"
|
||||
warn "code for upstart managed systems not implemented, NOOP"
|
||||
return 1
|
||||
;;
|
||||
'sysv')
|
||||
(( ARG_DEBUG > 0 )) && debug "is a sysv managed host"
|
||||
service ${_SERVICE} ${_ACTION} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
return $?
|
||||
;;
|
||||
*)
|
||||
(( ARG_DEBUG > 0 )) && debug "unknown init system for this host?"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: linux_exec_ssh()
|
||||
# DOES: execute a shell command remotely via SSH
|
||||
# EXPECTS: 1=options [string], 2=user [string], 3=host [string], 4=command [string]
|
||||
# RETURNS: exit code of remote command
|
||||
# OUTPUTS: STDOUT from SSH call
|
||||
# REQUIRES: ssh command-line utility
|
||||
function linux_exec_ssh
|
||||
{
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
typeset _SSH_OPTS="${1}"
|
||||
typeset _SSH_USER="${2}"
|
||||
typeset _SSH_HOST="${3}"
|
||||
typeset _SSH_COMMAND="${4}"
|
||||
|
||||
if [[ -z "${_SSH_USER}" || -z "${_SSH_HOST}" || -z "${_SSH_COMMAND}" ]]
|
||||
then
|
||||
return 255
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
ssh ${_SSH_OPTS} -l ${_SSH_USER} ${_SSH_HOST} ${_SSH_COMMAND} 2>>${HC_STDERR_LOG} </dev/null
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: linux_get_distro()
|
||||
# DOES: get Linux distribution name & version, sets $LINUX_DISTRO & $LINUX_RELEASE
|
||||
@ -118,12 +212,75 @@ elif [[ -r /usr/share/upstart ]]
|
||||
then
|
||||
# shellcheck disable=SC2034
|
||||
LINUX_INIT="upstart"
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: linux_has_service()
|
||||
# DOES: check if a specific service is present and/or enabled
|
||||
# EXPECTS: name of service [string]
|
||||
# OUTPUTS: 0=not present; 1=present (not enabled); 2=present (enabled)
|
||||
# RETURNS: 0=success; 1=error
|
||||
# REQUIRES: linux_get_init(), linux_has_systemd_service()
|
||||
function linux_has_service
|
||||
{
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _SERVICE="${1}"
|
||||
typeset _HAS_SERVICE=0
|
||||
|
||||
# linux only
|
||||
check_platform 'Linux' || {
|
||||
warn "may only run on platform(s): Linux"
|
||||
return 1
|
||||
}
|
||||
|
||||
[[ -n "${LINUX_INIT}" ]] || linux_get_init
|
||||
case "${LINUX_INIT}" in
|
||||
'systemd')
|
||||
(( ARG_DEBUG > 0 )) && debug "is a systemd managed host"
|
||||
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_SERVICE}")
|
||||
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
||||
then
|
||||
systemctl --quiet is-enabled ${_SERVICE} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_HAS_SERVICE=1
|
||||
else
|
||||
_HAS_SERVICE=2
|
||||
fi
|
||||
else
|
||||
warn "systemd unit file not found {${_SERVICE}}"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
'upstart')
|
||||
(( ARG_DEBUG > 0 )) && debug "is an upstart managed host"
|
||||
warn "code for upstart managed systems not implemented, NOOP"
|
||||
return 1
|
||||
;;
|
||||
'sysv')
|
||||
(( ARG_DEBUG > 0 )) && debug "is a sysv managed host"
|
||||
chkconfig ${_SERVICE} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_HAS_SERVICE=2
|
||||
else
|
||||
_HAS_SERVICE=0
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
(( ARG_DEBUG > 0 )) && debug "unknown init system for this host?"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
print ${_HAS_SERVICE}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: linux_has_crm()
|
||||
# DOES: check if Corosync (CRM version) is running
|
||||
@ -249,30 +406,70 @@ return ${_RC}
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: linux_exec_ssh()
|
||||
# DOES: execute a shell command remotely via SSH
|
||||
# EXPECTS: 1=options [string], 2=user [string], 3=host [string], 4=command [string]
|
||||
# RETURNS: exit code of remote command
|
||||
# OUTPUTS: STDOUT from SSH call
|
||||
# REQUIRES: ssh command-line utility
|
||||
function linux_exec_ssh
|
||||
# @(#) FUNCTION: linux_runs_service()
|
||||
# DOES: check if a specific service is running (active)
|
||||
# EXPECTS: name of service [string]
|
||||
# OUTPUTS: 0=not running/not active; 1=running/active
|
||||
# RETURNS: 0=success; 1=error
|
||||
# REQUIRES: linux_get_init(), linux_has_systemd_service()
|
||||
function linux_runs_service
|
||||
{
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||
typeset _SSH_OPTS="${1}"
|
||||
typeset _SSH_USER="${2}"
|
||||
typeset _SSH_HOST="${3}"
|
||||
typeset _SSH_COMMAND="${4}"
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _SERVICE="${1}"
|
||||
typeset _RUNS_SERVICE=0
|
||||
|
||||
if [[ -z "${_SSH_USER}" || -z "${_SSH_HOST}" || -z "${_SSH_COMMAND}" ]]
|
||||
then
|
||||
return 255
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
ssh ${_SSH_OPTS} -l ${_SSH_USER} ${_SSH_HOST} ${_SSH_COMMAND} 2>>${HC_STDERR_LOG} </dev/null
|
||||
|
||||
return $?
|
||||
# linux only
|
||||
check_platform 'Linux' || {
|
||||
(( ARG_DEBUG > 0 )) && debug "may only run on platform(s): Linux"
|
||||
return 1
|
||||
}
|
||||
|
||||
[[ -n "${LINUX_INIT}" ]] || linux_get_init
|
||||
case "${LINUX_INIT}" in
|
||||
'systemd')
|
||||
(( ARG_DEBUG > 0 )) && debug "is a systemd managed host"
|
||||
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_SERVICE}")
|
||||
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
||||
then
|
||||
systemctl --quiet is-active ${_SERVICE} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_RUNS_SERVICE=0
|
||||
else
|
||||
_RUNS_SERVICE=1
|
||||
fi
|
||||
else
|
||||
warn "systemd unit file not found {${_SERVICE}}"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
'upstart')
|
||||
(( ARG_DEBUG > 0 )) && debug "is an upstart managed host"
|
||||
warn "code for upstart managed systems not implemented, NOOP"
|
||||
return 1
|
||||
;;
|
||||
'sysv')
|
||||
(( ARG_DEBUG > 0 )) && debug "is a sysv managed host"
|
||||
service ${_SERVICE} status >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_RUNS_SERVICE=0
|
||||
else
|
||||
_RUNS_SERVICE=1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
(( ARG_DEBUG > 0 )) && debug "unknown init system for this host?"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
print ${_RUNS_SERVICE}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
||||
|
257
opt/hc/lib/platform/hp-ux/check_hpux_autofs.sh
Normal file
257
opt/hc/lib/platform/hp-ux/check_hpux_autofs.sh
Normal file
@ -0,0 +1,257 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_hpux_autofs.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_hpux_autofs
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), data_is_numeric(), dump_logs(), init_hc(),
|
||||
# log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2019-07-14: original version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_hpux_autofs
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-07-14" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# shellcheck disable=SC2034
|
||||
typeset _HC_CAN_FIX=1 # plugin has fix/healing logic?
|
||||
typeset _CHRC_BIN="/usr/bin/ch_rc"
|
||||
# ------------------------- 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_FIX_AUTOFS=""
|
||||
typeset _FIX_AUTOFS=0
|
||||
typeset _IS_ACTIVE=0
|
||||
typeset _IS_ENABLED=0
|
||||
typeset _RETRY_START=3
|
||||
typeset _SLEEP_TIME=5
|
||||
typeset _RETRY_COUNT=1
|
||||
|
||||
# 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
|
||||
_CFG_FIX_AUTOFS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'fix_autofs')
|
||||
case "${_CFG_FIX_AUTOFS}" in
|
||||
yes|YES|Yes)
|
||||
_FIX_AUTOFS=1
|
||||
;;
|
||||
*)
|
||||
_FIX_AUTOFS=0
|
||||
;;
|
||||
esac
|
||||
_CFG_RETRY_START=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'retry_start')
|
||||
data_is_numeric "${_CFG_RETRY_START}"
|
||||
# shellcheck disable=SC2181
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
warn "value for parameter 'retry_count' in configuration file ${_CONFIG_FILE} is invalid"
|
||||
return 1
|
||||
else
|
||||
_RETRY_START=${_CFG_RETRY_START}
|
||||
fi
|
||||
_CFG_SLEEP_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'sleep_time')
|
||||
data_is_numeric "${_CFG_SLEEP_TIME}"
|
||||
# shellcheck disable=SC2181
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
warn "value for parameter 'sleep_time' in configuration file ${_CONFIG_FILE} is invalid"
|
||||
return 1
|
||||
else
|
||||
_SLEEP_TIME=${_CFG_SLEEP_TIME}
|
||||
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
|
||||
|
||||
# log_healthy/--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
|
||||
# --no-fix
|
||||
if (( ARG_NO_FIX > 0 ))
|
||||
then
|
||||
_FIX_AUTOFS=0
|
||||
log "fix/healing logic has been disabled"
|
||||
fi
|
||||
|
||||
# check required tools
|
||||
if [[ ! -x ${_CHRC_BIN} ]]
|
||||
then
|
||||
warn "${_CHRC_BIN} is not installed here"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# check if autofs is enabled
|
||||
log "checking if autofs daemon is enabled"
|
||||
_IS_ENABLED=$(ch_rc -l -p AUTOFS /etc/rc.config.d/nfsconf 2>${HC_STDERR_LOG})
|
||||
if (( _IS_ENABLED > 0 ))
|
||||
then
|
||||
_MSG="autofs service is enabled"
|
||||
_STC=0
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
# check if autofs is running
|
||||
log "checking if autofs daemon is active"
|
||||
_is_autofs_active
|
||||
_IS_ACTIVE=$?
|
||||
if (( _IS_ACTIVE > 0 ))
|
||||
then
|
||||
_MSG="autofs daemon is running"
|
||||
_STC=0
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
else
|
||||
warn "autofs daemon is not running"
|
||||
# try restart if healing is desired
|
||||
if (( _FIX_AUTOFS > 0 ))
|
||||
then
|
||||
while (( _RETRY_COUNT <= _RETRY_START && _IS_ACTIVE == 0 ))
|
||||
do
|
||||
log "restarting autofs (attempt #${_RETRY_COUNT})"
|
||||
/sbin/init.d/autofs stop >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
/sbin/init.d/autofs start >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
log "sleeping for ${_SLEEP_TIME} seconds"
|
||||
sleep ${_SLEEP_TIME}
|
||||
_RETRY_COUNT=$(( _RETRY_COUNT + 1 ))
|
||||
_is_autofs_active
|
||||
_IS_ACTIVE=$?
|
||||
done
|
||||
# check again if autofs is running
|
||||
_is_autofs_active
|
||||
_IS_ACTIVE=$?
|
||||
if (( _IS_ACTIVE > 0 ))
|
||||
then
|
||||
_MSG="autofs daemon is running"
|
||||
_STC=0
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
else
|
||||
_MSG="autofs daemon is not running"
|
||||
_STC=1
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
_MSG="autofs daemon is not running"
|
||||
_STC=1
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
_MSG="autofs service is disabled"
|
||||
_STC=1
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _is_autofs_active
|
||||
{
|
||||
typeset _IS_ACTIVE=$(pgrep -u root automountd 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null)
|
||||
|
||||
return ${_IS_ACTIVE}
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
fix_autofs=<yes|no>
|
||||
retry_start=<amount_of_start_retries>
|
||||
sleep_time=<seconds_to_sleep_during_restart_attempts>
|
||||
PURPOSE : Check/fix AutoFS service
|
||||
LOG HEALTHY : Supported
|
||||
CAN FIX? : Yes
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
235
opt/hc/lib/platform/linux/check_linux_autofs.sh
Normal file
235
opt/hc/lib/platform/linux/check_linux_autofs.sh
Normal file
@ -0,0 +1,235 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) check_linux_autofs.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_autofs
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_comma2space(), data_is_numeric(), dump_logs(), init_hc(),
|
||||
# linux_change_service(), linux_has_service(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2019-07-14: original version [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function check_linux_autofs
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2019-07-14" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# shellcheck disable=SC2034
|
||||
typeset _HC_CAN_FIX=1 # plugin has fix/healing logic?
|
||||
# ------------------------- 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_FIX_AUTOFS=""
|
||||
typeset _FIX_AUTOFS=0
|
||||
typeset _IS_ACTIVE=0
|
||||
typeset _HAS_SERVICE=0
|
||||
typeset _RETRY_START=3
|
||||
typeset _SLEEP_TIME=5
|
||||
typeset _RETRY_COUNT=1
|
||||
|
||||
# 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
|
||||
_CFG_FIX_AUTOFS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'fix_autofs')
|
||||
case "${_CFG_FIX_AUTOFS}" in
|
||||
yes|YES|Yes)
|
||||
_FIX_AUTOFS=1
|
||||
;;
|
||||
*)
|
||||
_FIX_AUTOFS=0
|
||||
;;
|
||||
esac
|
||||
_CFG_RETRY_START=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'retry_start')
|
||||
data_is_numeric "${_CFG_RETRY_START}"
|
||||
# shellcheck disable=SC2181
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
warn "value for parameter 'retry_count' in configuration file ${_CONFIG_FILE} is invalid"
|
||||
return 1
|
||||
else
|
||||
_RETRY_START=${_CFG_RETRY_START}
|
||||
fi
|
||||
_CFG_SLEEP_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'sleep_time')
|
||||
data_is_numeric "${_CFG_SLEEP_TIME}"
|
||||
# shellcheck disable=SC2181
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
warn "value for parameter 'sleep_time' in configuration file ${_CONFIG_FILE} is invalid"
|
||||
return 1
|
||||
else
|
||||
_SLEEP_TIME=${_CFG_SLEEP_TIME}
|
||||
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
|
||||
|
||||
# log_healthy/--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
|
||||
# --no-fix
|
||||
if (( ARG_NO_FIX > 0 ))
|
||||
then
|
||||
_FIX_AUTOFS=0
|
||||
log "fix/healing logic has been disabled"
|
||||
fi
|
||||
|
||||
# check if autofs is enabled
|
||||
log "checking if autofs daemon is enabled"
|
||||
_HAS_SERVICE=$(linux_has_service "autofs")
|
||||
if (( _HAS_SERVICE == 2 ))
|
||||
then
|
||||
_MSG="autofs service is enabled"
|
||||
_STC=0
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
# check if autofs is running
|
||||
log "checking if autofs daemon is active"
|
||||
_IS_ACTIVE=$(linux_runs_service autofs)
|
||||
if (( _IS_ACTIVE > 0 ))
|
||||
then
|
||||
_MSG="autofs daemon is running"
|
||||
_STC=0
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
else
|
||||
warn "autofs daemon is not running"
|
||||
# try restart if healing is desired
|
||||
if (( _FIX_AUTOFS > 0 ))
|
||||
then
|
||||
while (( _RETRY_COUNT <= _RETRY_START && _IS_ACTIVE == 0 ))
|
||||
do
|
||||
log "restarting autofs (attempt #${_RETRY_COUNT})"
|
||||
linux_change_service "autofs" "restart" >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
# dump debug info
|
||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
log "sleeping for ${_SLEEP_TIME} seconds"
|
||||
sleep ${_SLEEP_TIME}
|
||||
_RETRY_COUNT=$(( _RETRY_COUNT + 1 ))
|
||||
_IS_ACTIVE=$(linux_runs_service "autofs")
|
||||
done
|
||||
# check again if autofs is running
|
||||
_IS_ACTIVE=$(linux_runs_service "autofs")
|
||||
if (( _IS_ACTIVE > 0 ))
|
||||
then
|
||||
_MSG="autofs daemon is running"
|
||||
_STC=0
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
else
|
||||
_MSG="autofs daemon is not running"
|
||||
_STC=1
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
_MSG="autofs daemon is not running"
|
||||
_STC=1
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
_MSG="autofs service is disabled"
|
||||
_STC=1
|
||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||
then
|
||||
log_hc "$0" ${_STC} "${_MSG}"
|
||||
fi
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function _show_usage
|
||||
{
|
||||
cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with parameters:
|
||||
log_healthy=<yes|no>
|
||||
fix_autofs=<yes|no>
|
||||
retry_start=<amount_of_start_retries>
|
||||
sleep_time=<seconds_to_sleep_during_restart_attempts>
|
||||
PURPOSE : Check/fix AutoFS service
|
||||
LOG HEALTHY : Supported
|
||||
CAN FIX? : Yes
|
||||
|
||||
EOT
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
Loading…
x
Reference in New Issue
Block a user