Compare commits
No commits in common. "master" and "20190516" have entirely different histories.
3
.github/FUNDING.yml
vendored
3
.github/FUNDING.yml
vendored
@ -1,3 +0,0 @@
|
|||||||
# These are supported funding model platforms
|
|
||||||
|
|
||||||
github: patvdv
|
|
@ -90,11 +90,6 @@ Additionally, there may be bundles for display or notification plugins, e.g.:
|
|||||||
* hc-display-terse
|
* hc-display-terse
|
||||||
* hc-notify-eif
|
* hc-notify-eif
|
||||||
* hc-notify-sms
|
* hc-notify-sms
|
||||||
* hc-notify-slack
|
|
||||||
|
|
||||||
## Configure & deploy
|
|
||||||
|
|
||||||
An Ansible role is available at: https://github.com/patvdv/kudos.check_health
|
|
||||||
|
|
||||||
## Execute (examples)
|
## Execute (examples)
|
||||||
|
|
||||||
@ -142,14 +137,13 @@ An Ansible role is available at: https://github.com/patvdv/kudos.check_health
|
|||||||
* **Alerting** on failed health checks:
|
* **Alerting** on failed health checks:
|
||||||
```
|
```
|
||||||
/opt/hc/bin/check_health.sh --hc=check_hpux_root_crontab --run --notify=mail --mail-to="alert@acme.com"
|
/opt/hc/bin/check_health.sh --hc=check_hpux_root_crontab --run --notify=mail --mail-to="alert@acme.com"
|
||||||
/opt/hc/bin/check_health.sh --hc=check_linux_fs_usage --run --notify=slack
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
More documentation can be found at <https://www.kudos.be/check_health/>
|
More documentation can be found at http://www.kudos.be/Projects/Health_checker.html
|
||||||
|
|
||||||
### Logo
|
### Logo
|
||||||
|
|
||||||
|
@ -32,14 +32,12 @@ Fileset
|
|||||||
/opt/hc/lib/platform/aix/check_aix_subsystems.sh
|
/opt/hc/lib/platform/aix/check_aix_subsystems.sh
|
||||||
/opt/hc/lib/platform/aix/check_aix_sysbackup.sh
|
/opt/hc/lib/platform/aix/check_aix_sysbackup.sh
|
||||||
/opt/hc/lib/platform/aix/check_aix_topasrec.sh
|
/opt/hc/lib/platform/aix/check_aix_topasrec.sh
|
||||||
/opt/hc/lib/platform/aix/check_aix_uptime.sh
|
|
||||||
/etc/opt/hc
|
/etc/opt/hc
|
||||||
/etc/opt/hc/check_aix_file_age.conf.dist
|
/etc/opt/hc/check_aix_file_age.conf.dist
|
||||||
/etc/opt/hc/check_aix_file_change.conf.dist
|
/etc/opt/hc/check_aix_file_change.conf.dist
|
||||||
/etc/opt/hc/check_aix_root_crontab.conf.dist
|
/etc/opt/hc/check_aix_root_crontab.conf.dist
|
||||||
/etc/opt/hc/check_aix_subsystems.conf.dist
|
/etc/opt/hc/check_aix_subsystems.conf.dist
|
||||||
/etc/opt/hc/check_aix_sysbackup.conf.dist
|
/etc/opt/hc/check_aix_sysbackup.conf.dist
|
||||||
/etc/opt/hc/check_aix_uptime.conf.dist
|
|
||||||
EOROOTFiles
|
EOROOTFiles
|
||||||
Relocatable: N
|
Relocatable: N
|
||||||
EOFileset
|
EOFileset
|
||||||
|
@ -1 +0,0 @@
|
|||||||
*prereq hc_aix.rte
|
|
@ -1,31 +0,0 @@
|
|||||||
Package Name: hc_notify_slack
|
|
||||||
Package VRMF: %BUILD_DATE%
|
|
||||||
Update: N
|
|
||||||
Fileset
|
|
||||||
Fileset Name: hc_notify_slack.rte
|
|
||||||
Fileset VRMF: %BUILD_DATE%
|
|
||||||
Fileset Description: Health Checker - core Slack plugin
|
|
||||||
USRLIBLPPFiles
|
|
||||||
EOUSRLIBLPPFiles
|
|
||||||
ROOTLIBLPPFiles
|
|
||||||
Post-installation Script: /export/nim/build/hc_notify_slack/scripts/hc_notify_slack.postinstall
|
|
||||||
Unpost-installation Script: /export/nim/build/hc_notify_slack/scripts/hc_notify_slack.postuninstall
|
|
||||||
EOROOTLIBLPPFiles
|
|
||||||
Bosboot required: N
|
|
||||||
License agreement acceptance required: N
|
|
||||||
Include license files in this package: N
|
|
||||||
Requisites: /export/nim/build/hc_notify_slack/hc_notify_slack.reqs
|
|
||||||
USRFiles
|
|
||||||
EOUSRFiles
|
|
||||||
ROOT Part: Y
|
|
||||||
ROOTFiles
|
|
||||||
/opt/hc/lib
|
|
||||||
/opt/hc/lib/core
|
|
||||||
/opt/hc/lib/platform/aix/notify_slack.sh
|
|
||||||
/etc/opt/hc
|
|
||||||
/etc/opt/hc/core
|
|
||||||
/etc/opt/hc/core/providers
|
|
||||||
/etc/opt/hc/core/providers/notify_slack.conf.dist
|
|
||||||
EOROOTFiles
|
|
||||||
Relocatable: N
|
|
||||||
EOFileset
|
|
@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) post-install script for hc_notify_slack LPP package
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2022 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
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of ETC dir
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
|
|
||||||
print "INFO: starting post-install script ..."
|
|
||||||
|
|
||||||
# copy plugin config file from dist (if needed)
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_slack.conf ]]
|
|
||||||
then
|
|
||||||
cp -p ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist ${HC_ETC_DIR}/core/providers/notify_slack.conf >/dev/null || \
|
|
||||||
{
|
|
||||||
print -u2 "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks || print -u2 "WARN: updating symlinks failed"
|
|
||||||
else
|
|
||||||
print -u2 "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
print "INFO: finished post-install script"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -1,48 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) post-uninstall script for hc_notify_slack LPP package
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2022 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
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of the HC configuration files
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
|
|
||||||
print "INFO: starting post-uninstall script ..."
|
|
||||||
|
|
||||||
# remove plugin configuration file (.dist only)
|
|
||||||
if [[ -d ${HC_ETC_DIR}/core/providers ]]
|
|
||||||
then
|
|
||||||
rm -f ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist >/dev/null
|
|
||||||
(( $? == 0 )) || echo "WARN: could not remove plugin config file in directory ${HC_ETC_DIR}/core/providers"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks || print -u2 "WARN: updating symlinks failed"
|
|
||||||
else
|
|
||||||
print -u2 "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
print "INFO: finished post-uninstall script"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -28,9 +28,7 @@ package() {
|
|||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh
|
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh
|
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh
|
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_ib_status.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_ib_status.sh
|
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_megaraid.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_megaraid.sh
|
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_megaraid.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_megaraid.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_zfs_cluster.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_zfs_cluster.sh
|
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh
|
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh
|
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh
|
install -D -m 755 opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh ${pkgdir}/opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh
|
||||||
@ -45,7 +43,6 @@ package() {
|
|||||||
install -D -m 644 etc/opt/hc/check_exadata_cell_megaraid.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_cell_megaraid.conf.dist
|
install -D -m 644 etc/opt/hc/check_exadata_cell_megaraid.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_cell_megaraid.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist
|
install -D -m 644 etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_exadata_megaraid.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_megaraid.conf.dist
|
install -D -m 644 etc/opt/hc/check_exadata_megaraid.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_megaraid.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_exadata_zfs_cluster.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_zfs_cluster.conf.dist
|
|
||||||
install -D -m 644 etc/opt/hc/check_exadata_zfs_logs.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_zfs_logs.conf.dist
|
install -D -m 644 etc/opt/hc/check_exadata_zfs_logs.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_zfs_logs.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist
|
install -D -m 644 etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_exadata_zfs_services.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_zfs_services.conf.dist
|
install -D -m 644 etc/opt/hc/check_exadata_zfs_services.conf.dist ${pkgdir}/etc/opt/hc/check_exadata_zfs_services.conf.dist
|
||||||
|
@ -36,9 +36,7 @@ cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_cell_griddisks.sh $RPM_B
|
|||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh
|
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh
|
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh
|
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_ib_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_ib_status.sh
|
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_megaraid.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_megaraid.sh
|
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_megaraid.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_megaraid.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_zfs_cluster.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_zfs_cluster.sh
|
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh
|
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh
|
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh
|
cp ../SOURCES/opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh
|
||||||
@ -54,7 +52,6 @@ cp ../SOURCES/etc/opt/hc/check_exadata_cell_luns.conf.dist $RPM_BUILD_ROOT/etc/o
|
|||||||
cp ../SOURCES/etc/opt/hc/check_exadata_cell_megaraid.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_cell_megaraid.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_exadata_cell_megaraid.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_cell_megaraid.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_exadata_megaraid.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_megaraid.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_exadata_megaraid.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_megaraid.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_exadata_zfs_cluster.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_zfs_cluster.conf.dist
|
|
||||||
cp ../SOURCES/etc/opt/hc/check_exadata_zfs_logs.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_zfs_logs.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_exadata_zfs_logs.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_zfs_logs.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_exadata_zfs_services.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_zfs_services.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_exadata_zfs_services.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_exadata_zfs_services.conf.dist
|
||||||
@ -106,9 +103,7 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh
|
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_cell_luns.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh
|
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_cell_megaraid.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh
|
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_cell_physicaldisks.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_ib_status.sh
|
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_megaraid.sh
|
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_megaraid.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_zfs_cluster.sh
|
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh
|
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_zfs_logs.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh
|
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_zfs_pool_usage.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh
|
%attr(755, root, root) /opt/hc/lib/platform/exadata/check_exadata_zfs_services.sh
|
||||||
@ -123,7 +118,6 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(644, root, root) /etc/opt/hc/check_exadata_cell_megaraid.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_exadata_cell_megaraid.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_exadata_cell_physicaldisks.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_exadata_megaraid.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_exadata_megaraid.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_exadata_zfs_cluster.conf.dist
|
|
||||||
%attr(644, root, root) /etc/opt/hc/check_exadata_zfs_logs.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_exadata_zfs_logs.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_exadata_zfs_pool_usage.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_exadata_zfs_services.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_exadata_zfs_services.conf.dist
|
||||||
@ -132,10 +126,6 @@ echo "INFO: finished post-uninstall script"
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Tue Jul 07 2020 <patrick@kudos.be> - 0.5.0
|
|
||||||
- Added check_exadata_ib_status
|
|
||||||
* Fri Jul 07 2019 <patrick@kudos.be> - 0.4.0
|
|
||||||
- Added check_exadata_zfs_cluster
|
|
||||||
* Fri May 14 2019 <patrick@kudos.be> - 0.3.0
|
* Fri May 14 2019 <patrick@kudos.be> - 0.3.0
|
||||||
- Added include_exadata
|
- Added include_exadata
|
||||||
- Added plugin check_exadata_cell_alerts
|
- Added plugin check_exadata_cell_alerts
|
||||||
|
@ -59,11 +59,9 @@ This is the OS/platform plugin package"
|
|||||||
file_permissions -u 0222 -o root -g sys
|
file_permissions -u 0222 -o root -g sys
|
||||||
|
|
||||||
directory ../../../opt/hc/lib/platform/hp-ux=/opt/hc/lib/platform/hp-ux
|
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_autopath.sh
|
||||||
file -m 755 check_hpux_cdsf_cluster.sh
|
file -m 755 check_hpux_cdsf_cluster.sh
|
||||||
file -m 755 check_hpux_cron_status.sh
|
file -m 755 check_hpux_cron_status.sh
|
||||||
file -m 755 check_hpux_defunct_processes.sh
|
|
||||||
file -m 755 check_hpux_drd_status.sh
|
file -m 755 check_hpux_drd_status.sh
|
||||||
file -m 755 check_hpux_file_age.sh
|
file -m 755 check_hpux_file_age.sh
|
||||||
file -m 755 check_hpux_file_change.sh
|
file -m 755 check_hpux_file_change.sh
|
||||||
@ -73,7 +71,7 @@ This is the OS/platform plugin package"
|
|||||||
file -m 755 check_hpux_ignite_backup.sh
|
file -m 755 check_hpux_ignite_backup.sh
|
||||||
file -m 755 check_hpux_ioscan.sh
|
file -m 755 check_hpux_ioscan.sh
|
||||||
file -m 755 check_hpux_guid_status.sh
|
file -m 755 check_hpux_guid_status.sh
|
||||||
file -m 755 check_hpux_hpvm_vpar_status.sh
|
file -m 644 check_hpux_hpvm_vpar_status.sh
|
||||||
file -m 755 check_hpux_httpd_status.sh
|
file -m 755 check_hpux_httpd_status.sh
|
||||||
file -m 755 check_hpux_kernel_params.sh
|
file -m 755 check_hpux_kernel_params.sh
|
||||||
file -m 755 check_hpux_kernel_usage.sh
|
file -m 755 check_hpux_kernel_usage.sh
|
||||||
@ -88,7 +86,6 @@ This is the OS/platform plugin package"
|
|||||||
file -m 755 check_hpux_sshd_status.sh
|
file -m 755 check_hpux_sshd_status.sh
|
||||||
file -m 755 check_hpux_syslog.sh
|
file -m 755 check_hpux_syslog.sh
|
||||||
file -m 755 check_hpux_syslogd_status.sh
|
file -m 755 check_hpux_syslogd_status.sh
|
||||||
file -m 755 check_hpux_uptime.sh
|
|
||||||
file -m 755 check_hpux_vg_minor_number.sh
|
file -m 755 check_hpux_vg_minor_number.sh
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -105,9 +102,6 @@ This is the OS/platform plugin package"
|
|||||||
file_permissions -u 0222 -o root -g sys
|
file_permissions -u 0222 -o root -g sys
|
||||||
|
|
||||||
directory ../../../etc/opt/hc/=/etc/opt/hc
|
directory ../../../etc/opt/hc/=/etc/opt/hc
|
||||||
file -m 644 check_hpux_autofs.conf.dist
|
|
||||||
file -m 644 check_hpux_cron_status.conf.dist
|
|
||||||
file -m 644 check_hpux_defunct_processes.conf.dist
|
|
||||||
file -m 644 check_hpux_drd_status.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_age.conf.dist
|
||||||
file -m 644 check_hpux_file_change.conf.dist
|
file -m 644 check_hpux_file_change.conf.dist
|
||||||
@ -119,12 +113,11 @@ This is the OS/platform plugin package"
|
|||||||
file -m 644 check_hpux_kernel_params.conf.dist
|
file -m 644 check_hpux_kernel_params.conf.dist
|
||||||
file -m 644 check_hpux_kernel_usage.conf.dist
|
file -m 644 check_hpux_kernel_usage.conf.dist
|
||||||
file -m 644 check_hpux_ntp_status.conf.dist
|
file -m 644 check_hpux_ntp_status.conf.dist
|
||||||
file -m 644 check_hpux_ovpa_status.conf.dist
|
file -m 755 check_hpux_ovpa_status.conf.dist
|
||||||
file -m 644 check_hpux_patch_version.conf.dist
|
file -m 755 check_hpux_patch_version.conf.dist
|
||||||
file -m 644 check_hpux_root_crontab.conf.dist
|
file -m 644 check_hpux_root_crontab.conf.dist
|
||||||
file -m 644 check_hpux_sfm_status.conf.dist
|
file -m 644 check_hpux_sfm_status.conf.dist
|
||||||
file -m 644 check_hpux_syslog.conf.dist
|
file -m 644 check_hpux_syslog.conf.dist
|
||||||
file -m 644 check_hpux_uptime.conf.dist
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fileset
|
fileset
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
# Depot definition:
|
|
||||||
depot
|
|
||||||
layout_version 1.0
|
|
||||||
|
|
||||||
# Vendor definition:
|
|
||||||
vendor
|
|
||||||
tag KUDOS
|
|
||||||
title "KUDOS BVBA - http://www.kudos.be"
|
|
||||||
end
|
|
||||||
|
|
||||||
# Bundle definitions:
|
|
||||||
bundle
|
|
||||||
tag HC-NOTIFY-SLACK
|
|
||||||
title "The Health Checker (HC) for UNIX (core SLACK plugin)"
|
|
||||||
os_name HP-UX
|
|
||||||
revision %BUILD_DATE%
|
|
||||||
architecture HP-UX_B.11_32/64
|
|
||||||
machine_type ia64*
|
|
||||||
vendor_tag KUDOS
|
|
||||||
contents HC-NOTIFY-SLACK-MAIN,r=,a=,v=
|
|
||||||
end
|
|
||||||
|
|
||||||
# Product definitions:
|
|
||||||
product
|
|
||||||
tag HC-NOTIFY-SLACK-MAIN
|
|
||||||
revision %BUILD_DATE%
|
|
||||||
category tools
|
|
||||||
category_title Tools
|
|
||||||
title "The Health Checker (HC) for UNIX (OS plugins)"
|
|
||||||
description "The Health Checker is collection of scripts (plugins)
|
|
||||||
designed to perform regular - but not intensive - health checks on
|
|
||||||
UNIX/Linux systems. It provides plugins for AIX, HP-UX and Linux as
|
|
||||||
well customer specific checks. Checks may include topics such file
|
|
||||||
system mounts, process checks, file consistency etc.
|
|
||||||
This is the core SLACK plugin package"
|
|
||||||
architecture S700/S800_HP-UX_10/HP-UX_11/IA64_HP-UX_11
|
|
||||||
machine_type 9000/7*|9000/8*|ia64*
|
|
||||||
os_name HP-UX
|
|
||||||
os_release ?.1?.*
|
|
||||||
os_version [A-Z]
|
|
||||||
directory /opt/hc
|
|
||||||
is_locatable false
|
|
||||||
is_patch false
|
|
||||||
|
|
||||||
postinstall scripts/hc_notify_slack.postinstall
|
|
||||||
postremove scripts/hc_notify_slack.postremove
|
|
||||||
|
|
||||||
# Fileset definitions:
|
|
||||||
fileset
|
|
||||||
tag core_plugins
|
|
||||||
title UX Health Checker (core SLACK plugins)
|
|
||||||
is_kernel false
|
|
||||||
is_locatable false
|
|
||||||
is_reboot false
|
|
||||||
is_sparse false
|
|
||||||
is_patch false
|
|
||||||
prerequisite HC-HPUX-MAIN
|
|
||||||
|
|
||||||
file_permissions -u 0222 -o root -g sys
|
|
||||||
|
|
||||||
directory ../../../opt/hc/lib/core=/opt/hc/lib/core
|
|
||||||
file -m 755 notify_slack.sh
|
|
||||||
end
|
|
||||||
|
|
||||||
fileset
|
|
||||||
tag config
|
|
||||||
title UX Health Checker (core SLACK plugins: configuration)
|
|
||||||
is_kernel false
|
|
||||||
is_locatable false
|
|
||||||
is_reboot false
|
|
||||||
is_sparse false
|
|
||||||
is_patch false
|
|
||||||
prerequisite HC-NOTIFY-SLACK-MAIN.core_plugins
|
|
||||||
|
|
||||||
file_permissions -u 0222 -o root -g sys
|
|
||||||
|
|
||||||
directory ../../../etc/opt/hc/core/providers=/etc/opt/hc/core/providers
|
|
||||||
file -m 644 notify_slack.conf.dist
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) post-install script for HC-NOTIFY-SLACK SD package
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2022 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
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of ETC dir
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
|
|
||||||
print "INFO: starting post-install script ..."
|
|
||||||
|
|
||||||
# copy plugin config file from dist (if needed)
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_slack.conf ]]
|
|
||||||
then
|
|
||||||
cp -p ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist ${HC_ETC_DIR}/core/providers/notify_slack.conf >/dev/null || \
|
|
||||||
{
|
|
||||||
print -u2 "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks || print -u2 "WARN: updating symlinks failed"
|
|
||||||
else
|
|
||||||
print -u2 "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
print "INFO: finished post-install script"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -1,48 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) post-remove script for HC-NOTIFY-SLACK SD package
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2022 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
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of the HC configuration files
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
|
|
||||||
print "INFO: starting post-remove script ..."
|
|
||||||
|
|
||||||
# remove plugin configuration file (.dist only)
|
|
||||||
if [[ -d ${HC_ETC_DIR}/core/providers ]]
|
|
||||||
then
|
|
||||||
rm -f ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist >/dev/null
|
|
||||||
(( $? == 0 )) || echo "WARN: could not remove plugin config file in directory ${HC_ETC_DIR}/core/providers"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks || print -u2 "WARN: updating symlinks failed"
|
|
||||||
else
|
|
||||||
print -u2 "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
|
||||||
fi
|
|
||||||
|
|
||||||
print "INFO: finished post-remove script"
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -19,13 +19,9 @@ package() {
|
|||||||
install -d -m 755 ${pkgdir}/opt/hc/lib
|
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
|
||||||
install -d -m 755 ${pkgdir}/opt/hc/lib/platform/linux
|
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_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_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_dovecot_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_dovecot_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
|
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
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh
|
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_age.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_age.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_change.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_file_change.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fs_mounts.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_fs_mounts.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
||||||
@ -45,15 +41,11 @@ package() {
|
|||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_hpssacli.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_hpssacli.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_process_limits.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_process_limits.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_root_crontab.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
install -D -m 755 opt/hc/lib/platform/linux/check_linux_root_crontab.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
||||||
install -D -m 755 opt/hc/lib/platform/linux/check_linux_uptime.sh ${pkgdir}/opt/hc/lib/platform/linux/check_linux_uptime.sh
|
|
||||||
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_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 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 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_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_es_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_es_status.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_fail2ban_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
|
||||||
install -D -m 644 etc/opt/hc/check_linux_fetchmail_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fetchmail_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
|
install -D -m 644 etc/opt/hc/check_linux_file_age.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_age.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_file_change.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_change.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_file_change.conf.dist ${pkgdir}/etc/opt/hc/check_linux_file_change.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_fs_usage.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fs_usage.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_fs_usage.conf.dist ${pkgdir}/etc/opt/hc/check_linux_fs_usage.conf.dist
|
||||||
@ -61,12 +53,10 @@ 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
|
||||||
install -D -m 644 etc/opt/hc/check_linux_root_crontab.conf.dist ${pkgdir}/etc/opt/hc/check_linux_root_crontab.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_root_crontab.conf.dist ${pkgdir}/etc/opt/hc/check_linux_root_crontab.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_uptime.conf.dist ${pkgdir}/etc/opt/hc/check_linux_uptime.conf.dist
|
|
||||||
install -D -m 644 etc/opt/hc/check_linux_vz_ct_counters.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_vz_ct_counters.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
||||||
install -D -m 644 etc/opt/hc/check_linux_vz_ct_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
install -D -m 644 etc/opt/hc/check_linux_vz_ct_status.conf.dist ${pkgdir}/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
||||||
install -d -m 755 ${pkgdir}/etc/opt/hc/core
|
install -d -m 755 ${pkgdir}/etc/opt/hc/core
|
||||||
|
@ -40,34 +40,6 @@ post_install() {
|
|||||||
else
|
else
|
||||||
echo "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
echo "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
||||||
fi
|
fi
|
||||||
# set SELinux contexts for logrotate
|
|
||||||
SESTATUS_BIN=$(command -v sestatus 2>/dev/null)
|
|
||||||
if [[ -n "${SESTATUS_BIN}" ]]
|
|
||||||
then
|
|
||||||
IS_ENFORCING=$(${SESTATUS_BIN} | grep -c "Current mode.*enforcing" 2>/dev/null)
|
|
||||||
if (( IS_ENFORCING > 0 ))
|
|
||||||
then
|
|
||||||
SEMANAGE_BIN=$(command -v semanage 2>/dev/null)
|
|
||||||
if [[ -n "${SEMANAGE_BIN}" ]]
|
|
||||||
then
|
|
||||||
${SEMANAGE_BIN} fcontext -a -t var_log_t "${HC_VAR_DIR}(/check_health\.sh\.log.*)?"
|
|
||||||
echo "INFO: SELinux fcontexts configured for log rotation"
|
|
||||||
if [[ -d ${HC_VAR_DIR} ]]
|
|
||||||
then
|
|
||||||
RESTORECON_BIN=$(command -v restorecon 2>/dev/null)
|
|
||||||
if [[ -n "${RESTORECON_BIN}" ]]
|
|
||||||
then
|
|
||||||
${RESTORECON_BIN} -Frv ${HC_VAR_DIR}
|
|
||||||
echo "INFO: SELinux fcontexts set on ${HC_VAR_DIR} for log rotation"
|
|
||||||
else
|
|
||||||
echo "WARN: SELinux is set to 'enforcing' but could not found 'restorecon' to set fcontexts for log rotation"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "WARN: SELinux is set to 'enforcing' but could not found 'semanage' to set fcontexts for log rotation"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-install script"
|
echo "INFO: finished post-install script"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
# -- post-install --
|
|
||||||
post_install() {
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
echo "INFO: starting post-install script ..."
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks
|
|
||||||
(( $? == 0 )) || echo "WARN: updating symlinks failed"
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-install script"
|
|
||||||
}
|
|
||||||
|
|
||||||
# -- post-remove --
|
|
||||||
post_remove() {
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
echo "INFO: starting post-uninstall script ..."
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks
|
|
||||||
(( $? == 0 )) || echo "WARN: updating symlinks failed"
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-uninstall script"
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
# Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
|
||||||
|
|
||||||
_pkgname="check_health"
|
|
||||||
pkgname="hc-notify-slack"
|
|
||||||
pkgver="%BUILD_DATE%"
|
|
||||||
pkgrel=1
|
|
||||||
pkgdesc="The KUDOS Health Checker (HC) for UNIX (Slack notify core plugin)"
|
|
||||||
arch=("any")
|
|
||||||
url="https://github.com/patvdv/${_pkgname}"
|
|
||||||
license=('GPL3')
|
|
||||||
makedepends=('git')
|
|
||||||
depends=('hc-linux')
|
|
||||||
source=("${_pkgname}::git+${url}.git#branch=master")
|
|
||||||
install=".install"
|
|
||||||
sha256sums=('SKIP')
|
|
||||||
|
|
||||||
package() {
|
|
||||||
cd "${srcdir}/${_pkgname}"
|
|
||||||
install -d -m 755 ${pkgdir}/opt/hc/lib
|
|
||||||
install -d -m 755 ${pkgdir}/opt/hc/lib/core
|
|
||||||
install -D -m 755 opt/hc/lib/core/notify_slack.sh ${pkgdir}/opt/hc/lib/core/notify_slack.sh
|
|
||||||
install -d -m 755 ${pkgdir}/etc/opt/hc
|
|
||||||
install -d -m 755 ${pkgdir}/etc/opt/hc/core
|
|
||||||
install -d -m 755 ${pkgdir}/etc/opt/hc/core/providers
|
|
||||||
install -D -m 644 etc/opt/hc/core/providers/notify_slack.conf.dist ${pkgdir}/etc/opt/hc/core/providers/notify_slack.conf.dist
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 50
|
Installed-Size: 50
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (CSV display core plugin).
|
Description: The KUDOS Health Checker (HC) for UNIX (CSV display core plugin).
|
||||||
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 50
|
Installed-Size: 50
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (init display core plugin).
|
Description: The KUDOS Health Checker (HC) for UNIX (init display core plugin).
|
||||||
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 50
|
Installed-Size: 50
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (JSON display core plugin).
|
Description: The KUDOS Health Checker (HC) for UNIX (JSON display core plugin).
|
||||||
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 50
|
Installed-Size: 50
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (terse display core plugin).
|
Description: The KUDOS Health Checker (HC) for UNIX (terse display core plugin).
|
||||||
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 50
|
Installed-Size: 50
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (Zenoss display core plugin).
|
Description: The KUDOS Health Checker (HC) for UNIX (Zenoss display core plugin).
|
||||||
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 300
|
Installed-Size: 300
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (platform plugins).
|
Description: The KUDOS Health Checker (HC) for UNIX (platform plugins).
|
||||||
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 300
|
Installed-Size: 300
|
||||||
Depends: ksh, aptitude
|
Depends: ksh
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX.
|
Description: The KUDOS Health Checker (HC) for UNIX.
|
||||||
|
@ -16,8 +16,6 @@ chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null
|
|||||||
chown root:root /etc/logrotate.d/check_health 2>/dev/null
|
chown root:root /etc/logrotate.d/check_health 2>/dev/null
|
||||||
chmod 644 /etc/logrotate.d/check_health 2>/dev/null
|
chmod 644 /etc/logrotate.d/check_health 2>/dev/null
|
||||||
# copy configuration files
|
# copy configuration files
|
||||||
if [[ -f ${HC_ETC_DIR}/core/check_health.conf.dist ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/core/check_health.conf ]]
|
if [[ ! -f ${HC_ETC_DIR}/core/check_health.conf ]]
|
||||||
then
|
then
|
||||||
# copy main configuration file
|
# copy main configuration file
|
||||||
@ -28,11 +26,6 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "WARN: could not check_health config .dist file in ${HC_ETC_DIR}/core"
|
|
||||||
fi
|
|
||||||
if [[ -f ${HC_ETC_DIR}/check_host.conf.dist ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/check_host.conf ]]
|
if [[ ! -f ${HC_ETC_DIR}/check_host.conf ]]
|
||||||
then
|
then
|
||||||
# copy host check configuration file
|
# copy host check configuration file
|
||||||
@ -43,9 +36,6 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "WARN: could not find check_host config .dist file in ${HC_ETC_DIR}"
|
|
||||||
fi
|
|
||||||
# refresh symbolic FPATH links for core includes & plugins
|
# refresh symbolic FPATH links for core includes & plugins
|
||||||
if [[ -x ${HC_BIN} ]]
|
if [[ -x ${HC_BIN} ]]
|
||||||
then
|
then
|
||||||
@ -53,32 +43,4 @@ then
|
|||||||
else
|
else
|
||||||
echo "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
echo "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
||||||
fi
|
fi
|
||||||
# set SELinux contexts for logrotate
|
|
||||||
SESTATUS_BIN=$(command -v sestatus 2>/dev/null)
|
|
||||||
if [[ -n "${SESTATUS_BIN}" ]]
|
|
||||||
then
|
|
||||||
IS_ENFORCING=$(${SESTATUS_BIN} | grep -c "Current mode.*enforcing" 2>/dev/null)
|
|
||||||
if (( IS_ENFORCING > 0 ))
|
|
||||||
then
|
|
||||||
SEMANAGE_BIN=$(command -v semanage 2>/dev/null)
|
|
||||||
if [[ -n "${SEMANAGE_BIN}" ]]
|
|
||||||
then
|
|
||||||
${SEMANAGE_BIN} fcontext -a -t var_log_t "${HC_VAR_DIR}(/check_health\.sh\.log.*)?"
|
|
||||||
echo "INFO: SELinux fcontexts configured for log rotation"
|
|
||||||
if [[ -d ${HC_VAR_DIR} ]]
|
|
||||||
then
|
|
||||||
RESTORECON_BIN=$(command -v restorecon 2>/dev/null)
|
|
||||||
if [[ -n "${RESTORECON_BIN}" ]]
|
|
||||||
then
|
|
||||||
${RESTORECON_BIN} -Frv ${HC_VAR_DIR}
|
|
||||||
echo "INFO: SELinux fcontexts set on ${HC_VAR_DIR} for log rotation"
|
|
||||||
else
|
|
||||||
echo "WARN: SELinux is set to 'enforcing' but could not found 'restorecon' to set fcontexts for log rotation"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "WARN: SELinux is set to 'enforcing' but could not found 'semanage' to set fcontexts for log rotation"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-install script"
|
echo "INFO: finished post-install script"
|
||||||
|
@ -10,9 +10,8 @@ HC_VAR_DIR="/var/opt/hc"
|
|||||||
echo "INFO: starting post-uninstall script ..."
|
echo "INFO: starting post-uninstall script ..."
|
||||||
if [[ -d ${HC_DIR} ]]
|
if [[ -d ${HC_DIR} ]]
|
||||||
then
|
then
|
||||||
# remove all symlinks
|
rm -rf ${HC_DIR} 2>/dev/null
|
||||||
find ${HC_DIR} -type l -exec rm -f {} \; 2>/dev/null
|
(( $? == 0 )) || echo "WARN: failed to remove ${HC_DIR}"
|
||||||
(( $? == 0 )) || echo "WARN: failed to remove symlinks in ${HC_DIR}"
|
|
||||||
fi
|
fi
|
||||||
if [[ -d ${HC_ETC_DIR} ]]
|
if [[ -d ${HC_ETC_DIR} ]]
|
||||||
then
|
then
|
||||||
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 50
|
Installed-Size: 50
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (EIF notify core plugin).
|
Description: The KUDOS Health Checker (HC) for UNIX (EIF notify core plugin).
|
||||||
|
@ -10,8 +10,6 @@ echo "INFO: starting post-install script ..."
|
|||||||
# debian: reset ownerships
|
# debian: reset ownerships
|
||||||
chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null
|
chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null
|
||||||
# copy plugin configuration file
|
# copy plugin configuration file
|
||||||
if [[ -f ${HC_ETC_DIR}/core/providers/notify_eif.conf.dist ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_eif.conf ]]
|
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_eif.conf ]]
|
||||||
then
|
then
|
||||||
cp -p ${HC_ETC_DIR}/core/providers/notify_eif.conf.dist ${HC_ETC_DIR}/core/providers/notify_eif.conf >/dev/null
|
cp -p ${HC_ETC_DIR}/core/providers/notify_eif.conf.dist ${HC_ETC_DIR}/core/providers/notify_eif.conf >/dev/null
|
||||||
@ -21,9 +19,6 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "WARN: could not find plugin config .dist file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
fi
|
|
||||||
# refresh symbolic FPATH links
|
# refresh symbolic FPATH links
|
||||||
if [[ -x ${HC_BIN} ]]
|
if [[ -x ${HC_BIN} ]]
|
||||||
then
|
then
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
Package: hc-notify-slack
|
|
||||||
Version: %BUILD_DATE%
|
|
||||||
Architecture: all
|
|
||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
|
||||||
Essential: no
|
|
||||||
Installed-Size: 50
|
|
||||||
Pre-Depends: hc-linux
|
|
||||||
Section: tools
|
|
||||||
Priority: extra
|
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (Slack notify core plugin).
|
|
@ -1,33 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of the HC configuration files
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
echo "INFO: starting post-install script ..."
|
|
||||||
# debian: reset ownerships
|
|
||||||
chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null
|
|
||||||
# copy plugin configuration file
|
|
||||||
if [[ -f ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_slack.conf ]]
|
|
||||||
then
|
|
||||||
cp -p ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist ${HC_ETC_DIR}/core/providers/notify_slack.conf >/dev/null
|
|
||||||
(( $? == 0 )) || \
|
|
||||||
{
|
|
||||||
echo "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "WARN: could not find plugin config .dist file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
fi
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks
|
|
||||||
(( $? == 0 )) || echo "WARN: updating symlinks failed"
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-install script"
|
|
@ -1,32 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of the HC configuration files
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
# update or uninstall?
|
|
||||||
if (( $1 == 0 ))
|
|
||||||
then
|
|
||||||
echo "INFO: starting post-uninstall script ..."
|
|
||||||
# copy plugin configuration file (.dist only)
|
|
||||||
if [[ -d ${HC_ETC_DIR}/core/providers ]]
|
|
||||||
then
|
|
||||||
rm -f ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist 2>/dev/null
|
|
||||||
(( $? == 0 )) || \
|
|
||||||
{
|
|
||||||
echo "ERROR: could not remove plugin config file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "INFO: starting post-uninstall script (RPM upgrade)"
|
|
||||||
fi
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks
|
|
||||||
(( $? == 0 )) || echo "WARN: updating symlinks failed"
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-uninstall script"
|
|
@ -4,7 +4,7 @@ Architecture: all
|
|||||||
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
Maintainer: Patrick Van der Veken <patrick@kudos.be>
|
||||||
Essential: no
|
Essential: no
|
||||||
Installed-Size: 50
|
Installed-Size: 50
|
||||||
Pre-Depends: hc-linux
|
Depends: hc-linux
|
||||||
Section: tools
|
Section: tools
|
||||||
Priority: extra
|
Priority: extra
|
||||||
Description: The KUDOS Health Checker (HC) for UNIX (SMS notify core plugin).
|
Description: The KUDOS Health Checker (HC) for UNIX (SMS notify core plugin).
|
||||||
|
@ -10,8 +10,6 @@ echo "INFO: starting post-install script ..."
|
|||||||
# debian: reset ownerships
|
# debian: reset ownerships
|
||||||
chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null
|
chown -R root:root /opt/hc /etc/opt/hc 2>/dev/null
|
||||||
# copy plugin configuration file
|
# copy plugin configuration file
|
||||||
if [[ -f ${HC_ETC_DIR}/core/providers/notify_sms.conf.dist ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_sms.conf ]]
|
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_sms.conf ]]
|
||||||
then
|
then
|
||||||
cp -p ${HC_ETC_DIR}/core/providers/notify_sms.conf.dist ${HC_ETC_DIR}/core/providers/notify_sms.conf >/dev/null
|
cp -p ${HC_ETC_DIR}/core/providers/notify_sms.conf.dist ${HC_ETC_DIR}/core/providers/notify_sms.conf >/dev/null
|
||||||
@ -21,9 +19,6 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "WARN: could not find plugin config .dist file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
fi
|
|
||||||
# refresh symbolic FPATH links
|
# refresh symbolic FPATH links
|
||||||
if [[ -x ${HC_BIN} ]]
|
if [[ -x ${HC_BIN} ]]
|
||||||
then
|
then
|
||||||
|
@ -27,13 +27,9 @@ 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
|
||||||
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/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_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_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_dovecot_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_dovecot_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
|
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
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fetchmail_status.sh
|
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_age.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_age.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_age.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_change.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_file_change.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_file_change.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_fs_mounts.sh
|
||||||
@ -53,15 +49,11 @@ cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_hplog.sh $RPM_BUILD_ROOT/opt
|
|||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_hpssacli.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_hpssacli.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_process_limits.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_process_limits.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_root_crontab.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_root_crontab.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
||||||
cp ../SOURCES/opt/hc/lib/platform/linux/check_linux_uptime.sh $RPM_BUILD_ROOT/opt/hc/lib/platform/linux/check_linux_uptime.sh
|
|
||||||
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_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
|
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
|
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_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_es_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_es_status.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_fail2ban_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_fetchmail_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fetchmail_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
|
cp ../SOURCES/etc/opt/hc/check_linux_file_age.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_age.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_file_change.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_change.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_file_change.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_file_change.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_fs_usage.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fs_usage.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_fs_usage.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_fs_usage.conf.dist
|
||||||
@ -69,12 +61,10 @@ 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
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_root_crontab.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_root_crontab.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_root_crontab.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_root_crontab.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_uptime.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_uptime.conf.dist
|
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_counters.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_counters.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
||||||
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
cp ../SOURCES/etc/opt/hc/check_linux_vz_ct_status.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc/core
|
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc/core
|
||||||
@ -117,13 +107,9 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%dir /opt/hc/lib
|
%dir /opt/hc/lib
|
||||||
%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_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_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_burp_status.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_dovecot_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_es_status.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fail2ban_status.sh
|
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_fetchmail_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
|
||||||
@ -143,15 +129,11 @@ echo "INFO: finished post-uninstall script"
|
|||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_hpssacli.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_process_limits.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_root_crontab.sh
|
||||||
%attr(755, root, root) /opt/hc/lib/platform/linux/check_linux_uptime.sh
|
|
||||||
%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_counters.sh
|
||||||
%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_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_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_es_status.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_fail2ban_status.conf.dist
|
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_fetchmail_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
|
||||||
@ -159,12 +141,10 @@ 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
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_root_crontab.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_root_crontab.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_uptime.conf.dist
|
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_counters.conf.dist
|
||||||
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
%attr(644, root, root) /etc/opt/hc/check_linux_vz_ct_status.conf.dist
|
||||||
%dir /etc/opt/hc/core
|
%dir /etc/opt/hc/core
|
||||||
@ -173,17 +153,6 @@ 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 Dec 26 2020 <patrick@kudos.be> - 0.3.5
|
|
||||||
- Added check_linux_fetchmail_status plugin
|
|
||||||
- Added check_linux_dovecot_status plugin
|
|
||||||
* Mon Dec 21 2020 <patrick@kudos.be> - 0.3.4
|
|
||||||
- Added check_linux_uptime plugin
|
|
||||||
* Fri Oct 18 2020 <patrick@kudos.be> - 0.3.3
|
|
||||||
- Added check_linux_fail2ban_status plugin
|
|
||||||
* 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
|
|
||||||
- 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
|
||||||
- Removed Serviceguard plugins
|
- Removed Serviceguard plugins
|
||||||
* Tue Mar 26 2019 <patrick@kudos.be> - 0.2.0
|
* Tue Mar 26 2019 <patrick@kudos.be> - 0.2.0
|
||||||
|
@ -88,34 +88,6 @@ then
|
|||||||
else
|
else
|
||||||
echo "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
echo "ERROR: could not locate or excute the HC main script (${HC_BIN})"
|
||||||
fi
|
fi
|
||||||
# set SELinux contexts for logrotate
|
|
||||||
SESTATUS_BIN=$(command -v sestatus 2>/dev/null)
|
|
||||||
if [[ -n "${SESTATUS_BIN}" ]]
|
|
||||||
then
|
|
||||||
IS_ENFORCING=$(${SESTATUS_BIN} | grep -c "Current mode.*enforcing" 2>/dev/null)
|
|
||||||
if (( IS_ENFORCING > 0 ))
|
|
||||||
then
|
|
||||||
SEMANAGE_BIN=$(command -v semanage 2>/dev/null)
|
|
||||||
if [[ -n "${SEMANAGE_BIN}" ]]
|
|
||||||
then
|
|
||||||
${SEMANAGE_BIN} fcontext -a -t var_log_t "${HC_VAR_DIR}(/check_health\.sh\.log.*)?"
|
|
||||||
echo "INFO: SELinux fcontexts configured for log rotation"
|
|
||||||
if [[ -d ${HC_VAR_DIR} ]]
|
|
||||||
then
|
|
||||||
RESTORECON_BIN=$(command -v restorecon 2>/dev/null)
|
|
||||||
if [[ -n "${RESTORECON_BIN}" ]]
|
|
||||||
then
|
|
||||||
${RESTORECON_BIN} -Frv ${HC_VAR_DIR}
|
|
||||||
echo "INFO: SELinux fcontexts set on ${HC_VAR_DIR} for log rotation"
|
|
||||||
else
|
|
||||||
echo "WARN: SELinux is set to 'enforcing' but could not found 'restorecon' to set fcontexts for log rotation"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "WARN: SELinux is set to 'enforcing' but could not found 'semanage' to set fcontexts for log rotation"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-install script"
|
echo "INFO: finished post-install script"
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
|
@ -1,107 +0,0 @@
|
|||||||
%define build_timestamp %(date +"%Y%m%d")
|
|
||||||
|
|
||||||
Name: hc-notify-slack
|
|
||||||
Version: %{build_timestamp}
|
|
||||||
Release: 1
|
|
||||||
|
|
||||||
Summary: The KUDOS Health Checker (HC) for UNIX (Slack notify core plugin)
|
|
||||||
Group: Tools/Monitoring
|
|
||||||
|
|
||||||
License: GNU General Public License either version 2 of the License, or (at your option) any later version
|
|
||||||
URL: http://www.kudos.be
|
|
||||||
|
|
||||||
Requires: ksh,hc-linux
|
|
||||||
BuildArch: noarch
|
|
||||||
BuildRoot: %{_topdir}/%{name}-%{version}-root
|
|
||||||
|
|
||||||
%description
|
|
||||||
The Health Checker is collection of scripts (plugins) designed to perform regular - but not intensive - health checks on UNIX/Linux systems. It provides plugins for AIX, HP-UX and Linux as well customer specific checks. Checks may include topics such file system mounts, process checks, file consistency etc.
|
|
||||||
This package contains core plugins (notify).
|
|
||||||
|
|
||||||
%prep
|
|
||||||
|
|
||||||
%build
|
|
||||||
|
|
||||||
%install
|
|
||||||
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/core
|
|
||||||
cp ../SOURCES/opt/hc/lib/core/notify_slack.sh $RPM_BUILD_ROOT/opt/hc/lib/core/notify_slack.sh
|
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc
|
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc/core
|
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/etc/opt/hc/core/providers
|
|
||||||
cp ../SOURCES/etc/opt/hc/core/providers/notify_slack.conf.dist $RPM_BUILD_ROOT/etc/opt/hc/core/providers/notify_slack.conf.dist
|
|
||||||
|
|
||||||
%post
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of the HC configuration files
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
echo "INFO: starting post-install script ..."
|
|
||||||
# copy plugin configuration file
|
|
||||||
if [[ ! -f ${HC_ETC_DIR}/core/providers/notify_slack.conf ]]
|
|
||||||
then
|
|
||||||
cp -p ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist ${HC_ETC_DIR}/core/providers/notify_slack.conf >/dev/null
|
|
||||||
(( $? == 0 )) || \
|
|
||||||
{
|
|
||||||
echo "ERROR: could not copy plugin config file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks
|
|
||||||
(( $? == 0 )) || echo "WARN: updating symlinks failed"
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-install script"
|
|
||||||
|
|
||||||
%postun
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
# location of the HC configuration files
|
|
||||||
HC_ETC_DIR="/etc/opt/hc"
|
|
||||||
# location of check_health.sh
|
|
||||||
HC_BIN="/opt/hc/bin/check_health.sh"
|
|
||||||
PATH="$PATH:/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
|
||||||
# update or uninstall?
|
|
||||||
if (( $1 == 0 ))
|
|
||||||
then
|
|
||||||
echo "INFO: starting post-uninstall script ..."
|
|
||||||
# copy plugin configuration file (.dist only)
|
|
||||||
if [[ -d ${HC_ETC_DIR}/core/providers ]]
|
|
||||||
then
|
|
||||||
rm -f ${HC_ETC_DIR}/core/providers/notify_slack.conf.dist 2>/dev/null
|
|
||||||
(( $? == 0 )) || \
|
|
||||||
{
|
|
||||||
echo "ERROR: could not remove plugin config file in ${HC_ETC_DIR}/core/providers"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "INFO: starting post-uninstall script (RPM upgrade)"
|
|
||||||
fi
|
|
||||||
# refresh symbolic FPATH links
|
|
||||||
if [[ -x ${HC_BIN} ]]
|
|
||||||
then
|
|
||||||
${HC_BIN} --fix-symlinks
|
|
||||||
(( $? == 0 )) || echo "WARN: updating symlinks failed"
|
|
||||||
fi
|
|
||||||
echo "INFO: finished post-uninstall script"
|
|
||||||
|
|
||||||
%files
|
|
||||||
%defattr(-,root,root,755)
|
|
||||||
%dir /opt/hc/lib
|
|
||||||
%dir /opt/hc/lib/core
|
|
||||||
%attr(755, root, root) /opt/hc/lib/core/notify_slack.sh
|
|
||||||
%dir /etc/opt/hc
|
|
||||||
%dir /etc/opt/hc/core
|
|
||||||
%dir /etc/opt/hc/core/providers
|
|
||||||
%attr(644, root, root) /etc/opt/hc/core/providers/notify_slack.conf.dist
|
|
||||||
|
|
||||||
%changelog
|
|
||||||
* Sun Oct 14 2022 <patrick@kudos.be> - 0.0.1
|
|
||||||
- Initial build
|
|
@ -47,7 +47,6 @@ rpmbuild -bb ${BUILD_DIR}/SPECS/hc-linux-platform.spec
|
|||||||
# build core plugins
|
# build core plugins
|
||||||
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-notify-eif.spec
|
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-notify-eif.spec
|
||||||
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-notify-sms.spec
|
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-notify-sms.spec
|
||||||
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-notify-slack.spec
|
|
||||||
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-display-init.spec
|
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-display-init.spec
|
||||||
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-display-json.spec
|
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-display-json.spec
|
||||||
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-display-csv.spec
|
rpmbuild -bb ${BUILD_DIR}/SPECS/hc-display-csv.spec
|
||||||
|
@ -13,11 +13,9 @@ log_healthy="no"
|
|||||||
|
|
||||||
# full path to the location of mksysb images, the tool expects sub-directories
|
# full path to the location of mksysb images, the tool expects sub-directories
|
||||||
# per host underneath this location
|
# per host underneath this location
|
||||||
# [default: /export/images]
|
|
||||||
backup_path=/export/images
|
backup_path=/export/images
|
||||||
|
|
||||||
# name of the file containing the mksysb output
|
# name of the file containing the mksysb output
|
||||||
# [default: mksysb.log]
|
|
||||||
mksysb_log=mksysb.log
|
mksysb_log=mksysb.log
|
||||||
|
|
||||||
# maximum days before backup gets flagged as 'too old'
|
# maximum days before backup gets flagged as 'too old'
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_aix_uptime.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_aix_uptime 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"
|
|
||||||
|
|
||||||
# trigger event when current uptime is less than previously record uptime?
|
|
||||||
# [default: yes]
|
|
||||||
check_reboot="yes"
|
|
||||||
|
|
||||||
# time to wait before the current uptime is considered for the reboot check.
|
|
||||||
# Example: a value of 60m means the check for a previous reboot will be at earliest
|
|
||||||
# performed 1 hour after the last reboot of the host.
|
|
||||||
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
|
||||||
# if no suffix is specified, then minutes are assumed.
|
|
||||||
# [default: 60m]
|
|
||||||
reboot_time="60m"
|
|
||||||
|
|
||||||
# trigger event when current uptime goes over the maximum threshold?
|
|
||||||
# [default: no]
|
|
||||||
check_old_age="no"
|
|
||||||
|
|
||||||
# time to expire before the current uptime is considered "old age".
|
|
||||||
# Example: a value of 365d means a must-reboot will be flagged at earliest after
|
|
||||||
# 1 year of uptime of the host
|
|
||||||
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
|
||||||
# if no suffix is specified, then minutes are assumed.
|
|
||||||
# [default: 365d]
|
|
||||||
old_age_time="365d"
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -27,10 +27,6 @@ check_controller="yes"
|
|||||||
# [default: yes]
|
# [default: yes]
|
||||||
check_bbu="yes"
|
check_bbu="yes"
|
||||||
|
|
||||||
# specify whether to check the BBU (supercap) state (yes|no)
|
|
||||||
# [default: yes]
|
|
||||||
check_supercap="yes"
|
|
||||||
|
|
||||||
# specify whether to check the physical devices (yes|no)
|
# specify whether to check the physical devices (yes|no)
|
||||||
# [default: yes]
|
# [default: yes]
|
||||||
check_physical="yes"
|
check_physical="yes"
|
||||||
@ -39,14 +35,6 @@ check_physical="yes"
|
|||||||
# [default: yes]
|
# [default: yes]
|
||||||
check_virtual="yes"
|
check_virtual="yes"
|
||||||
|
|
||||||
# individual checks that should be disabled (wildcards are not supported)
|
|
||||||
# cell_exclude:<cell_server>:<controller|bbu|supercap|physical|virtual>
|
|
||||||
# Examples:
|
|
||||||
# disable controller check on mycell1
|
|
||||||
# cell_exclude:mycell1:controller
|
|
||||||
# disable bbu check on mycell2
|
|
||||||
# cell_exclude:mycell2:bbu
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# End of FILE
|
# End of FILE
|
||||||
|
@ -19,10 +19,6 @@ check_controller="yes"
|
|||||||
# [default: yes]
|
# [default: yes]
|
||||||
check_bbu="yes"
|
check_bbu="yes"
|
||||||
|
|
||||||
# specify whether to check the BBU (supercap) state (yes|no)
|
|
||||||
# [default: yes]
|
|
||||||
check_supercap="yes"
|
|
||||||
|
|
||||||
# specify whether to check the physical devices (yes|no)
|
# specify whether to check the physical devices (yes|no)
|
||||||
# [default: yes]
|
# [default: yes]
|
||||||
check_physical="yes"
|
check_physical="yes"
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_exadata_zfs_cluster.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_exadata_zfs_cluster 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 user account for the SSH session to the ZFS appliance(s)
|
|
||||||
# [default: root]
|
|
||||||
ssh_user=""
|
|
||||||
|
|
||||||
# specify the private key file for the SSH session to the ZFS appliance(s)
|
|
||||||
# [default: ~root/.ssh/id_rsa]
|
|
||||||
ssh_key_file=""
|
|
||||||
|
|
||||||
# specify additional options for the SSH session to the ZFS appliance(s)
|
|
||||||
# [default: null]
|
|
||||||
ssh_opts=""
|
|
||||||
|
|
||||||
# specify the ZFS hostname(s) to check the cluster states on
|
|
||||||
# Format:
|
|
||||||
# zfs:<host_name>
|
|
||||||
# Examples:
|
|
||||||
# zfs:myzfs1
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -1,7 +1,7 @@
|
|||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# @(#) check_exadata_zfs_logs.conf
|
# @(#) check_exadata_zfs_share_usage.conf
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# This is a configuration file for the check_exadata_zfs_logs HC plugin.
|
# This is a configuration file for the check_exadata_zfs_share_usage HC plugin.
|
||||||
# All lines starting with a '#' are comment lines.
|
# All lines starting with a '#' are comment lines.
|
||||||
# [default: indicates hardcoded script values if no value is defined here]
|
# [default: indicates hardcoded script values if no value is defined here]
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
@ -33,26 +33,21 @@ max_replication_lag=300
|
|||||||
# will for this given share will be skipped (this allows for exclusion of shares)
|
# will for this given share will be skipped (this allows for exclusion of shares)
|
||||||
# In order to check share(s) for a given ZFS appliance at least one configuration
|
# In order to check share(s) for a given ZFS appliance at least one configuration
|
||||||
# entry must be present: either a wildcard or custom entry.
|
# entry must be present: either a wildcard or custom entry.
|
||||||
# Caveat: any share must finally resolve to one entry only.
|
|
||||||
# Format:
|
# Format:
|
||||||
# zfs:<host_name>:<replication_name|*>:<true|false|*>:<success|failed|*>:[<max_replication_lag>]:[day1,day2,..|*>]:[<hour|<start_hour-end_hour>|*>]
|
# zfs:<host_name>:<replication_name|*>:<true|false|*>:<success|failed|*>:[<max_replication_lag>]
|
||||||
#
|
|
||||||
# <day>: 3 letter day name (case insensitive)
|
|
||||||
# <hour>: 24 hours notation (start and end hours are inclusive)
|
|
||||||
#
|
|
||||||
# Examples:
|
# Examples:
|
||||||
# check rep_share1 on myzfs1 with a custom threshold of 300 seconds on every day of the week
|
# check rep_share1 on myzfs1 with a custom threshold of 300 seconds
|
||||||
# zfs:myzfs1:rep_share1:*:*:600:*
|
# zfs:myzfs1:rep_share1:*:*:600
|
||||||
# check all shares of myzfs2 with a custom threshold of 1200 seconds on Sunday and Monday
|
# check all shares of myzfs2 with a custom threshold of 1200 seconds
|
||||||
# zfs:myzfs2:*:*:*:1200:Sun,Mon
|
# zfs:myzfs2:*:*:*:1200
|
||||||
# check all shares of myzfs3 with the general threshold but only on Friday between 7am-10m
|
# check all shares of myzfs3 with the general threshold
|
||||||
# zfs:myzfs3:*:*:*:Fri:07-10
|
# zfs:myzfs3:*:*:*:
|
||||||
# disable all shares of myzfs4 from checking
|
# disable all shares of myzfs4 from checking
|
||||||
# zfs:myzfs4:*:*:*:0:*
|
# zfs:myzfs4:*:*:*:0
|
||||||
# disable check of rep_share7 on myzfs5
|
# disable check of rep_share7 on myzfs5
|
||||||
# zfs:myzfs5:rep_share7:*:*:0:*
|
# zfs:myzfs5:rep_share7:*:*:0
|
||||||
# check that rep_share4 on myzfs6 is inactive (every day of the week)
|
# check that rep_share4 on myzfs6 is inactive
|
||||||
# zfs:myzfs6:rep_share4:false:*:*
|
# zfs:myzfs6:rep_share4:false:*:
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
@ -33,7 +33,6 @@ max_space_usage=90
|
|||||||
# will for this given share will be skipped (this allows for exclusion of shares)
|
# will for this given share will be skipped (this allows for exclusion of shares)
|
||||||
# In order to check share(s) for a given ZFS appliance at least one configuration
|
# In order to check share(s) for a given ZFS appliance at least one configuration
|
||||||
# entry must be present: either a wildcard or custom entry.
|
# entry must be present: either a wildcard or custom entry.
|
||||||
# Caveat: any share must finally resolve to one entry only.
|
|
||||||
# Format:
|
# Format:
|
||||||
# zfs:<host_name>:<project_name|*>:<share_name|*>:[<usage_threshold_%>]
|
# zfs:<host_name>:<project_name|*>:<share_name|*>:[<usage_threshold_%>]
|
||||||
# Examples:
|
# Examples:
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_hpux_autofs.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_hpux_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 fix autofs (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
|
|
||||||
#******************************************************************************
|
|
@ -1,25 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_hpux_cron_status.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_hpux_cron_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 the wait time (in seconds) between registering and checking a cron task
|
|
||||||
# [default: 10]
|
|
||||||
wait_time=10
|
|
||||||
|
|
||||||
# specify the path the cron log file
|
|
||||||
# [default: /var/adm/cron/log]
|
|
||||||
cron_log="/var/adm/cron/log"
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -1,27 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_hpux_defunct_processes.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_hpux_defunct_processes 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 above which threshold of defunct processes to generate a HC fail event
|
|
||||||
# If group_by_ppid is set to 'yes' then the value of 'process_threshold' will
|
|
||||||
# apply for each PPID, otherwise it will apply to all defunct processes together
|
|
||||||
# [default: 10]
|
|
||||||
process_threshold=10
|
|
||||||
|
|
||||||
# specify whether to group by parent ID or not.
|
|
||||||
# [default: yes]
|
|
||||||
group_by_ppid="yes"
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -32,7 +32,7 @@ max_space_usage=90
|
|||||||
# defining a threshold of 0 (zero), then the check will for this give filesystem
|
# defining a threshold of 0 (zero), then the check will for this give filesystem
|
||||||
# will be skipped (this allows for exclusion of filesystems)
|
# will be skipped (this allows for exclusion of filesystems)
|
||||||
# Format:
|
# Format:
|
||||||
# fs:<mount_point>:[<max_inodes_usage_%>]:[<max_space_usage_%]
|
# fs:<mount_point>:[<max_inode_usage_%>]:[<max_space_usage_%]
|
||||||
# Examples:
|
# Examples:
|
||||||
# check myfs1 with a custom inodes + space usage threshold
|
# check myfs1 with a custom inodes + space usage threshold
|
||||||
#fs:myfs1:70:95
|
#fs:myfs1:70:95
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# [default: no]
|
# [default: no]
|
||||||
log_healthy="no"
|
log_healthy="no"
|
||||||
|
|
||||||
# specify properties as displayed by the 'hpvmstatus -M' command
|
# specify properties as displayed by the 'vzlist -a -H -o ctid,status,onboot' command
|
||||||
# Format:
|
# Format:
|
||||||
# [vpar:<parid>:<runtime_status>:<boot_status>]
|
# [vpar:<parid>:<runtime_status>:<boot_status>]
|
||||||
# runtime_status should be 'on' or 'off'
|
# runtime_status should be 'on' or 'off'
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_hpux_uptime.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_hpux_uptime 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"
|
|
||||||
|
|
||||||
# trigger event when current uptime is less than previously record uptime?
|
|
||||||
# [default: yes]
|
|
||||||
check_reboot="yes"
|
|
||||||
|
|
||||||
# time to wait before the current uptime is considered for the reboot check.
|
|
||||||
# Example: a value of 60m means the check for a previous reboot will be at earliest
|
|
||||||
# performed 1 hour after the last reboot of the host.
|
|
||||||
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
|
||||||
# if no suffix is specified, then minutes are assumed.
|
|
||||||
# [default: 60m]
|
|
||||||
reboot_time="60m"
|
|
||||||
|
|
||||||
# trigger event when current uptime goes over the maximum threshold?
|
|
||||||
# [default: no]
|
|
||||||
check_old_age="no"
|
|
||||||
|
|
||||||
# time to expire before the current uptime is considered "old age".
|
|
||||||
# Example: a value of 365d means a must-reboot will be flagged at earliest after
|
|
||||||
# 1 year of uptime of the host
|
|
||||||
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
|
||||||
# if no suffix is specified, then minutes are assumed.
|
|
||||||
# [default: 365d]
|
|
||||||
old_age_time="365d"
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -1,31 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) 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 fix autofs (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
|
|
||||||
#******************************************************************************
|
|
@ -1,27 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_linux_fail2ban_status.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_linux_fail2ban_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]
|
|
||||||
check_type="auto"
|
|
||||||
|
|
||||||
# specify the list jails to status check (comma-separated)
|
|
||||||
# Format: jail1,jail2,jail3,...
|
|
||||||
# [default: none]
|
|
||||||
check_jails=""
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -1,28 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_linux_fetchmail_status.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_linux_fetchmail_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 the regex of error codes that will be used to search the log file_path
|
|
||||||
# [default: error|authfail|lockbusy|ioerr]
|
|
||||||
error_regex="error|authfail|lockbusy|ioerr"
|
|
||||||
|
|
||||||
# specify fetchmail details
|
|
||||||
# Format:
|
|
||||||
# fetchmail:<account>:<rc_file>:<check_log=Yes|No>
|
|
||||||
# Examples:
|
|
||||||
#fetchmail:vmail:/srv/vmail/janedoe/.fetchmailrc:Yes
|
|
||||||
#fetchmail:vmail:/srv/vmail/johndoe/.fetchmailrc:No
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -32,7 +32,7 @@ max_space_usage=90
|
|||||||
# defining a threshold of 0 (zero), then the check will for this give filesystem
|
# defining a threshold of 0 (zero), then the check will for this give filesystem
|
||||||
# will be skipped (this allows for exclusion of filesystems)
|
# will be skipped (this allows for exclusion of filesystems)
|
||||||
# Format:
|
# Format:
|
||||||
# fs:<mount_point>:[<max_inodes_usage_%>]:[<max_space_usage_%]
|
# fs:<mount_point>:[<max_inode_usage_%>]:[<max_space_usage_%]
|
||||||
# Examples:
|
# Examples:
|
||||||
# check myfs1 with a custom inodes + space usage threshold
|
# check myfs1 with a custom inodes + space usage threshold
|
||||||
#fs:myfs1:70:95
|
#fs:myfs1:70:95
|
||||||
|
@ -12,23 +12,18 @@
|
|||||||
log_healthy="no"
|
log_healthy="no"
|
||||||
|
|
||||||
# location of 'hpacucli' tool
|
# location of 'hpacucli' tool
|
||||||
# [default: /usr/sbin/hpacucli]
|
|
||||||
hpacucli_bin="/usr/sbin/hpacucli"
|
hpacucli_bin="/usr/sbin/hpacucli"
|
||||||
|
|
||||||
# controller all show status (0=off, 1=on)
|
# controller all show status (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_acu_controller=1
|
do_acu_controller=1
|
||||||
|
|
||||||
# controller slot=X enclosure all show (0=off, 1=on)
|
# controller slot=X enclosure all show (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_acu_enclosure=1
|
do_acu_enclosure=1
|
||||||
|
|
||||||
# controller slot=X physicaldrive all show status (0=off, 1=on)
|
# controller slot=X physicaldrive all show status (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_acu_physical=1
|
do_acu_physical=1
|
||||||
|
|
||||||
# controller slot=X logicaldrive all show status (0=off, 1=on)
|
# controller slot=X logicaldrive all show status (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_acu_logical=1
|
do_acu_logical=1
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,27 +12,21 @@
|
|||||||
log_healthy="no"
|
log_healthy="no"
|
||||||
|
|
||||||
# location of 'hpasmcli' tool
|
# location of 'hpasmcli' tool
|
||||||
# [default: /sbin/hpasmcli]
|
|
||||||
hpasmcli_bin="/sbin/hpasmcli"
|
hpasmcli_bin="/sbin/hpasmcli"
|
||||||
|
|
||||||
# SHOW FANS (0=off, 1=on)
|
# SHOW FANS (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_asm_fans=1
|
do_asm_fans=1
|
||||||
|
|
||||||
# SHOW DIMM (0=off, 1=on)
|
# SHOW DIMM (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_asm_dimm=1
|
do_asm_dimm=1
|
||||||
|
|
||||||
# SHOW POWERSUPPLY (0=off, 1=on)
|
# SHOW POWERSUPPLY (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_asm_powersupply=1
|
do_asm_powersupply=1
|
||||||
|
|
||||||
# SHOW SERVER (0=off, 1=on)
|
# SHOW SERVER (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_asm_server=1
|
do_asm_server=1
|
||||||
|
|
||||||
# SHOW TEMPERATURE (0=off, 1=on)
|
# SHOW TEMPERATURE (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_asm_temperature=1
|
do_asm_temperature=1
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
log_healthy="no"
|
log_healthy="no"
|
||||||
|
|
||||||
# location of 'hpacucli' tool
|
# location of 'hpacucli' tool
|
||||||
# [default: /sbin/hplog]
|
|
||||||
hplog_bin="/sbin/hplog"
|
hplog_bin="/sbin/hplog"
|
||||||
|
|
||||||
# comma-separated list of severities to search for (case insensitive)
|
# comma-separated list of severities to search for (case insensitive)
|
||||||
|
@ -12,23 +12,18 @@
|
|||||||
log_healthy="no"
|
log_healthy="no"
|
||||||
|
|
||||||
# location of 'hpssacli' tool
|
# location of 'hpssacli' tool
|
||||||
# [default: /usr/sbin/hpssacli]
|
|
||||||
hpssacli_bin="/usr/sbin/hpssacli"
|
hpssacli_bin="/usr/sbin/hpssacli"
|
||||||
|
|
||||||
# controller all show status (0=off, 1=on)
|
# controller all show status (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_ssa_controller=1
|
do_ssa_controller=1
|
||||||
|
|
||||||
# controller slot=X enclosure all show (0=off, 1=on)
|
# controller slot=X enclosure all show (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_ssa_enclosure=1
|
do_ssa_enclosure=1
|
||||||
|
|
||||||
# controller slot=X physicaldrive all show status (0=off, 1=on)
|
# controller slot=X physicaldrive all show status (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_ssa_physical=1
|
do_ssa_physical=1
|
||||||
|
|
||||||
# controller slot=X logicaldrive all show status (0=off, 1=on)
|
# controller slot=X logicaldrive all show status (0=off, 1=on) [default: 1]
|
||||||
# [default: 1]
|
|
||||||
do_ssa_logical=1
|
do_ssa_logical=1
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) 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]
|
|
||||||
# [release >20191101]
|
|
||||||
check_type="auto"
|
|
||||||
|
|
||||||
# specify name of the httpd binary
|
|
||||||
# Format: httpd|apache|apache2
|
|
||||||
# [default: httpd]
|
|
||||||
# [release >20201010]
|
|
||||||
httpd_bin="httpd"
|
|
||||||
|
|
||||||
# specify custom path to the httpd binary
|
|
||||||
# [default: null]
|
|
||||||
# [release >20201010]
|
|
||||||
httpd_path=""
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -19,11 +19,6 @@ force_chrony="no"
|
|||||||
# [default: no]
|
# [default: no]
|
||||||
force_ntp="no"
|
force_ntp="no"
|
||||||
|
|
||||||
# whether to force the use of systemd-timesyncd?
|
|
||||||
# [default: no]
|
|
||||||
# [release >20220129]
|
|
||||||
force_systemd="no"
|
|
||||||
|
|
||||||
# maximum allowed offset (in milliseconds (positive integers only)
|
# maximum allowed offset (in milliseconds (positive integers only)
|
||||||
# [default: 500]
|
# [default: 500]
|
||||||
max_offset=500
|
max_offset=500
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) check_linux_uptime.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is a configuration file for the check_linux_uptime 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"
|
|
||||||
|
|
||||||
# trigger event when current uptime is less than previously record uptime?
|
|
||||||
# [default: yes]
|
|
||||||
check_reboot="yes"
|
|
||||||
|
|
||||||
# time to wait before the current uptime is considered for the reboot check.
|
|
||||||
# Example: a value of 60m means the check for a previous reboot will be at earliest
|
|
||||||
# performed 1 hour after the last reboot of the host.
|
|
||||||
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
|
||||||
# if no suffix is specified, then minutes are assumed.
|
|
||||||
# [default: 60m]
|
|
||||||
reboot_time="60m"
|
|
||||||
|
|
||||||
# trigger event when current uptime goes over the maximum threshold?
|
|
||||||
# [default: no]
|
|
||||||
check_old_age="no"
|
|
||||||
|
|
||||||
# time to expire before the current uptime is considered "old age".
|
|
||||||
# Example: a value of 365d means a must-reboot will be flagged at earliest after
|
|
||||||
# 1 year of uptime of the host
|
|
||||||
# Format: <value>m|h|d where m=minutes, h=hours, d=days (lowercase suffix).
|
|
||||||
# if no suffix is specified, then minutes are assumed.
|
|
||||||
# [default: 365d]
|
|
||||||
old_age_time="365d"
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -11,12 +11,6 @@
|
|||||||
# [default: no]
|
# [default: no]
|
||||||
log_healthy="no"
|
log_healthy="no"
|
||||||
|
|
||||||
# specify UBC names to exclude (comma-separated list) (release >20200411)
|
|
||||||
# [default: none]
|
|
||||||
# [release >2020410]
|
|
||||||
# Examples: numfile,numpty
|
|
||||||
exclude_counters=""
|
|
||||||
|
|
||||||
# specify containers for which to check the UBC
|
# specify containers for which to check the UBC
|
||||||
# Format:
|
# Format:
|
||||||
# [ct:<ct_id>]
|
# [ct:<ct_id>]
|
||||||
|
@ -11,18 +11,13 @@
|
|||||||
# [default: no]
|
# [default: no]
|
||||||
log_healthy="no"
|
log_healthy="no"
|
||||||
|
|
||||||
# specify properties as displayed by the following commands:
|
# specify properties as displayed by the 'vzlist -a -H -o ctid,status,onboot' command
|
||||||
# OpenVZ 6.x: 'vzlist -a -H -o ctid,status,onboot'
|
|
||||||
# OpenVZ 7.x: 'prlctl list --info -a' (release >20200411)
|
|
||||||
# Format:
|
# 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' (OpenVZ 6.x)
|
# boot_status should be 'yes' or 'no'
|
||||||
# boot_status should be 'on' of 'off' (OpenVZ 7.x)
|
# Examples:
|
||||||
# Examples (OpenVZ 6.x):
|
|
||||||
#ct:100:running:yes
|
#ct:100:running:yes
|
||||||
# Examples (OpenVZ 7.x) (release >20200411):
|
|
||||||
#ct:621240e6-fa79-406a-a3f9-26de47b5d789:running:on
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# @(#) check_serviceguard_package_status.conf
|
# @(#) check_linux_sg_package_status.conf
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# This is a configuration file for the check_serviceguard_package_status HC plugin.
|
# This is a configuration file for the check_linux_sg_package_status HC plugin.
|
||||||
# All lines starting with a '#' are comment lines.
|
# All lines starting with a '#' are comment lines.
|
||||||
# [default: indicates hardcoded script values if no value is defined here]
|
# [default: indicates hardcoded script values if no value is defined here]
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
@ -10,31 +10,6 @@
|
|||||||
# maximum timeout for HC calls/plugins (seconds) [default: 60]
|
# maximum timeout for HC calls/plugins (seconds) [default: 60]
|
||||||
HC_TIME_OUT=60
|
HC_TIME_OUT=60
|
||||||
|
|
||||||
# enable/disable logging of passed health checks (warning: this may rapidly grow the HC log)
|
|
||||||
# see also: '--log-healthy' command-line parameter
|
|
||||||
# 'log_healthy' setting in HC plugin configuration file(s)
|
|
||||||
# [values: Yes|No]
|
|
||||||
HC_LOG_HEALTHY="No"
|
|
||||||
|
|
||||||
# enable/disable healing logic if available in HC plugin(s)
|
|
||||||
# see also: '--no-fix' command-line parameter
|
|
||||||
# [values: Yes|No]
|
|
||||||
HC_WILL_FIX="Yes"
|
|
||||||
|
|
||||||
# cache "last" reporting entries. Set to 'Yes' to speed up reporting of the last
|
|
||||||
# registered HC events
|
|
||||||
# [values: Yes|No]
|
|
||||||
HC_REPORT_CACHE_LAST="No"
|
|
||||||
|
|
||||||
# cache "today" reporting entries. Set to 'Yes' to speed up reporting of today's
|
|
||||||
# registered HC events
|
|
||||||
# [values: Yes|No]
|
|
||||||
HC_REPORT_CACHE_TODAY="No"
|
|
||||||
|
|
||||||
# Show log entry count(s) after archiving. Disabling this will speed up archiving.
|
|
||||||
# [values: Yes|No]
|
|
||||||
HC_COUNT_ARCHIVES="Yes"
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# End of FILE
|
# End of FILE
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
#******************************************************************************
|
|
||||||
# @(#) notify_slack.conf
|
|
||||||
#******************************************************************************
|
|
||||||
# This is the the configuration file for the notify_slack.sh provider.
|
|
||||||
# All lines starting with a '#' are comment lines.
|
|
||||||
# [default: indicates hardcoded script values if no value is defined here]
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# URL of the webhook of the Slack app
|
|
||||||
SLACK_WEBHOOK=""
|
|
||||||
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# End of FILE
|
|
||||||
#******************************************************************************
|
|
@ -23,8 +23,8 @@
|
|||||||
# REQUIRES: ksh88/93 (mksh/pdksh will probably work too but YMMV)
|
# REQUIRES: ksh88/93 (mksh/pdksh will probably work too but YMMV)
|
||||||
# build_fpath(), check_config(), check_core(), check_lock_dir(),
|
# build_fpath(), check_config(), check_core(), check_lock_dir(),
|
||||||
# check_params(), check_platform(), check_user(), check_shell(),
|
# check_params(), check_platform(), check_user(), check_shell(),
|
||||||
# display_usage(), do_cleanup, fix_symlinks(), get_disable_comment(),
|
# display_usage(), do_cleanup, fix_symlinks(), read_config()
|
||||||
# read_config() + include functions
|
# + include functions
|
||||||
# For other pre-requisites see the documentation in display_usage()
|
# For other pre-requisites see the documentation in display_usage()
|
||||||
# REQUIRES (OPTIONAL): display_*(), notify_*(), report_*()
|
# REQUIRES (OPTIONAL): display_*(), notify_*(), report_*()
|
||||||
# EXISTS: 0=no errors encountered, >0=some errors encountered
|
# EXISTS: 0=no errors encountered, >0=some errors encountered
|
||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
# define the version (YYYY-MM-DD)
|
# define the version (YYYY-MM-DD)
|
||||||
typeset -r SCRIPT_VERSION="2021-03-31"
|
typeset -r SCRIPT_VERSION="2019-05-14"
|
||||||
# location of parent directory containing KSH functions/HC plugins
|
# location of parent directory containing KSH functions/HC plugins
|
||||||
typeset -r FPATH_PARENT="/opt/hc/lib"
|
typeset -r FPATH_PARENT="/opt/hc/lib"
|
||||||
# location of custom HC configuration files
|
# location of custom HC configuration files
|
||||||
@ -86,15 +86,14 @@ typeset EXIT_CODE=0
|
|||||||
typeset FDIR=""
|
typeset FDIR=""
|
||||||
typeset FFILE=""
|
typeset FFILE=""
|
||||||
typeset FPATH=""
|
typeset FPATH=""
|
||||||
|
typeset HC_ARCHIVE=""
|
||||||
typeset HC_CHECK=""
|
typeset HC_CHECK=""
|
||||||
typeset HC_COMMENT=""
|
|
||||||
typeset HC_DISABLE=""
|
typeset HC_DISABLE=""
|
||||||
typeset HC_ENABLE=""
|
typeset HC_ENABLE=""
|
||||||
typeset HC_RUN=""
|
typeset HC_RUN=""
|
||||||
typeset HC_FAIL_ID=""
|
typeset HC_FAIL_ID=""
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
typeset HC_FILE_LINE=""
|
typeset HC_FILE_LINE=""
|
||||||
typeset HC_LOG_HEALTHY=""
|
|
||||||
typeset HC_NOW=""
|
typeset HC_NOW=""
|
||||||
typeset HC_TIME_OUT=60
|
typeset HC_TIME_OUT=60
|
||||||
typeset HC_MIN_TIME_OUT=30
|
typeset HC_MIN_TIME_OUT=30
|
||||||
@ -102,20 +101,10 @@ typeset HC_MIN_TIME_OUT=30
|
|||||||
typeset HC_MSG_VAR=""
|
typeset HC_MSG_VAR=""
|
||||||
typeset HC_STDOUT_LOG=""
|
typeset HC_STDOUT_LOG=""
|
||||||
typeset HC_STDERR_LOG=""
|
typeset HC_STDERR_LOG=""
|
||||||
set -A HC_STDOUT_LOG_ARRAY
|
|
||||||
set -A HC_STDERR_LOG_ARRAY
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
typeset HC_COUNT_ARCHVES=""
|
|
||||||
typeset HC_WILL_FIX=""
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
typeset HC_REPORT_CACHE_LAST=""
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
typeset HC_REPORT_CACHE_TODAY=""
|
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
typeset LINUX_DISTRO=""
|
typeset LINUX_DISTRO=""
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
typeset LINUX_RELEASE=""
|
typeset LINUX_RELEASE=""
|
||||||
typeset PREVIOUS_HC_TIME_OUT=""
|
|
||||||
typeset ARCHIVE_RC=0
|
typeset ARCHIVE_RC=0
|
||||||
typeset DISABLE_RC=0
|
typeset DISABLE_RC=0
|
||||||
typeset ENABLE_RC=0
|
typeset ENABLE_RC=0
|
||||||
@ -131,7 +120,6 @@ typeset DEBUG_OPTS=""
|
|||||||
# command-line parameters
|
# command-line parameters
|
||||||
typeset ARG_ACTION=0 # HC action flag
|
typeset ARG_ACTION=0 # HC action flag
|
||||||
typeset ARG_CHECK_HOST=0 # host check is off by default
|
typeset ARG_CHECK_HOST=0 # host check is off by default
|
||||||
typeset ARG_COMMENT=""
|
|
||||||
typeset ARG_CONFIG_FILE="" # custom configuration file for a HC, none by default
|
typeset ARG_CONFIG_FILE="" # custom configuration file for a HC, none by default
|
||||||
typeset ARG_DEBUG=0 # debug is off by default
|
typeset ARG_DEBUG=0 # debug is off by default
|
||||||
typeset ARG_DEBUG_LEVEL=0 # debug() only by default
|
typeset ARG_DEBUG_LEVEL=0 # debug() only by default
|
||||||
@ -144,10 +132,8 @@ typeset ARG_HC_ARGS="" # no extra arguments to HC plug-in by default
|
|||||||
typeset ARG_HISTORY=0 # include historical events is off by default
|
typeset ARG_HISTORY=0 # include historical events is off by default
|
||||||
typeset ARG_LAST=0 # report last events
|
typeset ARG_LAST=0 # report last events
|
||||||
typeset ARG_LIST="" # list all by default
|
typeset ARG_LIST="" # list all by default
|
||||||
typeset ARG_LIST_DETAILS=0 # list with full details is off by default
|
|
||||||
typeset ARG_LOCK=1 # lock for concurrent script executions is on by default
|
typeset ARG_LOCK=1 # lock for concurrent script executions is on by default
|
||||||
typeset ARG_LOG=1 # logging is on by default
|
typeset ARG_LOG=1 # logging is on by default
|
||||||
typeset ARG_NO_FIX=0 # fix/healing is not disabled by default
|
|
||||||
typeset ARG_LOG_HEALTHY=0 # logging of healthy health checks is off by default
|
typeset ARG_LOG_HEALTHY=0 # logging of healthy health checks is off by default
|
||||||
typeset ARG_MONITOR=1 # killing long running HC processes is on by default
|
typeset ARG_MONITOR=1 # killing long running HC processes is on by default
|
||||||
typeset ARG_NEWER=""
|
typeset ARG_NEWER=""
|
||||||
@ -257,47 +243,20 @@ then
|
|||||||
print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_core(.sh) is not present (tip: run --fix-symlinks)"
|
print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_core(.sh) is not present (tip: run --fix-symlinks)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# PDKSH hack (IS_PDKSH is not yet set here)
|
|
||||||
case "${KSH_VERSION}" in
|
|
||||||
*MIRBSD*|*PD*|*LEGACY*)
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
. ${FPATH_PARENT}/core/include_core.sh
|
|
||||||
if [[ -r ${FPATH_PARENT}/core/include_data.sh && -h ${FPATH_PARENT}/core/include_data ]]
|
|
||||||
then
|
|
||||||
(( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${FPATH_PARENT}/core/include_data.sh"
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
. ${FPATH_PARENT}/core/include_data.sh
|
|
||||||
else
|
|
||||||
print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_data.sh is not present (tip: run --fix-symlinks)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ -r ${FPATH_PARENT}/core/include_os.sh && -h ${FPATH_PARENT}/core/include_os ]]
|
|
||||||
then
|
|
||||||
(( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${FPATH_PARENT}/core/include_os.sh"
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
. ${FPATH_PARENT}/core/include_os.sh
|
|
||||||
else
|
|
||||||
print -u2 "ERROR: library file ${FPATH_PARENT}/core/include_os.sh is not present (tip: run --fix-symlinks)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# include include_*
|
# include include_*
|
||||||
find ${FPATH_PARENT}/core -name "include_*.sh" -type f -print 2>/dev/null | while read -r INCLUDE_FILE
|
find ${FPATH_PARENT}/core -name "include_*.sh" -type f -print 2>/dev/null | while read INCLUDE_FILE
|
||||||
do
|
do
|
||||||
if [[ -h ${INCLUDE_FILE%%.sh} ]]
|
if [[ -h ${INCLUDE_FILE%%.sh} ]]
|
||||||
then
|
then
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
(( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${INCLUDE_FILE}"
|
(( ARG_DEBUG > 0 )) && print -u2 "DEBUG: including ${INCLUDE_FILE}"
|
||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
. "${INCLUDE_FILE}"
|
. ${INCLUDE_FILE}
|
||||||
else
|
else
|
||||||
print -u2 "ERROR: library file ${INCLUDE_FILE} exists but has no symlink. Run --fix-symlinks"
|
print -u2 "ERROR: library file ${INCLUDE_FILE} exists but has no symlink. Run --fix-symlinks"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
esac
|
|
||||||
|
|
||||||
# check for core directories
|
# check for core directories
|
||||||
[[ -d ${ARCHIVE_DIR} ]] || mkdir -p "${ARCHIVE_DIR}" >/dev/null 2>&1
|
[[ -d ${ARCHIVE_DIR} ]] || mkdir -p "${ARCHIVE_DIR}" >/dev/null 2>&1
|
||||||
@ -340,19 +299,18 @@ function check_lock_dir
|
|||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
if (( ARG_LOCK > 0 ))
|
if (( ARG_LOCK > 0 ))
|
||||||
then
|
then
|
||||||
mkdir "${LOCK_DIR}" >/dev/null 2>/dev/null || {
|
mkdir ${LOCK_DIR} >/dev/null || {
|
||||||
print -u2 "ERROR: unable to acquire lock ${LOCK_DIR}"
|
print -u2 "ERROR: unable to acquire lock ${LOCK_DIR}"
|
||||||
ARG_VERBOSE=0 warn "unable to acquire lock ${LOCK_DIR}"
|
ARG_VERBOSE=0 warn "unable to acquire lock ${LOCK_DIR}"
|
||||||
if [[ -f ${LOCK_DIR}/.pid ]]
|
if [[ -f ${LOCK_DIR}/.pid ]]
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC2086
|
typeset LOCK_PID="$(<${LOCK_DIR}/.pid)"
|
||||||
typeset LOCK_PID=$(<"${LOCK_DIR}/.pid")
|
|
||||||
print -u2 "ERROR: active health checker running on PID: ${LOCK_PID}"
|
print -u2 "ERROR: active health checker running on PID: ${LOCK_PID}"
|
||||||
ARG_VERBOSE=0 warn "active health checker running on PID: ${LOCK_PID}. Exiting!"
|
ARG_VERBOSE=0 warn "active health checker running on PID: ${LOCK_PID}. Exiting!"
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
print $$ > "${LOCK_DIR}/.pid"
|
print $$ >${LOCK_DIR}/.pid
|
||||||
else
|
else
|
||||||
(( ARG_DEBUG > 0 )) && print "DEBUG: locking has been disabled"
|
(( ARG_DEBUG > 0 )) && print "DEBUG: locking has been disabled"
|
||||||
fi
|
fi
|
||||||
@ -476,15 +434,12 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# --comment
|
# --log-healthy
|
||||||
if [[ -n "${ARG_COMMENT}" ]]
|
if (( ARG_LOG_HEALTHY > 0 && ARG_ACTION != 4 ))
|
||||||
then
|
then
|
||||||
if (( ARG_ACTION != 2 )) && (( ARG_ACTION != 6 ))
|
print -u2 "ERROR: you can only use '--log-healthy' in combination with '--run'"
|
||||||
then
|
|
||||||
print -u2 "ERROR: you can only use '--comment' in combination with '--disable' or '--disable-all'"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
# check log location
|
# check log location
|
||||||
if (( ARG_LOG > 0 ))
|
if (( ARG_LOG > 0 ))
|
||||||
then
|
then
|
||||||
@ -586,9 +541,9 @@ cat << EOT
|
|||||||
Execute/report simple health checks (HC) on UNIX hosts.
|
Execute/report simple health checks (HC) on UNIX hosts.
|
||||||
|
|
||||||
Syntax: ${SCRIPT_DIR}/${SCRIPT_NAME} [--help] | [--help-terse] | [--version] |
|
Syntax: ${SCRIPT_DIR}/${SCRIPT_NAME} [--help] | [--help-terse] | [--version] |
|
||||||
[--list=<needle>] | [--list-details] | [--list-core] | [--list-include] | [--fix-symlinks] | [--show-stats] | (--archive-all | --disable-all [--comment=<text>] | --enable-all) | [--fix-logs [--with-history]] |
|
[--list=<needle>] | [--list-core] | [--list-include] | [--fix-symlinks] | [--show-stats] | (--archive-all | --disable-all | --enable-all) | [--fix-logs [--with-history]] |
|
||||||
(--check-host | ((--archive | --check | --enable | --disable [--comment=<text>] | --run [--timeout=<secs>] | --show) --hc=<list_of_checks> [--config-file=<configuration_file>] [hc-args="<arg1,arg2=val,arg3">]))
|
(--check-host | ((--archive | --check | --enable | --disable | --run [--timeout=<secs>] | --show) --hc=<list_of_checks> [--config-file=<configuration_file>] [hc-args="<arg1,arg2=val,arg3">]))
|
||||||
[--display=<method>] ([--debug] [--debug-level=<level>]) [--log-healthy] [--no-fix] [--no-log] [--no-lock] [--no-monitor] [[--flip-rc] [--with-rc=<count|max|sum>]]]
|
[--display=<method>] ([--debug] [--debug-level=<level>]) [--log-healthy] [--no-monitor] [--no-log] [--no-lock] [[--flip-rc] [--with-rc=<count|max|sum>]]]
|
||||||
[--notify=<method_list>] [--mail-to=<address_list>] [--sms-to=<sms_rcpt> --sms-provider=<name>]
|
[--notify=<method_list>] [--mail-to=<address_list>] [--sms-to=<sms_rcpt> --sms-provider=<name>]
|
||||||
[--report=<method> [--with-history] ( ([--last] | [--today]) | [(--older|--newer)=<date>] | [--reverse] [--id=<fail_id> [--detail]] )]
|
[--report=<method> [--with-history] ( ([--last] | [--today]) | [(--older|--newer)=<date>] | [--reverse] [--id=<fail_id> [--detail]] )]
|
||||||
|
|
||||||
@ -603,7 +558,6 @@ Parameters:
|
|||||||
--archive-all : move events for all HCs from the HC log file into archive log files
|
--archive-all : move events for all HCs from the HC log file into archive log files
|
||||||
--check : display HC state.
|
--check : display HC state.
|
||||||
--check-host : execute all configured HC(s) (see check_host.conf)
|
--check-host : execute all configured HC(s) (see check_host.conf)
|
||||||
--comment : add comment to requested action (--disable). WARNING: comments may not contain spaces!
|
|
||||||
--config-file : custom configuration file for a HC (may only be specified when executing a single HC plugin)
|
--config-file : custom configuration file for a HC (may only be specified when executing a single HC plugin)
|
||||||
--debug : run script in debug mode
|
--debug : run script in debug mode
|
||||||
--debug-level : level of debugging information to show (0,1,2)
|
--debug-level : level of debugging information to show (0,1,2)
|
||||||
@ -622,23 +576,18 @@ Parameters:
|
|||||||
in double quotes (example: --hc_args="arg1,arg2=value,arg3").
|
in double quotes (example: --hc_args="arg1,arg2=value,arg3").
|
||||||
--id : value of a FAIL ID (must be specified as uninterrupted sequence of numbers)
|
--id : value of a FAIL ID (must be specified as uninterrupted sequence of numbers)
|
||||||
--last : show the last (failed) events for each HC and their combined STC value
|
--last : show the last (failed) events for each HC and their combined STC value
|
||||||
--list : show the available health checks in a terse manner. Use --list-details for a more extensive list.
|
--list : show the available health checks. Use <needle> to search with wildcards. Following details are shown:
|
||||||
--list-details : show the available health checks with following details included:
|
|
||||||
- health check (plugin) name
|
- health check (plugin) name
|
||||||
- state of the HC plugin (disabled/enabled)
|
- state of the HC plugin (disabled/enabled)
|
||||||
- version of the HC plugin
|
- version of the HC plugin
|
||||||
- whether the HC plugin requires a configuration file in ${CONFIG_DIR}
|
- whether the HC plugin requires a configuration file in ${CONFIG_DIR}
|
||||||
- whether the HC plugin is scheduled by cron
|
- whether the HC plugin is scheduled by cron
|
||||||
- whether the plugin contains a facility for --log-healthy and/or whether it is enabled
|
|
||||||
- whether the plugin contains fix/healing logic (see --no-fix)
|
|
||||||
--list-core : show the available core plugins (mail,SMS,...)
|
--list-core : show the available core plugins (mail,SMS,...)
|
||||||
--list-include : show the available includes/libraries
|
--list-include : show the available includes/libraries
|
||||||
--log-healthy : log/show also passed health checks. By default this is off when the plugin support this feature.
|
--log-healthy : log/show also passed health checks. By default this is off when the plugin support this feature.
|
||||||
(overrides \$HC_LOG_HEALTHY and can itself be overridden by --no-log to disable all logging)
|
(can be overridden by --no-log to disable all logging)
|
||||||
--mail-to : list of e-mail address(es) to which an e-mail alert will be send to [requires mail core plugin]
|
--mail-to : list of e-mail address(es) to which an e-mail alert will be send to [requires mail core plugin]
|
||||||
--newer : show the (failed) events for each HC that are newer than the given date
|
--newer : show the (failed) events for each HC that are newer than the given date
|
||||||
--no-fix : do not apply fix/healing logic for failed health checks (if available)
|
|
||||||
(overrides \$HC_WILL_FIX)
|
|
||||||
--no-lock : disable locking to allow concurrent script executions
|
--no-lock : disable locking to allow concurrent script executions
|
||||||
--no-log : do not log any messages to the script log file or health check results.
|
--no-log : do not log any messages to the script log file or health check results.
|
||||||
--no-monitor : do not stop the execution of a HC after \$HC_TIME_OUT seconds
|
--no-monitor : do not stop the execution of a HC after \$HC_TIME_OUT seconds
|
||||||
@ -652,7 +601,7 @@ Parameters:
|
|||||||
--sms-provider : name of a supported SMS provider (see \$SMS_PROVIDERS) [requires SMS core plugin]
|
--sms-provider : name of a supported SMS provider (see \$SMS_PROVIDERS) [requires SMS core plugin]
|
||||||
--sms-to : name of person or group to which a sms alert will be send to [requires SMS core plugin]
|
--sms-to : name of person or group to which a sms alert will be send to [requires SMS core plugin]
|
||||||
--timeout : maximum runtime of a HC plugin in seconds (overrides \$HC_TIME_OUT)
|
--timeout : maximum runtime of a HC plugin in seconds (overrides \$HC_TIME_OUT)
|
||||||
--today : show (failed) events of today (HC and their combined STC value)
|
--today : show today's (failed) events (HC and their combined STC value)
|
||||||
--version : show the timestamp of the script.
|
--version : show the timestamp of the script.
|
||||||
--with-history : also include events that have been archived already (reporting)
|
--with-history : also include events that have been archived already (reporting)
|
||||||
--with-rc : define RC handling (plugin) when --flip-rc is used
|
--with-rc : define RC handling (plugin) when --flip-rc is used
|
||||||
@ -675,28 +624,16 @@ function do_cleanup
|
|||||||
log "performing cleanup ..."
|
log "performing cleanup ..."
|
||||||
|
|
||||||
# remove temporary files
|
# remove temporary files
|
||||||
[[ -f "${HC_MSG_FILE}" ]] && rm -f "${HC_MSG_FILE}" >/dev/null 2>&1
|
[[ -f "${HC_MSG_FILE}" ]] && rm -f ${HC_MSG_FILE} >/dev/null 2>&1
|
||||||
|
|
||||||
# remove left over plugin log files (pop from array stacks)
|
# remove trailing log files
|
||||||
FILE_COUNT=1
|
[[ -f "${HC_STDOUT_LOG}" ]] && rm -f ${HC_STDOUT_LOG} >/dev/null 2>&1
|
||||||
while (( FILE_COUNT <= ${#HC_STDOUT_LOG_ARRAY[*]} ))
|
[[ -f "${HC_STDERR_LOG}" ]] && rm -f ${HC_STDERR_LOG} >/dev/null 2>&1
|
||||||
do
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "cleaning up plugin log file ${HC_STDOUT_LOG_ARRAY[FILE_COUNT]}"
|
|
||||||
[[ -f "${HC_STDOUT_LOG_ARRAY[FILE_COUNT]}" ]] && rm -f "${HC_STDOUT_LOG_ARRAY[FILE_COUNT]}" >/dev/null 2>&1
|
|
||||||
FILE_COUNT=$(( FILE_COUNT + 1 ))
|
|
||||||
done
|
|
||||||
FILE_COUNT=1
|
|
||||||
while (( FILE_COUNT <= ${#HC_STDERR_LOG_ARRAY[*]} ))
|
|
||||||
do
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "cleaning up plugin log file ${HC_STDERR_LOG_ARRAY[FILE_COUNT]}"
|
|
||||||
[[ -f "${HC_STDERR_LOG_ARRAY[FILE_COUNT]}" ]] && rm -f "${HC_STDERR_LOG_ARRAY[FILE_COUNT]}" >/dev/null 2>&1
|
|
||||||
FILE_COUNT=$(( FILE_COUNT + 1 ))
|
|
||||||
done
|
|
||||||
|
|
||||||
# remove lock directory
|
# remove lock directory
|
||||||
if [[ -d ${LOCK_DIR} ]]
|
if [[ -d ${LOCK_DIR} ]]
|
||||||
then
|
then
|
||||||
rm -rf "${LOCK_DIR}" >/dev/null 2>&1
|
rm -rf ${LOCK_DIR} >/dev/null 2>&1
|
||||||
log "${LOCK_DIR} lock directory removed"
|
log "${LOCK_DIR} lock directory removed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -721,7 +658,6 @@ typeset FSYML=""
|
|||||||
# find missing symlinks (do not skip core plug-ins here)
|
# find missing symlinks (do not skip core plug-ins here)
|
||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# shellcheck disable=SC2086
|
|
||||||
find ${FDIR} -type f -print 2>/dev/null | while read -r FFILE
|
find ${FDIR} -type f -print 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
FSYML="${FFILE%.sh}"
|
FSYML="${FFILE%.sh}"
|
||||||
@ -740,7 +676,7 @@ done
|
|||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# do not use 'find -type l' here!
|
# do not use 'find -type l' here!
|
||||||
# shellcheck disable=SC2010,SC2086
|
# shellcheck disable=SC2010
|
||||||
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FSYML
|
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FSYML
|
||||||
do
|
do
|
||||||
# check if file is a dead symlink
|
# check if file is a dead symlink
|
||||||
@ -778,24 +714,6 @@ else
|
|||||||
. "${CONFIG_FILE}"
|
. "${CONFIG_FILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# reconcile global settings w/ cmd-line parameters
|
|
||||||
if (( ARG_LOG_HEALTHY == 0 ))
|
|
||||||
then
|
|
||||||
case "${HC_LOG_HEALTHY}" in
|
|
||||||
yes|YES|Yes)
|
|
||||||
ARG_LOG_HEALTHY=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
if (( ARG_NO_FIX == 0 ))
|
|
||||||
then
|
|
||||||
case "${HC_WILL_FIX}" in
|
|
||||||
no|NO|No)
|
|
||||||
ARG_NO_FIX=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -843,12 +761,6 @@ do
|
|||||||
fi
|
fi
|
||||||
ARG_CHECK_HOST=1
|
ARG_CHECK_HOST=1
|
||||||
;;
|
;;
|
||||||
-comment=*)
|
|
||||||
ARG_COMMENT="${CMD_PARAMETER#-comment=}"
|
|
||||||
;;
|
|
||||||
--comment=*)
|
|
||||||
ARG_COMMENT="${CMD_PARAMETER#--comment=}"
|
|
||||||
;;
|
|
||||||
-config-file=*)
|
-config-file=*)
|
||||||
ARG_CONFIG_FILE="${CMD_PARAMETER#-config-file=}"
|
ARG_CONFIG_FILE="${CMD_PARAMETER#-config-file=}"
|
||||||
;;
|
;;
|
||||||
@ -992,11 +904,6 @@ do
|
|||||||
ARG_ACTION=9
|
ARG_ACTION=9
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
-list-details|--list-details)
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
ARG_LIST_DETAILS=1
|
|
||||||
ARG_ACTION=9
|
|
||||||
;;
|
|
||||||
-list-hc|--list-hc|-list-all|--list-all)
|
-list-hc|--list-hc|-list-all|--list-all)
|
||||||
print -u2 "WARN: deprecated option. Use --list | --list=<needle>"
|
print -u2 "WARN: deprecated option. Use --list | --list=<needle>"
|
||||||
exit 0
|
exit 0
|
||||||
@ -1045,13 +952,8 @@ do
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
ARG_NOTIFY="${CMD_PARAMETER#--notify=}"
|
ARG_NOTIFY="${CMD_PARAMETER#--notify=}"
|
||||||
;;
|
;;
|
||||||
-no-fix|--no-fix)
|
|
||||||
ARG_NO_FIX=1
|
|
||||||
;;
|
|
||||||
-no-log|--no-log)
|
-no-log|--no-log)
|
||||||
ARG_LOG=0
|
ARG_LOG=0
|
||||||
# --no-log always means --no-fix!
|
|
||||||
ARG_NO_FIX=1
|
|
||||||
;;
|
;;
|
||||||
-no-lock|--no-lock)
|
-no-lock|--no-lock)
|
||||||
ARG_LOCK=0
|
ARG_LOCK=0
|
||||||
@ -1249,13 +1151,7 @@ case ${ARG_ACTION} in
|
|||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if (( $? == 0 ))
|
if (( $? == 0 ))
|
||||||
then
|
then
|
||||||
HC_COMMENT=$(get_disable_comment "${HC_CHECK}")
|
|
||||||
if [[ -n "${HC_COMMENT}" ]]
|
|
||||||
then
|
|
||||||
log "HC ${HC_CHECK} is currently disabled (${HC_COMMENT})"
|
|
||||||
else
|
|
||||||
log "HC ${HC_CHECK} is currently disabled"
|
log "HC ${HC_CHECK} is currently disabled"
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
log "HC ${HC_CHECK} is currently enabled"
|
log "HC ${HC_CHECK} is currently enabled"
|
||||||
fi
|
fi
|
||||||
@ -1277,11 +1173,6 @@ case ${ARG_ACTION} in
|
|||||||
exists_hc "${HC_DISABLE}" && die "cannot find HC: ${HC_DISABLE}"
|
exists_hc "${HC_DISABLE}" && die "cannot find HC: ${HC_DISABLE}"
|
||||||
log "disabling HC: ${HC_DISABLE}"
|
log "disabling HC: ${HC_DISABLE}"
|
||||||
touch "${STATE_PERM_DIR}/${HC_DISABLE}.disabled" >/dev/null 2>&1
|
touch "${STATE_PERM_DIR}/${HC_DISABLE}.disabled" >/dev/null 2>&1
|
||||||
# write comment if supplied
|
|
||||||
if [[ -n "${ARG_COMMENT}" ]]
|
|
||||||
then
|
|
||||||
print "${ARG_COMMENT}" >"${STATE_PERM_DIR}/${HC_DISABLE}.disabled"
|
|
||||||
fi
|
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if (( $? == 0 ))
|
if (( $? == 0 ))
|
||||||
then
|
then
|
||||||
@ -1329,7 +1220,7 @@ case ${ARG_ACTION} in
|
|||||||
# re-initialize messages stash (log of failed checks)
|
# re-initialize messages stash (log of failed checks)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
HC_MSG_VAR=""
|
HC_MSG_VAR=""
|
||||||
: > "${HC_MSG_FILE}" 2>/dev/null
|
: >${HC_MSG_FILE} 2>/dev/null
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if (( $? > 0 ))
|
if (( $? > 0 ))
|
||||||
then
|
then
|
||||||
@ -1367,16 +1258,13 @@ case ${ARG_ACTION} in
|
|||||||
# set & initialize STDOUT/STDERR locations (not in init_hc()!)
|
# set & initialize STDOUT/STDERR locations (not in init_hc()!)
|
||||||
HC_STDOUT_LOG="${TMP_DIR}/${HC_RUN}.stdout.log.$$"
|
HC_STDOUT_LOG="${TMP_DIR}/${HC_RUN}.stdout.log.$$"
|
||||||
HC_STDERR_LOG="${TMP_DIR}/${HC_RUN}.stderr.log.$$"
|
HC_STDERR_LOG="${TMP_DIR}/${HC_RUN}.stderr.log.$$"
|
||||||
# push plugin log files to array stacks (index starts at 1!)
|
: >${HC_STDOUT_LOG} 2>/dev/null
|
||||||
HC_STDOUT_LOG_ARRAY[${#HC_STDOUT_LOG_ARRAY[*]}+1]="${HC_STDOUT_LOG}"
|
|
||||||
HC_STDERR_LOG_ARRAY[${#HC_STDERR_LOG_ARRAY[*]}+1]="${HC_STDERR_LOG}"
|
|
||||||
: > "${HC_STDOUT_LOG}" 2>/dev/null
|
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if (( $? > 0 ))
|
if (( $? > 0 ))
|
||||||
then
|
then
|
||||||
die "unable to reset the \${HC_STDOUT_LOG} file"
|
die "unable to reset the \${HC_STDOUT_LOG} file"
|
||||||
fi
|
fi
|
||||||
: > "${HC_STDERR_LOG}" 2>/dev/null
|
: >${HC_STDERR_LOG} 2>/dev/null
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if (( $? > 0 ))
|
if (( $? > 0 ))
|
||||||
then
|
then
|
||||||
@ -1386,7 +1274,6 @@ case ${ARG_ACTION} in
|
|||||||
# --check-host handling: alternative configuration file, mangle ARG_CONFIG_FILE & HC_TIME_OUT
|
# --check-host handling: alternative configuration file, mangle ARG_CONFIG_FILE & HC_TIME_OUT
|
||||||
if (( ARG_CHECK_HOST == 1 ))
|
if (( ARG_CHECK_HOST == 1 ))
|
||||||
then
|
then
|
||||||
PREVIOUS_HC_TIME_OUT=${HC_TIME_OUT}
|
|
||||||
ARG_CONFIG_FILE="" # reset from previous call
|
ARG_CONFIG_FILE="" # reset from previous call
|
||||||
RUN_CONFIG_FILE=$(grep -i -E -e "^hc:${HC_RUN}:" ${HOST_CONFIG_FILE} 2>/dev/null | cut -f3 -d':')
|
RUN_CONFIG_FILE=$(grep -i -E -e "^hc:${HC_RUN}:" ${HOST_CONFIG_FILE} 2>/dev/null | cut -f3 -d':')
|
||||||
[[ -n "${RUN_CONFIG_FILE}" ]] && ARG_CONFIG_FILE="${CONFIG_DIR}/${RUN_CONFIG_FILE}"
|
[[ -n "${RUN_CONFIG_FILE}" ]] && ARG_CONFIG_FILE="${CONFIG_DIR}/${RUN_CONFIG_FILE}"
|
||||||
@ -1396,14 +1283,13 @@ case ${ARG_ACTION} in
|
|||||||
(( RUN_TIME_OUT > HC_TIME_OUT )) && HC_TIME_OUT=${RUN_TIME_OUT}
|
(( RUN_TIME_OUT > HC_TIME_OUT )) && HC_TIME_OUT=${RUN_TIME_OUT}
|
||||||
else
|
else
|
||||||
# reset for next HC
|
# reset for next HC
|
||||||
HC_TIME_OUT=${PREVIOUS_HC_TIME_OUT}
|
HC_TIME_OUT=60
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# run HC with or without monitor
|
# run HC with or without monitor
|
||||||
if (( ARG_MONITOR == 0 ))
|
if (( ARG_MONITOR == 0 ))
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC2086
|
|
||||||
${HC_RUN} ${ARG_HC_ARGS}
|
${HC_RUN} ${ARG_HC_ARGS}
|
||||||
RUN_RC=$?
|
RUN_RC=$?
|
||||||
EXIT_CODE=${RUN_RC}
|
EXIT_CODE=${RUN_RC}
|
||||||
@ -1442,7 +1328,6 @@ case ${ARG_ACTION} in
|
|||||||
# SLEEP_PID is the PID of the sleep subshell itself
|
# SLEEP_PID is the PID of the sleep subshell itself
|
||||||
SLEEP_PID=$!
|
SLEEP_PID=$!
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
${HC_RUN} ${ARG_HC_ARGS} &
|
${HC_RUN} ${ARG_HC_ARGS} &
|
||||||
CHILD_PID=$!
|
CHILD_PID=$!
|
||||||
log "spawning child process with time-out of ${HC_TIME_OUT} secs for HC call [PID=${CHILD_PID}]"
|
log "spawning child process with time-out of ${HC_TIME_OUT} secs for HC call [PID=${CHILD_PID}]"
|
||||||
@ -1493,7 +1378,7 @@ case ${ARG_ACTION} in
|
|||||||
handle_hc "${HC_RUN}"
|
handle_hc "${HC_RUN}"
|
||||||
# exit with return code from handle_hc() (see --flip-rc)
|
# exit with return code from handle_hc() (see --flip-rc)
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
rm -f "${HC_MSG_FILE}" >/dev/null 2>&1
|
rm -f ${HC_MSG_FILE} >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
5) # show info on HC (single)
|
5) # show info on HC (single)
|
||||||
@ -1513,11 +1398,6 @@ case ${ARG_ACTION} in
|
|||||||
exists_hc "${HC_DISABLE}" && die "cannot find HC: ${HC_DISABLE}"
|
exists_hc "${HC_DISABLE}" && die "cannot find HC: ${HC_DISABLE}"
|
||||||
log "disabling HC: ${HC_DISABLE}"
|
log "disabling HC: ${HC_DISABLE}"
|
||||||
touch "${STATE_PERM_DIR}/${HC_DISABLE}.disabled" >/dev/null 2>&1
|
touch "${STATE_PERM_DIR}/${HC_DISABLE}.disabled" >/dev/null 2>&1
|
||||||
# write comment if supplied
|
|
||||||
if [[ -n "${ARG_COMMENT}" ]]
|
|
||||||
then
|
|
||||||
print "${ARG_COMMENT}" >"${STATE_PERM_DIR}/${HC_DISABLE}.disabled"
|
|
||||||
fi
|
|
||||||
DISABLE_RC=$?
|
DISABLE_RC=$?
|
||||||
if (( DISABLE_RC == 0 ))
|
if (( DISABLE_RC == 0 ))
|
||||||
then
|
then
|
||||||
@ -1592,7 +1472,26 @@ case ${ARG_ACTION} in
|
|||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
13) # archive current log entries for all HCs
|
13) # archive current log entries for all HCs
|
||||||
archive_hc_all
|
list_hc "list" | while read -r HC_ARCHIVE
|
||||||
|
do
|
||||||
|
# check for HC (function)
|
||||||
|
exists_hc "${HC_ARCHIVE}" && die "cannot find HC: ${HC_ARCHIVE}"
|
||||||
|
log "archiving current log entries for HC: ${HC_ARCHIVE}"
|
||||||
|
archive_hc "${HC_ARCHIVE}"
|
||||||
|
ARCHIVE_RC=$?
|
||||||
|
case ${ARCHIVE_RC} in
|
||||||
|
0)
|
||||||
|
log "no archiving needed for ${HC_ARCHIVE}"
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
log "successfully archived log entries for ${HC_ARCHIVE}"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
log "failed to archive log entries for ${HC_ARCHIVE} [RC=${ARCHIVE_RC}]"
|
||||||
|
EXIT_CODE=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
function display_init
|
function display_init
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _VERSION="2020-10-10" # YYYY-MM-DD
|
typeset _VERSION="2019-03-22" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ fi
|
|||||||
|
|
||||||
# print status line (but also check for terminal support)
|
# print status line (but also check for terminal support)
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
printf "%-45s %50s\t[ %8s ]%s\n" \
|
printf "%-30s %50s\t[ %8s ]%s\n" \
|
||||||
"${_DISPLAY_HC}" \
|
"${_DISPLAY_HC}" \
|
||||||
"(${_DISPLAY_CFG})" \
|
"(${_DISPLAY_CFG})" \
|
||||||
"${_DISPLAY_COLOR}${_DISPLAY_CODE}${_NORMAL}" \
|
"${_DISPLAY_COLOR}${_DISPLAY_CODE}${_NORMAL}" \
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
# RETURNS: 0
|
# RETURNS: 0
|
||||||
function version_include_core
|
function version_include_core
|
||||||
{
|
{
|
||||||
typeset _VERSION="2022-10-14" # YYYY-MM-DD
|
typeset _VERSION="2019-04-03" # YYYY-MM-DD
|
||||||
|
|
||||||
print "INFO: $0: ${_VERSION#version_*}"
|
print "INFO: $0: ${_VERSION#version_*}"
|
||||||
|
|
||||||
@ -50,7 +50,6 @@ typeset HC_NAME="${1}"
|
|||||||
typeset ARCHIVE_FILE=""
|
typeset ARCHIVE_FILE=""
|
||||||
typeset ARCHIVE_RC=0
|
typeset ARCHIVE_RC=0
|
||||||
typeset YEAR_MONTH=""
|
typeset YEAR_MONTH=""
|
||||||
typeset COUNT_STATS=1
|
|
||||||
typeset LOG_COUNT=0
|
typeset LOG_COUNT=0
|
||||||
typeset PRE_LOG_COUNT=0
|
typeset PRE_LOG_COUNT=0
|
||||||
typeset TODO_LOG_COUNT=0
|
typeset TODO_LOG_COUNT=0
|
||||||
@ -63,137 +62,65 @@ typeset TMP2_FILE="${TMP_DIR}/.$0.tmp2.archive.$$"
|
|||||||
# shellcheck disable=SC2064
|
# shellcheck disable=SC2064
|
||||||
trap "rm -f ${TMP1_FILE} ${TMP2_FILE} ${SAVE_LOG_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
|
trap "rm -f ${TMP1_FILE} ${TMP2_FILE} ${SAVE_LOG_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
|
||||||
|
|
||||||
# get pre-archive log count
|
# get pre-archive log co
|
||||||
PRE_LOG_COUNT=$(wc -l "${HC_LOG}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
PRE_LOG_COUNT=$(wc -l ${HC_LOG} 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
||||||
if (( PRE_LOG_COUNT == 0 ))
|
if (( PRE_LOG_COUNT == 0 ))
|
||||||
then
|
then
|
||||||
warn "${HC_LOG} is empty, nothing to archive"
|
warn "${HC_LOG} is empty, nothing to archive"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check log count toggle (only affects $LOG_COUNT)
|
|
||||||
case "${HC_COUNT_ARCHIVES}" in
|
|
||||||
No|no|NO)
|
|
||||||
COUNT_STATS=0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
: # default is to do additional stats
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# isolate messages from HC, find unique %Y-%m combinations
|
# isolate messages from HC, find unique %Y-%m combinations
|
||||||
grep ".*${LOG_SEP}${HC_NAME}${LOG_SEP}" "${HC_LOG}" 2>/dev/null |\
|
grep ".*${LOG_SEP}${HC_NAME}${LOG_SEP}" ${HC_LOG} 2>/dev/null |\
|
||||||
cut -f1 -d"${LOG_SEP}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null |\
|
cut -f1 -d"${LOG_SEP}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null |\
|
||||||
cut -f1-2 -d'-' 2>/dev/null | sort -u 2>/dev/null |\
|
cut -f1-2 -d'-' 2>/dev/null | sort -u 2>/dev/null |\
|
||||||
while read -r YEAR_MONTH
|
while read -r YEAR_MONTH
|
||||||
do
|
do
|
||||||
# skip messages with bogus date
|
|
||||||
if [[ -z "${YEAR_MONTH}" ]]
|
|
||||||
then
|
|
||||||
warn "skipping bogus log lines (lines without proper datestamp)"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# find all messages for that YEAR-MONTH combination
|
# find all messages for that YEAR-MONTH combination
|
||||||
grep "${YEAR_MONTH}.*${LOG_SEP}${HC_NAME}${LOG_SEP}" "${HC_LOG}" >"${TMP1_FILE}"
|
grep "${YEAR_MONTH}.*${LOG_SEP}${HC_NAME}${LOG_SEP}" ${HC_LOG} >${TMP1_FILE}
|
||||||
TODO_LOG_COUNT=$(wc -l "${TMP1_FILE}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
TODO_LOG_COUNT=$(wc -l ${TMP1_FILE} 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
||||||
log "# of entries in ${YEAR_MONTH} to archive: ${TODO_LOG_COUNT}"
|
log "# of entries in ${YEAR_MONTH} to archive: ${TODO_LOG_COUNT}"
|
||||||
|
|
||||||
# combine existing archived messages and resort
|
# combine existing archived messages and resort
|
||||||
ARCHIVE_FILE="${ARCHIVE_DIR}/hc.${YEAR_MONTH}.log"
|
ARCHIVE_FILE="${ARCHIVE_DIR}/hc.${YEAR_MONTH}.log"
|
||||||
cat "${ARCHIVE_FILE}" "${TMP1_FILE}" 2>/dev/null | sort -u >"${TMP2_FILE}" 2>/dev/null
|
cat ${ARCHIVE_FILE} ${TMP1_FILE} 2>/dev/null | sort -u >${TMP2_FILE} 2>/dev/null
|
||||||
mv "${TMP2_FILE}" "${ARCHIVE_FILE}" 2>/dev/null || {
|
mv ${TMP2_FILE} ${ARCHIVE_FILE} 2>/dev/null || {
|
||||||
warn "failed to move archive file, aborting"
|
warn "failed to move archive file, aborting"
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
if (( COUNT_STATS > 0 ))
|
LOG_COUNT=$(wc -l ${ARCHIVE_FILE} 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
||||||
then
|
|
||||||
LOG_COUNT=$(wc -l "${ARCHIVE_FILE}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
|
||||||
log "# of entries in ${ARCHIVE_FILE} now: ${LOG_COUNT}"
|
log "# of entries in ${ARCHIVE_FILE} now: ${LOG_COUNT}"
|
||||||
fi
|
|
||||||
|
|
||||||
# remove archived messages from the $HC_LOG (but create a backup first!)
|
# remove archived messages from the $HC_LOG (but create a backup first!)
|
||||||
cp -p "${HC_LOG}" "${SAVE_HC_LOG}" 2>/dev/null
|
cp -p ${HC_LOG} ${SAVE_HC_LOG} 2>/dev/null
|
||||||
# compare with the sorted $HC_LOG
|
# compare with the sorted $HC_LOG
|
||||||
sort "${HC_LOG}" >"${TMP1_FILE}"
|
sort ${HC_LOG} >${TMP1_FILE}
|
||||||
comm -23 "${TMP1_FILE}" "${ARCHIVE_FILE}" 2>/dev/null >"${TMP2_FILE}"
|
comm -23 ${TMP1_FILE} ${ARCHIVE_FILE} 2>/dev/null >${TMP2_FILE}
|
||||||
|
|
||||||
# check archive action (HC_LOG should not be empty unless it contained
|
# check archive action (HC_LOG should not be empty unless it contained
|
||||||
# only messages from one single HC plugin before archival)
|
# only messages from one single HC plugin before archival)
|
||||||
if [[ -s ${TMP2_FILE} ]] || (( PRE_LOG_COUNT == TODO_LOG_COUNT ))
|
if [[ -s ${TMP2_FILE} ]] || (( PRE_LOG_COUNT == TODO_LOG_COUNT ))
|
||||||
then
|
then
|
||||||
mv "${TMP2_FILE}" "${HC_LOG}" 2>/dev/null || {
|
mv ${TMP2_FILE} ${HC_LOG} 2>/dev/null || {
|
||||||
warn "failed to move HC log file, aborting"
|
warn "failed to move HC log file, aborting"
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
if (( COUNT_STATS > 0 ))
|
LOG_COUNT=$(wc -l ${HC_LOG} 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
||||||
then
|
|
||||||
LOG_COUNT=$(wc -l "${HC_LOG}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
|
||||||
log "# entries in ${HC_LOG} now: ${LOG_COUNT}"
|
log "# entries in ${HC_LOG} now: ${LOG_COUNT}"
|
||||||
fi
|
|
||||||
ARCHIVE_RC=1
|
ARCHIVE_RC=1
|
||||||
else
|
else
|
||||||
warn "a problem occurred. Rolling back archival"
|
warn "a problem occurred. Rolling back archival"
|
||||||
mv "${SAVE_HC_LOG}" "${HC_LOG}" 2>/dev/null
|
mv ${SAVE_HC_LOG} ${HC_LOG} 2>/dev/null
|
||||||
ARCHIVE_RC=2
|
ARCHIVE_RC=2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# clean up temporary file(s)
|
# clean up temporary file(s)
|
||||||
rm -f "${TMP1_FILE}" "${TMP2_FILE}" "${SAVE_HC_LOG}" >/dev/null 2>&1
|
rm -f ${TMP1_FILE} ${TMP2_FILE} ${SAVE_HC_LOG} >/dev/null 2>&1
|
||||||
|
|
||||||
return ${ARCHIVE_RC}
|
return ${ARCHIVE_RC}
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: archive_hc_all()
|
|
||||||
# DOES: archive log entries for all HCs
|
|
||||||
# EXPECTS: n/a
|
|
||||||
# RETURNS: 0
|
|
||||||
# REQUIRES: ${HC_LOG}
|
|
||||||
function archive_hc_all
|
|
||||||
{
|
|
||||||
typeset HC_ARCHIVE=""
|
|
||||||
|
|
||||||
# build list with all HCs in $HC_LOG and sort them by highest number of messages
|
|
||||||
# first (to speed up the archiving operation)
|
|
||||||
log "parsing log file ${HC_LOG} for messages ..."
|
|
||||||
awk -F"${LOG_SEP}" '
|
|
||||||
{
|
|
||||||
# only do records with a proper HC name in $2
|
|
||||||
if ($2 ~ /check_/) {
|
|
||||||
count[$2]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
END {
|
|
||||||
for (hc in count) {
|
|
||||||
print count[hc] ":" hc;
|
|
||||||
}
|
|
||||||
}' "${HC_LOG}" 2>/dev/null | sort -rn 2>/dev/null |\
|
|
||||||
while IFS=":" read -r HC_COUNT HC_ARCHIVE
|
|
||||||
do
|
|
||||||
# check for HC (function)
|
|
||||||
exists_hc "${HC_ARCHIVE}" && die "cannot find HC: ${HC_ARCHIVE}"
|
|
||||||
log "archiving ${HC_COUNT} log entries for HC ${HC_ARCHIVE}"
|
|
||||||
archive_hc "${HC_ARCHIVE}"
|
|
||||||
ARCHIVE_RC=$?
|
|
||||||
case ${ARCHIVE_RC} in
|
|
||||||
0)
|
|
||||||
log "no archiving needed for ${HC_ARCHIVE}"
|
|
||||||
;;
|
|
||||||
1)
|
|
||||||
log "successfully archived log entries for ${HC_ARCHIVE}"
|
|
||||||
;;
|
|
||||||
2)
|
|
||||||
warn "failed to archive log entries for ${HC_ARCHIVE} [RC=${ARCHIVE_RC}]"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# @(#) FUNCTION: count_log_errors()
|
# @(#) FUNCTION: count_log_errors()
|
||||||
# DOES: check hc log file(s) for rogue entries (=lines with NF<>$NUM_LOG_FIELDS
|
# DOES: check hc log file(s) for rogue entries (=lines with NF<>$NUM_LOG_FIELDS
|
||||||
@ -211,7 +138,6 @@ function count_log_errors
|
|||||||
typeset LOG_STASH="${1}"
|
typeset LOG_STASH="${1}"
|
||||||
typeset ERROR_COUNT=0
|
typeset ERROR_COUNT=0
|
||||||
|
|
||||||
# shellcheck disable=SC2002,SC2086
|
|
||||||
ERROR_COUNT=$(cat ${LOG_STASH} 2>/dev/null | awk -F"${LOG_SEP}" '
|
ERROR_COUNT=$(cat ${LOG_STASH} 2>/dev/null | awk -F"${LOG_SEP}" '
|
||||||
BEGIN { num = 0 }
|
BEGIN { num = 0 }
|
||||||
{
|
{
|
||||||
@ -221,7 +147,7 @@ ERROR_COUNT=$(cat ${LOG_STASH} 2>/dev/null | awk -F"${LOG_SEP}" '
|
|||||||
}
|
}
|
||||||
END { print num }' 2>/dev/null)
|
END { print num }' 2>/dev/null)
|
||||||
|
|
||||||
print "${ERROR_COUNT}"
|
print ${ERROR_COUNT}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -263,7 +189,7 @@ then
|
|||||||
print - "$*" | while read -r LOG_LINE
|
print - "$*" | while read -r LOG_LINE
|
||||||
do
|
do
|
||||||
# shellcheck disable=SC2153
|
# shellcheck disable=SC2153
|
||||||
print "${NOW}: ERROR: [$$]:" "${LOG_LINE}" >>"${LOG_FILE}"
|
print "${NOW}: ERROR: [$$]:" "${LOG_LINE}" >>${LOG_FILE}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
print - "$*" | while read -r LOG_LINE
|
print - "$*" | while read -r LOG_LINE
|
||||||
@ -307,7 +233,6 @@ DO_DISPLAY_CUSTOM9=0
|
|||||||
DO_NOTIFY_EIF=0
|
DO_NOTIFY_EIF=0
|
||||||
DO_NOTIFY_MAIL=0
|
DO_NOTIFY_MAIL=0
|
||||||
DO_NOTIFY_SMS=0
|
DO_NOTIFY_SMS=0
|
||||||
DO_NOTIFY_SLACK=0
|
|
||||||
DO_REPORT_STD=0
|
DO_REPORT_STD=0
|
||||||
HAS_DISPLAY_CSV=0
|
HAS_DISPLAY_CSV=0
|
||||||
HAS_DISPLAY_INIT=0
|
HAS_DISPLAY_INIT=0
|
||||||
@ -326,13 +251,12 @@ HAS_DISPLAY_CUSTOM9=0
|
|||||||
HAS_NOTIFY_EIF=0
|
HAS_NOTIFY_EIF=0
|
||||||
HAS_NOTIFY_MAIL=0
|
HAS_NOTIFY_MAIL=0
|
||||||
HAS_NOTIFY_SMS=0
|
HAS_NOTIFY_SMS=0
|
||||||
HAS_NOTIFY_SLACK=0
|
|
||||||
HAS_REPORT_STD=0
|
HAS_REPORT_STD=0
|
||||||
|
|
||||||
# check which core display/notification plugins are installed
|
# check which core display/notification plugins are installed
|
||||||
# do not use a while-do loop here because mksh/pdksh does not pass updated
|
# do not use a while-do loop here because mksh/pdksh does not pass updated
|
||||||
# variables back from the sub shell (only works for true ksh88/ksh93)
|
# variables back from the sub shell (only works for true ksh88/ksh93)
|
||||||
# shellcheck disable=SC2010,SC2086
|
# shellcheck disable=SC2010
|
||||||
for FFILE in $(ls -1 ${FPATH_PARENT}/core/*.sh 2>/dev/null | grep -v "include_" 2>/dev/null)
|
for FFILE in $(ls -1 ${FPATH_PARENT}/core/*.sh 2>/dev/null | grep -v "include_" 2>/dev/null)
|
||||||
do
|
do
|
||||||
case "${FFILE}" in
|
case "${FFILE}" in
|
||||||
@ -404,10 +328,6 @@ do
|
|||||||
HAS_NOTIFY_EIF=1
|
HAS_NOTIFY_EIF=1
|
||||||
(( ARG_DEBUG > 0 )) && debug "notify_eif plugin is available"
|
(( ARG_DEBUG > 0 )) && debug "notify_eif plugin is available"
|
||||||
;;
|
;;
|
||||||
*notify_slack.sh)
|
|
||||||
HAS_NOTIFY_SLACK=1
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "notify_slack plugin is available"
|
|
||||||
;;
|
|
||||||
*report_std.sh)
|
*report_std.sh)
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
HAS_REPORT_STD=1
|
HAS_REPORT_STD=1
|
||||||
@ -565,9 +485,6 @@ then
|
|||||||
*mail*) # by mail
|
*mail*) # by mail
|
||||||
DO_NOTIFY_MAIL=1
|
DO_NOTIFY_MAIL=1
|
||||||
;;
|
;;
|
||||||
*slack*) # by Slack
|
|
||||||
DO_NOTIFY_SLACK=1
|
|
||||||
;;
|
|
||||||
*sms*) # by sms
|
*sms*) # by sms
|
||||||
DO_NOTIFY_SMS=1
|
DO_NOTIFY_SMS=1
|
||||||
;;
|
;;
|
||||||
@ -726,10 +643,8 @@ return 0
|
|||||||
function dump_logs
|
function dump_logs
|
||||||
{
|
{
|
||||||
log "=== STDOUT ==="
|
log "=== STDOUT ==="
|
||||||
# shellcheck disable=SC2086
|
|
||||||
log "$(<${HC_STDOUT_LOG})"
|
log "$(<${HC_STDOUT_LOG})"
|
||||||
log "=== STDERR ==="
|
log "=== STDERR ==="
|
||||||
# shellcheck disable=SC2086
|
|
||||||
log "$(<${HC_STDERR_LOG})"
|
log "$(<${HC_STDERR_LOG})"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -818,26 +733,24 @@ fi
|
|||||||
trap "[[ -f ${TMP_FILE} ]] && rm -f ${TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
|
trap "[[ -f ${TMP_FILE} ]] && rm -f ${TMP_FILE} >/dev/null 2>&1; return 1" 1 2 3 15
|
||||||
|
|
||||||
# check and rewrite log file(s)
|
# check and rewrite log file(s)
|
||||||
# shellcheck disable=SC2086
|
|
||||||
find ${LOG_STASH} -type f -print 2>/dev/null | while read -r FIX_FILE
|
find ${LOG_STASH} -type f -print 2>/dev/null | while read -r FIX_FILE
|
||||||
do
|
do
|
||||||
log "fixing log file ${FIX_FILE} ..."
|
log "fixing log file ${FIX_FILE} ..."
|
||||||
|
|
||||||
# count before rewrite
|
# count before rewrite
|
||||||
STASH_COUNT=$(wc -l "${FIX_FILE}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
STASH_COUNT=$(wc -l ${FIX_FILE} 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
||||||
|
|
||||||
# does it have errors?
|
# does it have errors?
|
||||||
ERROR_COUNT=$(count_log_errors "${FIX_FILE}")
|
ERROR_COUNT=$(count_log_errors ${FIX_FILE})
|
||||||
|
|
||||||
# we count the empty lines (again)
|
# we count the empty lines (again)
|
||||||
EMPTY_COUNT=$(grep -c -E -e '^$' "${FIX_FILE}" 2>/dev/null)
|
EMPTY_COUNT=$(grep -c -E -e '^$' ${FIX_FILE} 2>/dev/null)
|
||||||
|
|
||||||
# rewrite if needed
|
# rewrite if needed
|
||||||
if (( ERROR_COUNT > 0 ))
|
if (( ERROR_COUNT > 0 ))
|
||||||
then
|
then
|
||||||
: >"${TMP_FILE}" 2>/dev/null
|
: >${TMP_FILE} 2>/dev/null
|
||||||
# shellcheck disable=SC2002
|
cat ${FIX_FILE} 2>/dev/null | awk -F"${LOG_SEP}" -v OFS="${LOG_SEP}" '
|
||||||
cat "${FIX_FILE}" 2>/dev/null | awk -F"${LOG_SEP}" -v OFS="${LOG_SEP}" '
|
|
||||||
|
|
||||||
BEGIN { max_log_fields = '"${NUM_LOG_FIELDS}"'
|
BEGIN { max_log_fields = '"${NUM_LOG_FIELDS}"'
|
||||||
max_fields = (max_log_fields - 1) * 2
|
max_fields = (max_log_fields - 1) * 2
|
||||||
@ -913,10 +826,10 @@ do
|
|||||||
# correct log line, no rewrite needed
|
# correct log line, no rewrite needed
|
||||||
print $0
|
print $0
|
||||||
}
|
}
|
||||||
}' >"${TMP_FILE}" 2>/dev/null
|
}' >${TMP_FILE} 2>/dev/null
|
||||||
|
|
||||||
# count after rewrite (include empty lines again in the count)
|
# count after rewrite (include empty lines again in the count)
|
||||||
TMP_COUNT=$(wc -l "${TMP_FILE}" 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
TMP_COUNT=$(wc -l ${TMP_FILE} 2>/dev/null | cut -f1 -d' ' 2>/dev/null)
|
||||||
TMP_COUNT=$(( TMP_COUNT + EMPTY_COUNT ))
|
TMP_COUNT=$(( TMP_COUNT + EMPTY_COUNT ))
|
||||||
|
|
||||||
# bail out when we do not have enough records
|
# bail out when we do not have enough records
|
||||||
@ -927,16 +840,16 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# swap log file (but create a backup first!)
|
# swap log file (but create a backup first!)
|
||||||
cp -p "${FIX_FILE}" "${SAVE_TMP_FILE}" 2>/dev/null
|
cp -p ${FIX_FILE} ${SAVE_TMP_FILE} 2>/dev/null
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if (( $? == 0 ))
|
if (( $? == 0 ))
|
||||||
then
|
then
|
||||||
mv "${TMP_FILE}" "${FIX_FILE}" 2>/dev/null
|
mv ${TMP_FILE} ${FIX_FILE} 2>/dev/null
|
||||||
# shellcheck disable=SC2181
|
# shellcheck disable=SC2181
|
||||||
if (( $? > 0 ))
|
if (( $? > 0 ))
|
||||||
then
|
then
|
||||||
warn "failed to move/update log file, rolling back"
|
warn "failed to move/update log file, rolling back"
|
||||||
mv "${SAVE_TMP_FILE}" "${FIX_FILE}" 2>/dev/null
|
mv ${SAVE_TMP_FILE} ${FIX_FILE} 2>/dev/null
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
FIX_RC=1
|
FIX_RC=1
|
||||||
@ -946,7 +859,7 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# clean up temporary file(s)
|
# clean up temporary file(s)
|
||||||
rm -f "${SAVE_TMP_FILE}" "${TMP_FILE}" >/dev/null 2>&1
|
rm -f ${SAVE_TMP_FILE} ${TMP_FILE} >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
log "no fixing needed for ${FIX_FILE}"
|
log "no fixing needed for ${FIX_FILE}"
|
||||||
fi
|
fi
|
||||||
@ -957,33 +870,12 @@ done
|
|||||||
return ${FIX_RC}
|
return ${FIX_RC}
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: get_disable_comment()
|
|
||||||
# DOES: retrieve comment for a disabled HC
|
|
||||||
# EXPECTS: HC name [string]
|
|
||||||
# OUTPUTS: comment [string]
|
|
||||||
# RETURNS: 0
|
|
||||||
# REQUIRES: n/a
|
|
||||||
function get_disable_comment
|
|
||||||
{
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
typeset COMMENT_HC="${1}"
|
|
||||||
|
|
||||||
if [[ -s "${STATE_PERM_DIR}/${COMMENT_HC}.disabled" ]]
|
|
||||||
then
|
|
||||||
cat "${STATE_PERM_DIR}/${COMMENT_HC}.disabled" 2>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# @(#) FUNCTION: handle_hc()
|
# @(#) FUNCTION: handle_hc()
|
||||||
# DOES: handle HC results
|
# DOES: handle HC results
|
||||||
# EXPECTS: 1=HC name [string], $HC_MSG_FILE temporary file
|
# EXPECTS: 1=HC name [string], $HC_MSG_FILE temporary file
|
||||||
# RETURNS: 0 or $HC_STC_RC
|
# RETURNS: 0 or $HC_STC_RC
|
||||||
# REQUIRES: data_contains_string(), data_is_numeric(), die(), display_*(),
|
# REQUIRES: die(), display_*(), notify_*(), warn()
|
||||||
# notify_*(), warn()
|
|
||||||
function handle_hc
|
function handle_hc
|
||||||
{
|
{
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
@ -997,21 +889,12 @@ typeset ONE_MSG_TEXT=""
|
|||||||
typeset ONE_MSG_CUR_VAL=""
|
typeset ONE_MSG_CUR_VAL=""
|
||||||
typeset ONE_MSG_EXP_VAL=""
|
typeset ONE_MSG_EXP_VAL=""
|
||||||
typeset ALL_MSG_STC=0
|
typeset ALL_MSG_STC=0
|
||||||
typeset HC_CACHE_LAST_DATE=""
|
|
||||||
typeset HC_CACHE_TODAY_DATE=""
|
|
||||||
typeset HC_CACHE_LAST_NOW="$(date '+%Y-%m-%d %H:%M:%S' 2>/dev/null)" # see also $HC_NOW
|
|
||||||
typeset HC_CACHE_TODAY_NOW="$(date '+%Y-%m-%d' 2>/dev/null)" # see also $HC_NOW
|
|
||||||
typeset HC_REPORT_CACHE_LAST_STUB="${STATE_PERM_DIR}/cache.report-last"
|
|
||||||
typeset HC_REPORT_CACHE_LAST_FILE=""
|
|
||||||
typeset HC_REPORT_CACHE_TODAY_FILE="${STATE_PERM_DIR}/cache.report-today"
|
|
||||||
typeset LOG_STRING_GOOD=""
|
|
||||||
typeset LOG_STRING_FAIL=""
|
|
||||||
|
|
||||||
if [[ -s ${HC_MSG_FILE} ]]
|
if [[ -s ${HC_MSG_FILE} ]]
|
||||||
then
|
then
|
||||||
# load messages file into memory
|
# load messages file into memory
|
||||||
# do not use array: max 1024 items in ksh88; regular variable is only 32-bit memory limited
|
# do not use array: max 1024 items in ksh88; regular variable is only 32-bit memory limited
|
||||||
HC_MSG_VAR=$(<"${HC_MSG_FILE}")
|
HC_MSG_VAR=$(<${HC_MSG_FILE})
|
||||||
|
|
||||||
# DEBUG: dump TMP file
|
# DEBUG: dump TMP file
|
||||||
if (( ARG_DEBUG > 0 ))
|
if (( ARG_DEBUG > 0 ))
|
||||||
@ -1029,7 +912,6 @@ else
|
|||||||
# nothing to do, respect current EXIT_CODE
|
# nothing to do, respect current EXIT_CODE
|
||||||
if (( EXIT_CODE > 0 ))
|
if (( EXIT_CODE > 0 ))
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC2086
|
|
||||||
return ${EXIT_CODE}
|
return ${EXIT_CODE}
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
@ -1247,56 +1129,15 @@ then
|
|||||||
ONE_MSG_EXP_VAL=$(data_magic_unquote "${ONE_MSG_EXP_VAL}")
|
ONE_MSG_EXP_VAL=$(data_magic_unquote "${ONE_MSG_EXP_VAL}")
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
printf "%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}" \
|
||||||
|
"${ONE_MSG_TIME}" \
|
||||||
|
"${HC_NAME}" \
|
||||||
|
${ONE_MSG_STC} \
|
||||||
|
"${ONE_MSG_TEXT}" >>${HC_LOG}
|
||||||
if (( ONE_MSG_STC > 0 ))
|
if (( ONE_MSG_STC > 0 ))
|
||||||
then
|
then
|
||||||
# build log string
|
|
||||||
LOG_STRING_FAIL=$(printf "%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}" "${ONE_MSG_TIME}" "${HC_NAME}" "${ONE_MSG_STC}" "${ONE_MSG_TEXT}" "${HC_FAIL_ID}")
|
|
||||||
|
|
||||||
# do atomic log update
|
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
print "${LOG_STRING_FAIL}" >>"${HC_LOG}"
|
printf "%s${LOG_SEP}\n" "${HC_FAIL_ID}" >>${HC_LOG}
|
||||||
|
|
||||||
# cache report (--report --last)
|
|
||||||
HC_REPORT_CACHE_LAST_FILE="${HC_REPORT_CACHE_LAST_STUB}-${HC_NAME}"
|
|
||||||
case "${HC_REPORT_CACHE_LAST}" in
|
|
||||||
Yes|yes|YES)
|
|
||||||
# fetch date of last cache entry (did we rollover from last HC event?)
|
|
||||||
HC_CACHE_LAST_DATE=$(tail -n 1 "${HC_REPORT_CACHE_LAST_FILE}" 2>/dev/null | cut -f1 -d"${LOG_SEP}" 2>/dev/null)
|
|
||||||
if [[ -z "${HC_CACHE_LAST_DATE}" ]] || [[ "${HC_CACHE_LAST_DATE}" != "${HC_CACHE_LAST_NOW}" ]]
|
|
||||||
then
|
|
||||||
# set and update cache file
|
|
||||||
print "${LOG_STRING_FAIL}" >"${HC_REPORT_CACHE_LAST_FILE}"
|
|
||||||
else
|
|
||||||
# append cache file
|
|
||||||
print "${LOG_STRING_FAIL}" >>"${HC_REPORT_CACHE_LAST_FILE}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# remove cache file if it exists
|
|
||||||
[[ -f "${HC_REPORT_CACHE_LAST_FILE}" ]] && rm -f "${HC_REPORT_CACHE_LAST_FILE}" >/dev/null 2>/dev/null
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# cache report (--report --today)
|
|
||||||
case "${HC_REPORT_CACHE_TODAY}" in
|
|
||||||
Yes|yes|YES)
|
|
||||||
# fetch date of last cache entry (did we rollover midnight?)
|
|
||||||
HC_CACHE_TODAY_DATE=$(tail -n 1 "${HC_REPORT_CACHE_TODAY_FILE}" 2>/dev/null | cut -f1 -d"${LOG_SEP}" 2>/dev/null | awk '{ print $1 }' 2>/dev/null)
|
|
||||||
if [[ -z "${HC_CACHE_TODAY_DATE}" ]] || [[ "${HC_CACHE_TODAY_DATE}" != "${HC_CACHE_TODAY_NOW}" ]]
|
|
||||||
then
|
|
||||||
# rotate and update cache file
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "rotating today's cache file at ${HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
print "${LOG_STRING_FAIL}" >"${HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
else
|
|
||||||
# append cache file
|
|
||||||
print "${LOG_STRING_FAIL}" >>"${HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# remove cache file if it exists
|
|
||||||
[[ -f "${HC_REPORT_CACHE_TODAY_FILE}" ]] && rm -f "${HC_REPORT_CACHE_TODAY_FILE}" >/dev/null 2>/dev/null
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# RC handling (max/sum/count)
|
# RC handling (max/sum/count)
|
||||||
if (( ARG_FLIP_RC > 0 ))
|
if (( ARG_FLIP_RC > 0 ))
|
||||||
then
|
then
|
||||||
@ -1316,53 +1157,8 @@ then
|
|||||||
HC_STC_RC=$(( HC_STC_RC + 1 ))
|
HC_STC_RC=$(( HC_STC_RC + 1 ))
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# build log string
|
|
||||||
LOG_STRING_GOOD=$(printf "%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}" "${ONE_MSG_TIME}" "${HC_NAME}" "${ONE_MSG_STC}" "${ONE_MSG_TEXT}")
|
|
||||||
|
|
||||||
# do atomic log update
|
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
print "${LOG_STRING_GOOD}" >>"${HC_LOG}"
|
printf "\n" >>${HC_LOG}
|
||||||
|
|
||||||
# cache report (--report --last)
|
|
||||||
HC_REPORT_CACHE_LAST_FILE="${HC_REPORT_CACHE_LAST_STUB}-${HC_NAME}"
|
|
||||||
case "${HC_REPORT_CACHE_LAST}" in
|
|
||||||
Yes|yes|YES)
|
|
||||||
# fetch date of last cache entry (did we rollover from last HC event?)
|
|
||||||
HC_CACHE_LAST_DATE=$(tail -n 1 "${HC_REPORT_CACHE_LAST_FILE}" 2>/dev/null | cut -f1 -d"${LOG_SEP}" 2>/dev/null)
|
|
||||||
if [[ -z "${HC_CACHE_LAST_DATE}" ]] || [[ "${HC_CACHE_LAST_DATE}" != "${HC_CACHE_LAST_NOW}" ]]
|
|
||||||
then
|
|
||||||
# set and update cache file
|
|
||||||
print "${LOG_STRING_GOOD}" >"${HC_REPORT_CACHE_LAST_FILE}"
|
|
||||||
else
|
|
||||||
# append cache file
|
|
||||||
print "${LOG_STRING_GOOD}" >>"${HC_REPORT_CACHE_LAST_FILE}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# remove cache file if it exists
|
|
||||||
[[ -f "${HC_REPORT_CACHE_LAST_FILE}" ]] && rm -f "${HC_REPORT_CACHE_LAST_FILE}" >/dev/null 2>/dev/null
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
# cache report (--report --today)
|
|
||||||
case "${HC_REPORT_CACHE_TODAY}" in
|
|
||||||
Yes|yes|YES)
|
|
||||||
# fetch date of last cache last_entry (did we rollover midnight?)
|
|
||||||
HC_CACHE_TODAY_DATE=$(tail -n 1 "${HC_REPORT_CACHE_TODAY_FILE}" 2>/dev/null | cut -f1 -d"${LOG_SEP}" 2>/dev/null | awk '{ print $1 }' 2>/dev/null)
|
|
||||||
if [[ -z "${HC_CACHE_TODAY_DATE}" ]] || [[ "${HC_CACHE_TODAY_DATE}" != "${HC_CACHE_TODAY_NOW}" ]]
|
|
||||||
then
|
|
||||||
# rotate and update cache file
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "rotating today's cache file at ${HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
print "${LOG_STRING_GOOD}" >"${HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
else
|
|
||||||
# append cache file
|
|
||||||
print "${LOG_STRING_GOOD}" >>"${HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# remove cache file if it exists
|
|
||||||
[[ -f ${HC_REPORT_CACHE_TODAY_FILE} ]] && rm -f "${HC_REPORT_CACHE_TODAY_FILE}" >/dev/null 2>/dev/null
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -1379,14 +1175,14 @@ then
|
|||||||
then
|
then
|
||||||
# cut off the path and the .$$ part from the file location
|
# cut off the path and the .$$ part from the file location
|
||||||
HC_STDOUT_LOG_SHORT="${HC_STDOUT_LOG##*/}"
|
HC_STDOUT_LOG_SHORT="${HC_STDOUT_LOG##*/}"
|
||||||
mv "${HC_STDOUT_LOG}" "${EVENTS_DIR}/${DIR_PREFIX}/${HC_FAIL_ID}/${HC_STDOUT_LOG_SHORT%.*}" >/dev/null 2>&1 || \
|
mv ${HC_STDOUT_LOG} "${EVENTS_DIR}/${DIR_PREFIX}/${HC_FAIL_ID}/${HC_STDOUT_LOG_SHORT%.*}" >/dev/null 2>&1 || \
|
||||||
die "failed to move ${HC_STDOUT_LOG} to event directory at ${1}"
|
die "failed to move ${HC_STDOUT_LOG} to event directory at ${1}"
|
||||||
fi
|
fi
|
||||||
if [[ -f ${HC_STDERR_LOG} ]]
|
if [[ -f ${HC_STDERR_LOG} ]]
|
||||||
then
|
then
|
||||||
# cut off the path and the .$$ part from the file location
|
# cut off the path and the .$$ part from the file location
|
||||||
HC_STDERR_LOG_SHORT="${HC_STDERR_LOG##*/}"
|
HC_STDERR_LOG_SHORT="${HC_STDERR_LOG##*/}"
|
||||||
mv "${HC_STDERR_LOG}" "${EVENTS_DIR}/${DIR_PREFIX}/${HC_FAIL_ID}/${HC_STDERR_LOG_SHORT%.*}" >/dev/null 2>&1 || \
|
mv ${HC_STDERR_LOG} "${EVENTS_DIR}/${DIR_PREFIX}/${HC_FAIL_ID}/${HC_STDERR_LOG_SHORT%.*}" >/dev/null 2>&1 || \
|
||||||
die "failed to move ${HC_STDERR_LOG} to event directory at ${1}"
|
die "failed to move ${HC_STDERR_LOG} to event directory at ${1}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -1425,17 +1221,6 @@ then
|
|||||||
warn "notify_sms plugin is not avaible, cannot send alert via sms!"
|
warn "notify_sms plugin is not avaible, cannot send alert via sms!"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# by Slack?
|
|
||||||
if (( DO_NOTIFY_SLACK == 1 ))
|
|
||||||
then
|
|
||||||
if (( HAS_NOTIFY_SLACK == 1 ))
|
|
||||||
then
|
|
||||||
# call plugin
|
|
||||||
notify_slack "${HC_NAME}" "${HC_FAIL_ID}"
|
|
||||||
else
|
|
||||||
warn "notify_slack plugin is not avaible, cannot send alert via Slack!"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1460,7 +1245,6 @@ fi
|
|||||||
function handle_timeout
|
function handle_timeout
|
||||||
{
|
{
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||||
# shellcheck disable=SC2086
|
|
||||||
[[ -n "${CHILD_PID}" ]] && kill -s TERM ${CHILD_PID}
|
[[ -n "${CHILD_PID}" ]] && kill -s TERM ${CHILD_PID}
|
||||||
warn "child process with PID ${CHILD_PID} has been forcefully stopped"
|
warn "child process with PID ${CHILD_PID} has been forcefully stopped"
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
@ -1590,8 +1374,8 @@ esac
|
|||||||
|
|
||||||
# mangle $ARG_HC to build the full list of HCs to be executed
|
# mangle $ARG_HC to build the full list of HCs to be executed
|
||||||
ARG_HC=""
|
ARG_HC=""
|
||||||
grep -i '^hc:' "${HOST_CONFIG_FILE}" 2>/dev/null |\
|
grep -i '^hc:' ${HOST_CONFIG_FILE} 2>/dev/null |\
|
||||||
while IFS=':' read -r _ HC_EXEC _ _
|
while IFS=':' read _ HC_EXEC _ _
|
||||||
do
|
do
|
||||||
ARG_HC="${ARG_HC},${HC_EXEC}"
|
ARG_HC="${ARG_HC},${HC_EXEC}"
|
||||||
done
|
done
|
||||||
@ -1652,23 +1436,19 @@ case "${OS_NAME}" in
|
|||||||
# check system crontabs
|
# check system crontabs
|
||||||
if (( CRON_COUNT == 0 ))
|
if (( CRON_COUNT == 0 ))
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC2002,SC2086
|
|
||||||
CRON_COUNT=$(cat ${CRON_SYS_LOCATIONS} 2>/dev/null | grep -c -E -e "^[^#].*${CRON_HC}" 2>/dev/null)
|
CRON_COUNT=$(cat ${CRON_SYS_LOCATIONS} 2>/dev/null | grep -c -E -e "^[^#].*${CRON_HC}" 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
# check anacron
|
# check anacron
|
||||||
if (( CRON_COUNT == 0 ))
|
if (( CRON_COUNT == 0 ))
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC2002,SC2086
|
|
||||||
CRON_COUNT=$(cat ${CRON_ANACRON_LOCATIONS} 2>/dev/null | grep -c -E -e "^[^#].*${CRON_HC}" 2>/dev/null)
|
CRON_COUNT=$(cat ${CRON_ANACRON_LOCATIONS} 2>/dev/null | grep -c -E -e "^[^#].*${CRON_HC}" 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# use default root crontab
|
# use default root crontab
|
||||||
CRON_COUNT=$(crontab -l 2>/dev/null | grep -c -E -e "^[^#].*${CRON_HC}" 2>/dev/null)
|
CRON_COUNT=$(crontab -l 2>/dev/null | grep -c -E -e "^[^#].*${CRON_HC}" 2>/dev/null)
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
return ${CRON_COUNT}
|
return ${CRON_COUNT}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1700,11 +1480,11 @@ printf "%80s\n" | tr ' ' -
|
|||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" | sort 2>/dev/null | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" | sort 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# exclude core helper librar(y|ies)
|
# exclude core helper librar(y|ies)
|
||||||
# shellcheck disable=SC2010,SC2086
|
# shellcheck disable=SC2010
|
||||||
ls -1 ${FDIR}/*.sh 2>/dev/null | grep -v "include_" | sort 2>/dev/null | while read -r FFILE
|
ls -1 ${FDIR}/*.sh 2>/dev/null | grep -v "include_" | sort 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
# cache script contents in memory
|
# cache script contents in memory
|
||||||
FSCRIPT="$(<${FFILE})"
|
FSCRIPT=$(<${FFILE})
|
||||||
|
|
||||||
# reset state
|
# reset state
|
||||||
FSTATE="enabled"
|
FSTATE="enabled"
|
||||||
@ -1746,12 +1526,12 @@ print -n "Dead links: "
|
|||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# do not use 'find -type l' here!
|
# do not use 'find -type l' here!
|
||||||
# shellcheck disable=SC2010,SC1117,SC2086
|
# shellcheck disable=SC2010,SC1117
|
||||||
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
||||||
then
|
then
|
||||||
printf "%s " "${FFILE##*/}"
|
printf "%s " ${FFILE##*/}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -1783,7 +1563,6 @@ typeset FCONFIG=""
|
|||||||
typeset FSTATE=""
|
typeset FSTATE=""
|
||||||
typeset FFILE=""
|
typeset FFILE=""
|
||||||
typeset FHEALTHY=""
|
typeset FHEALTHY=""
|
||||||
typeset FFIX=0
|
|
||||||
typeset FSCHEDULED=0
|
typeset FSCHEDULED=0
|
||||||
typeset FSCRIPT=""
|
typeset FSCRIPT=""
|
||||||
typeset HAS_FCONFIG=0
|
typeset HAS_FCONFIG=0
|
||||||
@ -1800,45 +1579,22 @@ fi
|
|||||||
|
|
||||||
# print header
|
# print header
|
||||||
if [[ "${FACTION}" != "list" ]]
|
if [[ "${FACTION}" != "list" ]]
|
||||||
then
|
|
||||||
if (( ARG_LIST_DETAILS > 0 ))
|
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
printf "%-40s\t%-8s\t%s\t\t%s\t%s\t%s\t%s\n" "Health Check" "State" "Version" "Config?" "Sched?" "H+?" "Fix?"
|
printf "%-40s\t%-8s\t%s\t\t%s\t%s\t%s\n" "Health Check" "State" "Version" "Config?" "Sched?" "H+?"
|
||||||
# shellcheck disable=SC2183,SC1117
|
# shellcheck disable=SC2183,SC1117
|
||||||
printf "%110s\n" | tr ' ' -
|
printf "%100s\n" | tr ' ' -
|
||||||
else
|
|
||||||
# shellcheck disable=SC1117
|
|
||||||
printf "%-40s\t%-8s\n" "Health Check" "State"
|
|
||||||
# shellcheck disable=SC2183,SC1117
|
|
||||||
printf "%60s\n" | tr ' ' -
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep -v "core$" 2>/dev/null | sort 2>/dev/null |\
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep -v "core$" 2>/dev/null | sort 2>/dev/null |\
|
||||||
while read -r FDIR
|
while read -r FDIR
|
||||||
do
|
do
|
||||||
# shellcheck disable=SC2012,SC2086
|
|
||||||
ls -1 ${FDIR}/${FNEEDLE} 2>/dev/null | sort 2>/dev/null | while read -r FFILE
|
ls -1 ${FDIR}/${FNEEDLE} 2>/dev/null | sort 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
# cache script contents in memory
|
# cache script contents in memory
|
||||||
FSCRIPT="$(<${FFILE})"
|
FSCRIPT=$(<${FFILE})
|
||||||
|
|
||||||
# --list (basic)
|
|
||||||
# find function name but skip helper functions in the plug-in file (function _name)
|
# find function name but skip helper functions in the plug-in file (function _name)
|
||||||
FNAME=$(print -R "${FSCRIPT}" | grep -E -e "^function[[:space:]]+[^_]" 2>/dev/null)
|
FNAME=$(print -R "${FSCRIPT}" | grep -E -e "^function[[:space:]]+[^_]" 2>/dev/null)
|
||||||
|
|
||||||
# check state
|
|
||||||
DISABLE_FFILE="$(print ${FFILE##*/} | sed 's/\.sh$//')"
|
|
||||||
if [[ -f "${STATE_PERM_DIR}/${DISABLE_FFILE}.disabled" ]]
|
|
||||||
then
|
|
||||||
FSTATE="disabled"
|
|
||||||
else
|
|
||||||
FSTATE="enabled"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --list-details
|
|
||||||
if (( ARG_LIST_DETAILS > 0 ))
|
|
||||||
then
|
|
||||||
# look for version string (cut off comments but don't use [:space:] in tr)
|
# look for version string (cut off comments but don't use [:space:] in tr)
|
||||||
FVERSION=$(print -R "${FSCRIPT}" | grep '^typeset _VERSION=' 2>/dev/null |\
|
FVERSION=$(print -R "${FSCRIPT}" | grep '^typeset _VERSION=' 2>/dev/null |\
|
||||||
awk 'match($0,/[0-9]+-[0-9]+-[0-9]+/){print substr($0, RSTART, RLENGTH)}' 2>/dev/null)
|
awk 'match($0,/[0-9]+-[0-9]+-[0-9]+/){print substr($0, RSTART, RLENGTH)}' 2>/dev/null)
|
||||||
@ -1892,14 +1648,14 @@ do
|
|||||||
FCONFIG="No"
|
FCONFIG="No"
|
||||||
FHEALTHY="N/S"
|
FHEALTHY="N/S"
|
||||||
fi
|
fi
|
||||||
# check fix
|
# check state
|
||||||
if (( $(print -R "${FSCRIPT}" | grep -c -E -e "_HC_CAN_FIX=1" 2>/dev/null) > 0 ))
|
DISABLE_FFILE="$(print ${FFILE##*/} | sed 's/\.sh$//')"
|
||||||
|
if [[ -f "${STATE_PERM_DIR}/${DISABLE_FFILE}.disabled" ]]
|
||||||
then
|
then
|
||||||
FFIX="Yes"
|
FSTATE="disabled"
|
||||||
else
|
else
|
||||||
FFIX="No"
|
FSTATE="enabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# reset state when unlinked
|
# reset state when unlinked
|
||||||
[[ -h ${FFILE%%.*} ]] || FSTATE="unlinked"
|
[[ -h ${FFILE%%.*} ]] || FSTATE="unlinked"
|
||||||
# check scheduling
|
# check scheduling
|
||||||
@ -1911,28 +1667,18 @@ do
|
|||||||
else
|
else
|
||||||
FSCHEDULED="Yes"
|
FSCHEDULED="Yes"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# show results
|
# show results
|
||||||
if [[ "${FACTION}" != "list" ]]
|
if [[ "${FACTION}" != "list" ]]
|
||||||
then
|
|
||||||
if (( ARG_LIST_DETAILS > 0 ))
|
|
||||||
then
|
then
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
printf "%-40s\t%-8s\t%s\t%s\t%s\t%s\t%s\n" \
|
printf "%-40s\t%-8s\t%s\t%s\t%s\t%s\n" \
|
||||||
"${FNAME#function *}" \
|
"${FNAME#function *}" \
|
||||||
"${FSTATE}" \
|
"${FSTATE}" \
|
||||||
"${FVERSION#typeset _VERSION=*}" \
|
"${FVERSION#typeset _VERSION=*}" \
|
||||||
"${FCONFIG}" \
|
"${FCONFIG}" \
|
||||||
"${FSCHEDULED}" \
|
"${FSCHEDULED}" \
|
||||||
"${FHEALTHY}" \
|
"${FHEALTHY}"
|
||||||
"${FFIX}"
|
|
||||||
else
|
|
||||||
# shellcheck disable=SC1117
|
|
||||||
printf "%-40s\t%-8s\n" \
|
|
||||||
"${FNAME#function *}" \
|
|
||||||
"${FSTATE}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
printf "%s\n" "${FNAME#function *}"
|
printf "%s\n" "${FNAME#function *}"
|
||||||
@ -1948,12 +1694,12 @@ then
|
|||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep -v "core" 2>/dev/null | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep -v "core" 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# do not use 'find -type l' here!
|
# do not use 'find -type l' here!
|
||||||
# shellcheck disable=SC2010,SC1117,SC2086
|
# shellcheck disable=SC2010,SC1117
|
||||||
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
||||||
then
|
then
|
||||||
printf "%s " "${FFILE##*/}"
|
printf "%s " ${FFILE##*/}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -1966,19 +1712,11 @@ fi
|
|||||||
|
|
||||||
# legend
|
# legend
|
||||||
if [[ "${FACTION}" != "list" ]]
|
if [[ "${FACTION}" != "list" ]]
|
||||||
then
|
|
||||||
if (( ARG_LIST_DETAILS > 0 ))
|
|
||||||
then
|
then
|
||||||
print
|
print
|
||||||
print "Config?: plugin has a default configuration file (Yes/No)"
|
print "Config?: plugin has a default configuration file (Yes/No)"
|
||||||
print "Sched? : plugin is scheduled through cron (Yes/No)"
|
print "Sched? : plugin is scheduled through cron (Yes/No)"
|
||||||
print "H+? : plugin can choose whether to log/show passed health checks (Yes/No/Supported/Not supported)"
|
print "H+? : plugin can choose whether to log/show passed health checks (Yes/No/Supported/Not supported)"
|
||||||
print "Fix? : plugin contains fix/healing logic (Yes/No) -- not used by default!"
|
|
||||||
else
|
|
||||||
print
|
|
||||||
print "Tip: use --list-details to see a list of health checks with more details"
|
|
||||||
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -2011,11 +1749,11 @@ printf "%100s\n" | tr ' ' -
|
|||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | sort 2>/dev/null | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | sort 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# exclude core helper librar(y|ies)
|
# exclude core helper librar(y|ies)
|
||||||
# shellcheck disable=SC2010,SC2086
|
# shellcheck disable=SC2010
|
||||||
ls -1 ${FDIR}/*.sh 2>/dev/null | grep "include_" 2>/dev/null | sort 2>/dev/null | while read -r FFILE
|
ls -1 ${FDIR}/*.sh 2>/dev/null | grep "include_" 2>/dev/null | sort 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
# cache script contents in memory
|
# cache script contents in memory
|
||||||
FSCRIPT="$(<${FFILE})"
|
FSCRIPT=$(<${FFILE})
|
||||||
|
|
||||||
# find function name
|
# find function name
|
||||||
FNAME=$(print -R "${FSCRIPT}" | grep -E -e "^function[[:space:]].*version_" 2>/dev/null)
|
FNAME=$(print -R "${FSCRIPT}" | grep -E -e "^function[[:space:]].*version_" 2>/dev/null)
|
||||||
@ -2048,12 +1786,12 @@ print -n "Dead links: "
|
|||||||
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | while read -r FDIR
|
print "${FPATH}" | tr ':' '\n' 2>/dev/null | grep "core$" 2>/dev/null | while read -r FDIR
|
||||||
do
|
do
|
||||||
# do not use 'find -type l' here!
|
# do not use 'find -type l' here!
|
||||||
# shellcheck disable=SC2010,SC1117,SC2086
|
# shellcheck disable=SC2010,SC1117
|
||||||
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
ls ${FDIR} 2>/dev/null | grep -v "\." 2>/dev/null | while read -r FFILE
|
||||||
do
|
do
|
||||||
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
if [[ -h "${FDIR}/${FFILE}" ]] && [[ ! -f "${FDIR}/${FFILE}" ]]
|
||||||
then
|
then
|
||||||
printf "%s " "${FFILE##*/}"
|
printf "%s " ${FFILE##*/}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -2084,7 +1822,7 @@ then
|
|||||||
then
|
then
|
||||||
print - "$*" | while read -r LOG_LINE
|
print - "$*" | while read -r LOG_LINE
|
||||||
do
|
do
|
||||||
print "${NOW}: INFO: [$$]:" "${LOG_LINE}" >>"${LOG_FILE}"
|
print "${NOW}: INFO: [$$]:" "${LOG_LINE}" >>${LOG_FILE}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if (( ARG_VERBOSE > 0 ))
|
if (( ARG_VERBOSE > 0 ))
|
||||||
@ -2153,7 +1891,7 @@ fi
|
|||||||
|
|
||||||
# save the HC failure message for now
|
# save the HC failure message for now
|
||||||
print "${HC_STC}${MSG_SEP}${HC_NOW}${MSG_SEP}${HC_MSG_TEXT}${MSG_SEP}${HC_MSG_CUR_VAL}${MSG_SEP}${HC_MSG_EXP_VAL}" \
|
print "${HC_STC}${MSG_SEP}${HC_NOW}${MSG_SEP}${HC_MSG_TEXT}${MSG_SEP}${HC_MSG_CUR_VAL}${MSG_SEP}${HC_MSG_EXP_VAL}" \
|
||||||
>>"${HC_MSG_FILE}"
|
>>${HC_MSG_FILE}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -2208,14 +1946,13 @@ awk -F"${LOG_SEP}" '{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' "${HC_LOG}" 2>/dev/null
|
' ${HC_LOG} 2>/dev/null
|
||||||
|
|
||||||
# archived events
|
# archived events
|
||||||
print; print
|
print; print
|
||||||
print -R "--- ARCHIVED events --"
|
print -R "--- ARCHIVED events --"
|
||||||
print
|
print
|
||||||
# shellcheck disable=SC2086
|
find ${ARCHIVE_DIR} -type f -name "hc.*.log" 2>/dev/null | while read -r _ARCHIVE_FILE
|
||||||
find ${ARCHIVE_DIR} -type f -name "hc.*.log" 2>/dev/null | sort -rn 2>/dev/null | while read -r _ARCHIVE_FILE
|
|
||||||
do
|
do
|
||||||
print "${_ARCHIVE_FILE}:"
|
print "${_ARCHIVE_FILE}:"
|
||||||
awk -F"${LOG_SEP}" '{
|
awk -F"${LOG_SEP}" '{
|
||||||
@ -2251,7 +1988,7 @@ do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' "${_ARCHIVE_FILE}" 2>/dev/null
|
' ${_ARCHIVE_FILE} 2>/dev/null
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -2292,7 +2029,7 @@ then
|
|||||||
then
|
then
|
||||||
print - "$*" | while read -r LOG_LINE
|
print - "$*" | while read -r LOG_LINE
|
||||||
do
|
do
|
||||||
print "${NOW}: WARN: [$$]:" "${LOG_LINE}" >>"${LOG_FILE}"
|
print "${NOW}: WARN: [$$]:" "${LOG_LINE}" >>${LOG_FILE}
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if (( ARG_VERBOSE > 0 ))
|
if (( ARG_VERBOSE > 0 ))
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
# RETURNS: 0
|
# RETURNS: 0
|
||||||
function version_include_data
|
function version_include_data
|
||||||
{
|
{
|
||||||
typeset _VERSION="2020-12-27" # YYYY-MM-DD
|
typeset _VERSION="2019-04-20" # YYYY-MM-DD
|
||||||
|
|
||||||
print "INFO: $0: ${_VERSION#version_*}"
|
print "INFO: $0: ${_VERSION#version_*}"
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ typeset _PARAMETER="${1}"
|
|||||||
typeset _LVALUE=""
|
typeset _LVALUE=""
|
||||||
typeset _RC=0
|
typeset _RC=0
|
||||||
|
|
||||||
_LVALUE=$(grep -i "^${_PARAMETER} *=" "${_CONFIG_FILE}" | cut -f2- -d'=')
|
_LVALUE=$(grep -i "^${_PARAMETER} *=" ${_CONFIG_FILE} | cut -f2- -d'=')
|
||||||
|
|
||||||
if [[ -n "${_LVALUE}" ]]
|
if [[ -n "${_LVALUE}" ]]
|
||||||
then
|
then
|
||||||
@ -196,26 +196,6 @@ done
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: data_has_newline()
|
|
||||||
# DOES: checks if a string contains newlines
|
|
||||||
# EXPECTS: $1=haystack [string]
|
|
||||||
# OUTPUTS: n/a
|
|
||||||
# RETURNS: 0=no newline found; 1=newlines found
|
|
||||||
# REQUIRES: n/a
|
|
||||||
function data_has_newline
|
|
||||||
{
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
|
|
||||||
typeset _HAYSTACK="${1}"
|
|
||||||
|
|
||||||
typeset _COUNT=$(print -R "${_HAYSTACK}" | wc -l 2>/dev/null)
|
|
||||||
|
|
||||||
(( _COUNT > 1 )) && return 1
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# @(#) FUNCTION: data_magic_quote()
|
# @(#) FUNCTION: data_magic_quote()
|
||||||
# DOES: magically quotes a needle in a string (default needle is: %)
|
# DOES: magically quotes a needle in a string (default needle is: %)
|
||||||
@ -237,7 +217,7 @@ return 0
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# @(#) FUNCTION: data_magic_unquote()
|
# @(#) FUNCTION: data_magic_unquote()
|
||||||
# DOES: magically unquotes a needle in a string (default needle is: %)
|
# DOES: magically unquotes a needle in a string (default needle is: %)
|
||||||
# EXPECTS: $1=to be magically unquoted [string]; $2=needle [string]
|
# EXPECTS: to be magically unquoted [string]; $2=needle [string]
|
||||||
# OUTPUTS: magically unquoted [string]
|
# OUTPUTS: magically unquoted [string]
|
||||||
# RETURNS: n/a
|
# RETURNS: n/a
|
||||||
# REQUIRES: n/a
|
# REQUIRES: n/a
|
||||||
@ -613,68 +593,6 @@ esac
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: data_expand_numerical_range()
|
|
||||||
# DOES: expand numerical range (X-Y) to comma-separated list of numbers
|
|
||||||
# EXPECTS: $1=numerical range [string]
|
|
||||||
# $2=flag for leading zeroes <10 [0=do not add (default),1=add]
|
|
||||||
# OUTPUTS: [string]
|
|
||||||
# RETURNS: 0=no error occurred; <>0=some error occurred
|
|
||||||
# REQUIRES: n/a
|
|
||||||
function data_expand_numerical_range
|
|
||||||
{
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
typeset _NUM_LIST=""
|
|
||||||
typeset _HAS_LEAD_ZERO=${2:-0}
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
*-*)
|
|
||||||
# range operator, expand
|
|
||||||
# check if there are only 2 operands (fields)
|
|
||||||
if (( $(print "${1}" | awk -F '-' '{ print NF }' 2>/dev/null) > 2 ))
|
|
||||||
then
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "in range $1 found more than one range (-) operator"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# check if X < Y
|
|
||||||
if print "${1}" | awk -F '-' '{ if ($1 < $2) { exit 1 }}' 2>/dev/null
|
|
||||||
then
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "in range $1 operator Y is smaller or equal to operator Y"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# expand list
|
|
||||||
_NUM_LIST=$(print "${1}"| awk -F '-' -v has_lead_zero=${_HAS_LEAD_ZERO} '
|
|
||||||
BEGIN { count = 0; }
|
|
||||||
{
|
|
||||||
while ($1 + count <= $2) {
|
|
||||||
# add leading zero to sprintf when < 10
|
|
||||||
if (has_lead_zero > 0 && $1 + count < 10) { lead_zero = "0" } else { lead_zero = "" }
|
|
||||||
if (length (NUM_LIST) == 0) {
|
|
||||||
NUM_LIST = sprintf ("%" lead_zero "2d", $1 + count);
|
|
||||||
} else {
|
|
||||||
NUM_LIST = sprintf ("%s,%" lead_zero "2d", NUM_LIST, $1 + count); }
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# remove space from end result and print
|
|
||||||
END { gsub(/[[:space:]]/, "", NUM_LIST); print NUM_LIST; }')
|
|
||||||
if [[ -z "${_NUM_LIST}" ]]
|
|
||||||
then
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "range conversion returned empty list"
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
print "${_NUM_LIST}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# no range, return as-is
|
|
||||||
print "${1}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# @(#) FUNCTION: data_encode_url
|
# @(#) FUNCTION: data_encode_url
|
||||||
# DOES: encode URL data
|
# DOES: encode URL data
|
||||||
@ -937,7 +855,6 @@ print ${_EPOCH}
|
|||||||
# REQUIRES: n/a
|
# REQUIRES: n/a
|
||||||
function data_epoch2date
|
function data_epoch2date
|
||||||
{
|
{
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
typeset _UNIX_EPOCH="${1}"
|
typeset _UNIX_EPOCH="${1}"
|
||||||
typeset _CONVERT_DATE=""
|
typeset _CONVERT_DATE=""
|
||||||
|
|
||||||
@ -963,154 +880,6 @@ fi
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: data_timestring_to_days()
|
|
||||||
# DOES: converts a specific timestring to days (rounded to integer)
|
|
||||||
# EXPECTS: time definition with a single s|m|h|d suffix [string]
|
|
||||||
# OUTPUTS: time value in hours [string]
|
|
||||||
# RETURNS: 0=conversion OK; 1=conversion failed
|
|
||||||
# REQUIRES: n/a
|
|
||||||
function data_timestring_to_days
|
|
||||||
{
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
typeset _DAYS=""
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
*s|*s)
|
|
||||||
_DAYS=$(( $(print "${1%*[sS]}") / 60 / 60 / 24 ))
|
|
||||||
;;
|
|
||||||
*m|*M)
|
|
||||||
_DAYS=$(( $(print "${1%*[mM]}") / 60 / 24 ))
|
|
||||||
;;
|
|
||||||
*h|*H)
|
|
||||||
_DAYS=$(( $(print "${1%*[hH]}") / 24 ))
|
|
||||||
;;
|
|
||||||
*d|*D)
|
|
||||||
_DAYS=$(print "${1%*[dD]}")
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# invalid suffix specified
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
print "${_DAYS}"
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: data_timestring_to_hours()
|
|
||||||
# DOES: converts a specific timestring to hours (rounded to integer)
|
|
||||||
# EXPECTS: time definition with a single s|m|h|d suffix [string]
|
|
||||||
# OUTPUTS: time value in hours [string]
|
|
||||||
# RETURNS: 0=conversion OK; 1=conversion failed
|
|
||||||
# REQUIRES: n/a
|
|
||||||
function data_timestring_to_hours
|
|
||||||
{
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
typeset _HOURS=""
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
*s|*s)
|
|
||||||
_HOURS=$(( $(print "${1%*[sS]}") / 60 / 24 ))
|
|
||||||
;;
|
|
||||||
*m|*M)
|
|
||||||
_HOURS=$(( $(print "${1%*[mM]}") / 60 ))
|
|
||||||
;;
|
|
||||||
*h|*H)
|
|
||||||
_HOURS=$(print "${1%*[hH]}")
|
|
||||||
;;
|
|
||||||
*d|*D)
|
|
||||||
_HOURS=$(( $(print "${1%*[dD]}") * 24 ))
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# invalid suffix specified
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
print "${_HOURS}"
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: data_timestring_to_mins()
|
|
||||||
# DOES: converts a specific timestring to minutes (rounded to integer)
|
|
||||||
# EXPECTS: time definition with a single s|m|h|d suffix [string]
|
|
||||||
# OUTPUTS: time value in minutes [string]
|
|
||||||
# RETURNS: 0=conversion OK; 1=conversion failed
|
|
||||||
# REQUIRES: n/a
|
|
||||||
function data_timestring_to_mins
|
|
||||||
{
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
typeset _MINUTES=""
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
*s|*s)
|
|
||||||
_MINUTES=$(( $(print "${1%*[sS]}") / 60 ))
|
|
||||||
;;
|
|
||||||
*m|*M)
|
|
||||||
_MINUTES=$(print "${1%*[mM]}")
|
|
||||||
;;
|
|
||||||
*h|*H)
|
|
||||||
_MINUTES=$(( $(print "${1%*[hH]}") * 60 ))
|
|
||||||
;;
|
|
||||||
*d|*D)
|
|
||||||
_MINUTES=$(( $(print "${1%*[dD]}") * 60 * 24 ))
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# invalid suffix specified
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
print "${_MINUTES}"
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# @(#) FUNCTION: data_timestring_to_secs()
|
|
||||||
# DOES: converts a specific timestring to seconds (rounded to integer)
|
|
||||||
# EXPECTS: time definition with a single m|h|d suffix [string]
|
|
||||||
# OUTPUTS: time value in seconds [string]
|
|
||||||
# RETURNS: 0=conversion OK; 1=conversion failed
|
|
||||||
# REQUIRES: n/a
|
|
||||||
function data_timestring_to_secs
|
|
||||||
{
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
|
||||||
typeset _SECONDS=""
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
*s|*s)
|
|
||||||
_SECONDS=$(print "${1%*[sS]}")
|
|
||||||
;;
|
|
||||||
*m|*M)
|
|
||||||
_SECONDS=$(( $(print "${1%*[Mm]}") * 60 ))
|
|
||||||
;;
|
|
||||||
*h|*H)
|
|
||||||
_SECONDS=$(( $(print "${1%*[hH]}") * 60 * 60 ))
|
|
||||||
;;
|
|
||||||
*d|*D)
|
|
||||||
_SECONDS=$(( $(print "${1%*[dD]}") * 60 * 60 * 24 ))
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# invalid suffix specified
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "invalid time suffix specified (only s[econds]|m[inutes]|h[ours]|d[days] allowed)"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
print "${_SECONDS}"
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
# END of script
|
# END of script
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
@ -30,107 +30,13 @@
|
|||||||
# RETURNS: 0
|
# RETURNS: 0
|
||||||
function version_include_os
|
function version_include_os
|
||||||
{
|
{
|
||||||
typeset _VERSION="2019-07-14" # YYYY-MM-DD
|
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||||
|
|
||||||
print "INFO: $0: ${_VERSION#version_*}"
|
print "INFO: $0: ${_VERSION#version_*}"
|
||||||
|
|
||||||
return 0
|
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()
|
# @(#) FUNCTION: linux_get_distro()
|
||||||
# DOES: get Linux distribution name & version, sets $LINUX_DISTRO & $LINUX_RELEASE
|
# DOES: get Linux distribution name & version, sets $LINUX_DISTRO & $LINUX_RELEASE
|
||||||
@ -212,75 +118,12 @@ elif [[ -r /usr/share/upstart ]]
|
|||||||
then
|
then
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
LINUX_INIT="upstart"
|
LINUX_INIT="upstart"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
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()
|
# @(#) FUNCTION: linux_has_crm()
|
||||||
# DOES: check if Corosync (CRM version) is running
|
# DOES: check if Corosync (CRM version) is running
|
||||||
@ -406,70 +249,30 @@ return ${_RC}
|
|||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# @(#) FUNCTION: linux_runs_service()
|
# @(#) FUNCTION: linux_exec_ssh()
|
||||||
# DOES: check if a specific service is running (active)
|
# DOES: execute a shell command remotely via SSH
|
||||||
# EXPECTS: name of service [string]
|
# EXPECTS: 1=options [string], 2=user [string], 3=host [string], 4=command [string]
|
||||||
# OUTPUTS: 0=not running/not active; 1=running/active
|
# RETURNS: exit code of remote command
|
||||||
# RETURNS: 0=success; 1=error
|
# OUTPUTS: STDOUT from SSH call
|
||||||
# REQUIRES: linux_get_init(), linux_has_systemd_service()
|
# REQUIRES: ssh command-line utility
|
||||||
function linux_runs_service
|
function linux_exec_ssh
|
||||||
{
|
{
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||||
typeset _SERVICE="${1}"
|
typeset _SSH_OPTS="${1}"
|
||||||
typeset _RUNS_SERVICE=0
|
typeset _SSH_USER="${2}"
|
||||||
|
typeset _SSH_HOST="${3}"
|
||||||
|
typeset _SSH_COMMAND="${4}"
|
||||||
|
|
||||||
# linux only
|
if [[ -z "${_SSH_USER}" || -z "${_SSH_HOST}" || -z "${_SSH_COMMAND}" ]]
|
||||||
check_platform 'Linux' || {
|
then
|
||||||
(( ARG_DEBUG > 0 )) && debug "may only run on platform(s): Linux"
|
return 255
|
||||||
return 1
|
fi
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
ssh ${_SSH_OPTS} -l ${_SSH_USER} ${_SSH_HOST} ${_SSH_COMMAND} 2>>${HC_STDERR_LOG} </dev/null
|
||||||
|
|
||||||
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
[[ -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
|
# END of script
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
function notify_mail
|
function notify_mail
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _VERSION="2022-02-16" # YYYY-MM-DD
|
typeset _VERSION="2019-04-20" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -58,7 +58,6 @@ typeset _MAIL_ATTACH_BIT=""
|
|||||||
typeset _MAIL_METHOD=""
|
typeset _MAIL_METHOD=""
|
||||||
typeset _MAIL_RC=0
|
typeset _MAIL_RC=0
|
||||||
typeset _MAILX_BIN=""
|
typeset _MAILX_BIN=""
|
||||||
typeset _MAILX_ATTACH_SWITCH=""
|
|
||||||
typeset _MUTT_BIN=""
|
typeset _MUTT_BIN=""
|
||||||
typeset _SENDMAIL_BIN=""
|
typeset _SENDMAIL_BIN=""
|
||||||
typeset _UUENCODE_BIN=""
|
typeset _UUENCODE_BIN=""
|
||||||
@ -91,17 +90,6 @@ case "${OS_NAME}" in
|
|||||||
if [[ -x ${_MAILX_BIN} ]] && [[ -n "${_MAILX_BIN}" ]]
|
if [[ -x ${_MAILX_BIN} ]] && [[ -n "${_MAILX_BIN}" ]]
|
||||||
then
|
then
|
||||||
_MAIL_METHOD="mailx"
|
_MAIL_METHOD="mailx"
|
||||||
# check which switch we need for attaching a file:
|
|
||||||
# Debian/Ubuntu: -A file
|
|
||||||
# Redhat (Heirloom version): -a file
|
|
||||||
${_MAILX_BIN} -h 2>&1 | grep -q -e "-a FILE" >/dev/null 2>/dev/null
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? == 0 ))
|
|
||||||
then
|
|
||||||
_MAILX_ATTACH_SWITCH="-a "
|
|
||||||
else
|
|
||||||
_MAILX_ATTACH_SWITCH="-A "
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
_MAIL_METHOD="sendmail"
|
_MAIL_METHOD="sendmail"
|
||||||
fi
|
fi
|
||||||
@ -134,18 +122,18 @@ then
|
|||||||
[[ -r "${_MAIL_INFO_TPL}" ]] || die "cannot read mail info template at ${_MAIL_INFO_TPL}"
|
[[ -r "${_MAIL_INFO_TPL}" ]] || die "cannot read mail info template at ${_MAIL_INFO_TPL}"
|
||||||
eval "cat << __EOT
|
eval "cat << __EOT
|
||||||
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_INFO_TPL})
|
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_INFO_TPL})
|
||||||
__EOT" >"${_TMP1_MAIL_FILE}"
|
__EOT" >${_TMP1_MAIL_FILE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create header part
|
# create header part
|
||||||
[[ -r "${_MAIL_HEADER_TPL}" ]] || die "cannot read mail header template at ${_MAIL_HEADER_TPL}"
|
[[ -r "${_MAIL_HEADER_TPL}" ]] || die "cannot read mail header template at ${_MAIL_HEADER_TPL}"
|
||||||
eval "cat << __EOT
|
eval "cat << __EOT
|
||||||
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_HEADER_TPL})
|
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_HEADER_TPL})
|
||||||
__EOT" >>"${_TMP1_MAIL_FILE}"
|
__EOT" >>${_TMP1_MAIL_FILE}
|
||||||
print "" >>"${_TMP1_MAIL_FILE}"
|
print "" >>${_TMP1_MAIL_FILE}
|
||||||
|
|
||||||
# create body part (from $HC_MSG_VAR)
|
# create body part (from $HC_MSG_VAR)
|
||||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read -r _MAIL_MSG_STC _ _MAIL_MSG_TEXT _MAIL_MSG_CUR_VAL _MAIL_MSG_EXP_VAL
|
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _MAIL_MSG_STC _ _MAIL_MSG_TEXT _MAIL_MSG_CUR_VAL _MAIL_MSG_EXP_VAL
|
||||||
do
|
do
|
||||||
# magically unquote if needed
|
# magically unquote if needed
|
||||||
if [[ -n "${_MAIL_MSG_TEXT}" ]]
|
if [[ -n "${_MAIL_MSG_TEXT}" ]]
|
||||||
@ -187,8 +175,8 @@ done
|
|||||||
[[ -r "${_MAIL_BODY_TPL}" ]] || die "cannot read mail body template at ${_MAIL_BODY_TPL}"
|
[[ -r "${_MAIL_BODY_TPL}" ]] || die "cannot read mail body template at ${_MAIL_BODY_TPL}"
|
||||||
eval "cat << __EOT
|
eval "cat << __EOT
|
||||||
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_BODY_TPL})
|
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_BODY_TPL})
|
||||||
__EOT" >>"${_TMP1_MAIL_FILE}"
|
__EOT" >>${_TMP1_MAIL_FILE}
|
||||||
print "" >>"${_TMP1_MAIL_FILE}"
|
print "" >>${_TMP1_MAIL_FILE}
|
||||||
|
|
||||||
# HC STDOUT log? (drop the .$$ bit)
|
# HC STDOUT log? (drop the .$$ bit)
|
||||||
_MAIL_STDOUT_LOG="${EVENTS_DIR}/${DIR_PREFIX}/${_MAIL_FAIL_ID}/${_HC_STDOUT_LOG_SHORT%.*}"
|
_MAIL_STDOUT_LOG="${EVENTS_DIR}/${DIR_PREFIX}/${_MAIL_FAIL_ID}/${_HC_STDOUT_LOG_SHORT%.*}"
|
||||||
@ -196,14 +184,7 @@ if [[ -s "${_MAIL_STDOUT_LOG}" ]]
|
|||||||
then
|
then
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
_MAIL_STDOUT_MSG="${_MAIL_STDOUT_LOG}"
|
_MAIL_STDOUT_MSG="${_MAIL_STDOUT_LOG}"
|
||||||
case "${_MAIL_METHOD}" in
|
|
||||||
"mailx")
|
|
||||||
_MAIL_ATTACH_BIT="${_MAILX_ATTACH_SWITCH} ${_MAIL_STDOUT_LOG}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_MAIL_ATTACH_BIT="-a ${_MAIL_STDOUT_LOG}"
|
_MAIL_ATTACH_BIT="-a ${_MAIL_STDOUT_LOG}"
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
else
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
_MAIL_STDOUT_MSG="no log file available"
|
_MAIL_STDOUT_MSG="no log file available"
|
||||||
@ -214,14 +195,7 @@ if [[ -s "${_MAIL_STDERR_LOG}" ]]
|
|||||||
then
|
then
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
_MAIL_STDERR_MSG="${_MAIL_STDERR_LOG}"
|
_MAIL_STDERR_MSG="${_MAIL_STDERR_LOG}"
|
||||||
case "${_MAIL_METHOD}" in
|
|
||||||
"mailx")
|
|
||||||
_MAIL_ATTACH_BIT="${_MAIL_ATTACH_BIT} ${_MAILX_ATTACH_SWITCH} ${_MAIL_STDERR_LOG}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_MAIL_ATTACH_BIT="${_MAIL_ATTACH_BIT} -a ${_MAIL_STDERR_LOG}"
|
_MAIL_ATTACH_BIT="${_MAIL_ATTACH_BIT} -a ${_MAIL_STDERR_LOG}"
|
||||||
;;
|
|
||||||
esac
|
|
||||||
else
|
else
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
_MAIL_STDERR_MSG="no log file available"
|
_MAIL_STDERR_MSG="no log file available"
|
||||||
@ -231,29 +205,28 @@ fi
|
|||||||
[[ -r ${_MAIL_FOOTER_TPL} ]] || die "cannot read mail body template at ${_MAIL_FOOTER_TPL}"
|
[[ -r ${_MAIL_FOOTER_TPL} ]] || die "cannot read mail body template at ${_MAIL_FOOTER_TPL}"
|
||||||
eval "cat << __EOT
|
eval "cat << __EOT
|
||||||
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_FOOTER_TPL})
|
$(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_FOOTER_TPL})
|
||||||
__EOT" >>"${_TMP1_MAIL_FILE}"
|
__EOT" >>${_TMP1_MAIL_FILE}
|
||||||
|
|
||||||
# combine and send message components
|
# combine and send message components
|
||||||
case "${_MAIL_METHOD}" in
|
case "${_MAIL_METHOD}" in
|
||||||
"mailx")
|
"mailx")
|
||||||
# remove non-ASCII characters to avoid Exchange ATT00001.bin
|
# remove non-ASCII characters to avoid Exchange ATT00001.bin
|
||||||
# shellcheck disable=SC2086
|
cat ${_TMP1_MAIL_FILE} | tr -cd '[:print:]\n' 2>/dev/null |\
|
||||||
tr -cd '[:print:]\n' < "${_TMP1_MAIL_FILE}" 2>/dev/null |\
|
|
||||||
${_MAILX_BIN} ${_MAIL_ATTACH_BIT} -s "${_SUBJ_MSG}" "${ARG_MAIL_TO}"
|
${_MAILX_BIN} ${_MAIL_ATTACH_BIT} -s "${_SUBJ_MSG}" "${ARG_MAIL_TO}"
|
||||||
_MAIL_RC=$?
|
_MAIL_RC=$?
|
||||||
;;
|
;;
|
||||||
"mutt")
|
"mutt")
|
||||||
# attach bit goes at the end
|
# attach bit goes at the end
|
||||||
# shellcheck disable=SC2086
|
cat ${_TMP1_MAIL_FILE} 2>/dev/null |\
|
||||||
${_MUTT_BIN} -s "${_SUBJ_MSG}" "${ARG_MAIL_TO}" ${_MAIL_ATTACH_BIT} <"${_TMP1_MAIL_FILE}"
|
${_MUTT_BIN} -s "${_SUBJ_MSG}" "${ARG_MAIL_TO}" ${_MAIL_ATTACH_BIT}
|
||||||
_MAIL_RC=$?
|
_MAIL_RC=$?
|
||||||
;;
|
;;
|
||||||
"sendmail")
|
"sendmail")
|
||||||
[[ -s "${_MAIL_STDOUT_LOG}" ]] && \
|
[[ -s "${_MAIL_STDOUT_LOG}" ]] && \
|
||||||
uuencode "${_MAIL_STDOUT_LOG}" stdout.log >>"${_TMP2_MAIL_FILE}" 2>/dev/null
|
uuencode ${_MAIL_STDOUT_LOG} stdout.log >>${_TMP2_MAIL_FILE} 2>/dev/null
|
||||||
[[ -s "${_MAIL_STDERR_LOG}" ]] && \
|
[[ -s "${_MAIL_STDERR_LOG}" ]] && \
|
||||||
uuencode "${_MAIL_STDERR_LOG}" stderr.log >>"${_TMP2_MAIL_FILE}" 2>/dev/null
|
uuencode ${_MAIL_STDERR_LOG} stderr.log >>${_TMP2_MAIL_FILE} 2>/dev/null
|
||||||
cat "${_TMP1_MAIL_FILE}" "${_TMP2_MAIL_FILE}" 2>/dev/null | ${_SENDMAIL_BIN} -t
|
cat ${_TMP1_MAIL_FILE} ${_TMP2_MAIL_FILE} 2>/dev/null | ${_SENDMAIL_BIN} -t
|
||||||
_MAIL_RC=$?
|
_MAIL_RC=$?
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -269,8 +242,8 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# clean up temporary files
|
# clean up temporary files
|
||||||
[[ -f ${_TMP1_MAIL_FILE} ]] && rm -f "${_TMP1_MAIL_FILE}" >/dev/null 2>&1
|
[[ -f ${_TMP1_MAIL_FILE} ]] && rm -f ${_TMP1_MAIL_FILE} >/dev/null 2>&1
|
||||||
[[ -f ${_TMP2_MAIL_FILE} ]] && rm -f "${_TMP2_MAIL_FILE}" >/dev/null 2>&1
|
[[ -f ${_TMP2_MAIL_FILE} ]] && rm -f ${_TMP2_MAIL_FILE} >/dev/null 2>&1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1,135 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) notify_slack.sh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2022 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: notify_slack
|
|
||||||
# DOES: send message to slack app
|
|
||||||
# EXPECTS: 1=HC name [string], 2=HC FAIL_ID [string]
|
|
||||||
# RETURNS: 0
|
|
||||||
# REQUIRES: data_contains_string(), data_get_lvalue_from_config(), data_magic_unquote(),
|
|
||||||
# init_hc(), log(), warn(), curl
|
|
||||||
#
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function notify_slack
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/core/providers/$0.conf"
|
|
||||||
typeset _VERSION="2022-10-14" # YYYY-MM-DD
|
|
||||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,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 _SLACK_HC="$1"
|
|
||||||
typeset _SLACK_FAIL_ID="$2"
|
|
||||||
|
|
||||||
typeset _SLACK_TEXT=""
|
|
||||||
typeset _SLACK_MSG_STC=""
|
|
||||||
typeset _SLACK_MSG_TEXT=""
|
|
||||||
typeset _SLACK_MSG_CUR_VAL=""
|
|
||||||
typeset _SLACK_MSG_EXP_VAL=""
|
|
||||||
typeset _CURL_BIN=""
|
|
||||||
typeset _SLACK_WEBHOOK=""
|
|
||||||
|
|
||||||
# handle config file
|
|
||||||
if [[ ! -r ${_CONFIG_FILE} ]]
|
|
||||||
then
|
|
||||||
warn "unable to read configuration file at ${_CONFIG_FILE}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
# read required config values
|
|
||||||
_SLACK_WEBHOOK=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'SLACK_WEBHOOK')
|
|
||||||
if [[ -z "${_SLACK_WEBHOOK}" ]]
|
|
||||||
then
|
|
||||||
warn "no value set for 'SLACK_WEBHOOK' in ${_CONFIG_FILE}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# create header part
|
|
||||||
_SLACK_TEXT="${EXEC_USER}@${HOST_NAME}: HC ${_SLACK_HC} failed, FAIL_ID=${_SLACK_FAIL_ID}"
|
|
||||||
|
|
||||||
# create body part (from $HC_MSG_VAR)
|
|
||||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read -r _SLACK_MSG_STC _ _SLACK_MSG_TEXT _SLACK_MSG_CUR_VAL _SLACK_MSG_EXP_VAL
|
|
||||||
do
|
|
||||||
# magically unquote if needed
|
|
||||||
if [[ -n "${_SLACK_MSG_TEXT}" ]]
|
|
||||||
then
|
|
||||||
data_contains_string "${_SLACK_MSG_TEXT}" "${MAGIC_QUOTE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
_SLACK_MSG_TEXT=$(data_magic_unquote "${_SLACK_MSG_TEXT}")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ -n "${_SLACK_MSG_CUR_VAL}" ]]
|
|
||||||
then
|
|
||||||
data_contains_string "${_SLACK_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
_SLACK_MSG_CUR_VAL=$(data_magic_unquote "${_SLACK_MSG_CUR_VAL}")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ -n "${_SLACK_MSG_EXP_VAL}" ]]
|
|
||||||
then
|
|
||||||
data_contains_string "${_SLACK_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
_SLACK_MSG_EXP_VAL=$(data_magic_unquote "${_SLACK_MSG_EXP_VAL}")
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if (( _SLACK_MSG_STC > 0 ))
|
|
||||||
then
|
|
||||||
# shellcheck disable=SC1117
|
|
||||||
_SLACK_BODY=$(printf "%s\n%s\n" "${_SLACK_BODY}" "${_SLACK_MSG_TEXT}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# send message
|
|
||||||
# find 'curl'
|
|
||||||
_CURL_BIN="$(command -v curl 2>/dev/null)"
|
|
||||||
if [[ -x ${_CURL_BIN} ]] && [[ -n "${_CURL_BIN}" ]]
|
|
||||||
then
|
|
||||||
if (( ARG_DEBUG == 0 ))
|
|
||||||
then
|
|
||||||
${_CURL_BIN} --silent --data-urlencode \
|
|
||||||
"$(printf 'payload={"text": "%s\n\n%s" }' "${_SLACK_TEXT}" "${_SLACK_BODY}")" \
|
|
||||||
"${_SLACK_WEBHOOK}" >/dev/null 2>&1
|
|
||||||
else
|
|
||||||
${_CURL_BIN} --data-urlencode \
|
|
||||||
"$(printf 'payload={"text": "%s\n\n%s" }' "${_SLACK_TEXT}" "${_SLACK_BODY}")" \
|
|
||||||
"${_SLACK_WEBHOOK}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
die "unable to send message to Slack - curl is not installed here"
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "Slack alert sent: ${_SLACK_HC} failed, FAIL_ID=${_SLACK_FAIL_ID}"
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -20,8 +20,7 @@
|
|||||||
# DOES: send sms alert
|
# DOES: send sms alert
|
||||||
# EXPECTS: 1=HC name [string], 2=HC FAIL_ID [string]
|
# EXPECTS: 1=HC name [string], 2=HC FAIL_ID [string]
|
||||||
# RETURNS: 0
|
# RETURNS: 0
|
||||||
# REQUIRES: data_encode_url(), data_get_lvalue_from_config(), init_hc(),
|
# REQUIRES: data_get_lvalue_from_config(), init_hc(), log(), warn()
|
||||||
# log(), warn(), curl
|
|
||||||
#
|
#
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
@ -32,7 +31,7 @@ function notify_sms
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/core/providers/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/core/providers/$0.conf"
|
||||||
typeset _VERSION="2022-10-14" # YYYY-MM-DD
|
typeset _VERSION="2018-10-28" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
function report_std
|
function report_std
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _VERSION="2020-04-08" # YYYY-MM-DD
|
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -59,14 +59,8 @@ typeset _OLDER_MONTH=""
|
|||||||
typeset _OLDER_YEAR=""
|
typeset _OLDER_YEAR=""
|
||||||
typeset _NEWER_MONTH=""
|
typeset _NEWER_MONTH=""
|
||||||
typeset _NEWER_YEAR=""
|
typeset _NEWER_YEAR=""
|
||||||
typeset _HC_REPORT_CACHE_LAST_STUB="${STATE_PERM_DIR}/cache.report-last"
|
|
||||||
typeset _HC_REPORT_CACHE_LAST_FILE=""
|
|
||||||
typeset _HC_REPORT_CACHE_TODAY_FILE="${STATE_PERM_DIR}/cache.report-today"
|
|
||||||
typeset _USE_CACHE=0
|
|
||||||
typeset _USE_ANY_CACHE=0
|
|
||||||
typeset _CACHE_NOTE_BIT=""
|
|
||||||
|
|
||||||
# set archive log stash (never use cache files)
|
# set archive log stash
|
||||||
if (( ARG_HISTORY > 0 )) || [[ -n "${ARG_OLDER}" ]] || [[ -n "${ARG_NEWER}" ]]
|
if (( ARG_HISTORY > 0 )) || [[ -n "${ARG_OLDER}" ]] || [[ -n "${ARG_NEWER}" ]]
|
||||||
then
|
then
|
||||||
set +f # file globbing must be on
|
set +f # file globbing must be on
|
||||||
@ -154,46 +148,10 @@ then
|
|||||||
_HC_LAST_TIME=""
|
_HC_LAST_TIME=""
|
||||||
_HC_LAST_STC=0
|
_HC_LAST_STC=0
|
||||||
_HC_LAST_FAIL_ID="-"
|
_HC_LAST_FAIL_ID="-"
|
||||||
_USE_CACHE=0
|
|
||||||
|
|
||||||
# check for cache usage
|
|
||||||
if (( ARG_HISTORY == 0 ))
|
|
||||||
then
|
|
||||||
case "${HC_REPORT_CACHE_LAST}" in
|
|
||||||
Yes|yes|YES)
|
|
||||||
_HC_REPORT_CACHE_LAST_FILE="${_HC_REPORT_CACHE_LAST_STUB}-${_HC_LAST}"
|
|
||||||
# check if cache file exists
|
|
||||||
if [[ -s "${_HC_REPORT_CACHE_LAST_FILE}" ]]
|
|
||||||
then
|
|
||||||
_LOG_STASH="${_HC_REPORT_CACHE_LAST_FILE}"
|
|
||||||
_USE_CACHE=1
|
|
||||||
_USE_ANY_CACHE=1
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "setting log stash to cache file at ${_HC_REPORT_CACHE_LAST_FILE}"
|
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "HC_REPORT_CACHE_LAST is enabled but unable to find cache file at ${_HC_REPORT_CACHE_LAST_FILE}"
|
|
||||||
# reset log stash to current log
|
|
||||||
_LOG_STASH="${HC_LOG} ${_LOG_STASH}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# no caching: reset log stash to current log
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "HC_REPORT_CACHE_LAST is disabled"
|
|
||||||
_LOG_STASH="${HC_LOG} ${_LOG_STASH}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# determine LAST_TIME from cache or log(s)
|
|
||||||
if (( ARG_HISTORY == 0 )) && (( _USE_CACHE > 1 ))
|
|
||||||
then
|
|
||||||
_HC_LAST_TIME="$(tail -n 1 ${_LOG_STASH} 2>/dev/null | cut -f1 -d${LOG_SEP} 2>/dev/null)"
|
|
||||||
else
|
|
||||||
# find last event or block of events (same timestamp)
|
# find last event or block of events (same timestamp)
|
||||||
# (but unfortunately this is only accurate to events within the SAME second!)
|
# (but unfortunately this is only accurate to events within the SAME second!)
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
_HC_LAST_TIME="$(grep -h ${_HC_LAST} ${_LOG_STASH} 2>/dev/null | sort -n 2>/dev/null | cut -f1 -d${LOG_SEP} 2>/dev/null | uniq 2>/dev/null | tail -1 2>/dev/null)"
|
_HC_LAST_TIME="$(grep -h ${_HC_LAST} ${_LOG_STASH} 2>/dev/null | sort -n 2>/dev/null | cut -f1 -d${LOG_SEP} 2>/dev/null | uniq 2>/dev/null | tail -1 2>/dev/null)"
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z "${_HC_LAST_TIME}" ]]
|
if [[ -z "${_HC_LAST_TIME}" ]]
|
||||||
then
|
then
|
||||||
_HC_LAST_TIME="-"
|
_HC_LAST_TIME="-"
|
||||||
@ -223,26 +181,12 @@ then
|
|||||||
fi
|
fi
|
||||||
# report on findings
|
# report on findings
|
||||||
# shellcheck disable=SC1117
|
# shellcheck disable=SC1117
|
||||||
if (( _USE_CACHE > 0 ))
|
|
||||||
then
|
|
||||||
printf "| %-40s | %-20s | %-14s | %-4s (C)\n" \
|
|
||||||
"${_HC_LAST}" "${_HC_LAST_TIME}" "${_HC_LAST_FAIL_ID}" "${_HC_LAST_STC}"
|
|
||||||
else
|
|
||||||
printf "| %-40s | %-20s | %-14s | %-4s\n" \
|
printf "| %-40s | %-20s | %-14s | %-4s\n" \
|
||||||
"${_HC_LAST}" "${_HC_LAST_TIME}" "${_HC_LAST_FAIL_ID}" "${_HC_LAST_STC}"
|
"${_HC_LAST}" "${_HC_LAST_TIME}" "${_HC_LAST_FAIL_ID}" "${_HC_LAST_STC}"
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
# spacer
|
# disclaimer
|
||||||
print
|
print "NOTE: this report only shows the overall combined status of all events of each HC within exactly"
|
||||||
# disclaimer & note(s)
|
print " the *same* time stamp (seconds precise). It may therefore fail to report certain FAIL IDs."
|
||||||
if (( _USE_ANY_CACHE > 0 ))
|
|
||||||
then
|
|
||||||
print "NOTE: entries suffixed by (C) indicate results were retrieved from a cache file. If you wish to use "
|
|
||||||
print " the real log files then disable HC_REPORT_CACHE_LAST in ${CONFIG_FILE}"
|
|
||||||
fi
|
|
||||||
(( ARG_HISTORY == 0 )) && _CACHE_NOTE_BIT="for non-cached entries: "
|
|
||||||
print "NOTE: ${_CACHE_NOTE_BIT}this report only shows the overall combined status of all events of each HC"
|
|
||||||
print " within exactly the *same* time stamp (seconds precise). It may therefore fail to report certain FAIL IDs."
|
|
||||||
print " Use '--report' to get the exact list of failure events."
|
print " Use '--report' to get the exact list of failure events."
|
||||||
# other reports
|
# other reports
|
||||||
else
|
else
|
||||||
@ -254,31 +198,7 @@ else
|
|||||||
(( _IS_VALID_ID > 0 )) || die "invalid ID specified"
|
(( _IS_VALID_ID > 0 )) || die "invalid ID specified"
|
||||||
_ID_NEEDLE="${ARG_FAIL_ID}"
|
_ID_NEEDLE="${ARG_FAIL_ID}"
|
||||||
fi
|
fi
|
||||||
# set today's needle and check cache usage
|
(( ARG_TODAY > 0 )) && _ID_NEEDLE="$(date '+%Y%m%d')" # refers to timestamp of HC FAIL_ID
|
||||||
if (( ARG_TODAY > 0 ))
|
|
||||||
then
|
|
||||||
_ID_NEEDLE="$(date '+%Y%m%d')" # refers to timestamp of HC FAIL_ID
|
|
||||||
# do not use a cache file when --with-history
|
|
||||||
if (( ARG_HISTORY == 0 ))
|
|
||||||
then
|
|
||||||
case "${HC_REPORT_CACHE_TODAY}" in
|
|
||||||
Yes|yes|YES)
|
|
||||||
# check if cache file exists
|
|
||||||
if [[ -s "${_HC_REPORT_CACHE_TODAY_FILE}" ]]
|
|
||||||
then
|
|
||||||
_LOG_STASH="${_HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
_USE_CACHE=1
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "setting log stash to today's cache file at ${_HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "HC_REPORT_CACHE_TODAY is enabled but unable to find cache file at ${_HC_REPORT_CACHE_TODAY_FILE}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "HC_REPORT_CACHE_TODAY is disabled"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# reverse?
|
# reverse?
|
||||||
if (( ARG_REVERSE == 0 ))
|
if (( ARG_REVERSE == 0 ))
|
||||||
@ -342,9 +262,9 @@ else
|
|||||||
split (events[i], event, "|");
|
split (events[i], event, "|");
|
||||||
printf ("\n| %-20s | %-14s | %-40s | %-s", event[1], event[5], event[2], event[4]);
|
printf ("\n| %-20s | %-14s | %-40s | %-s", event[1], event[5], event[2], event[4]);
|
||||||
}
|
}
|
||||||
printf ("\n\nSUMMARY: %s failed HC event(s) found.\n\n", event_count);
|
printf ("\n\nSUMMARY: %s failed HC event(s) found.\n", event_count);
|
||||||
} else {
|
} else {
|
||||||
printf ("\nSUMMARY: 0 failed HC events found.\n\n");
|
printf ("\nSUMMARY: 0 failed HC events found.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
' 2>/dev/null
|
' 2>/dev/null
|
||||||
@ -396,28 +316,17 @@ else
|
|||||||
# shellcheck disable=SC2183,SC1117
|
# shellcheck disable=SC2183,SC1117
|
||||||
printf "%80s\n" | tr ' ' -
|
printf "%80s\n" | tr ' ' -
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add notes
|
|
||||||
# cache or not?
|
|
||||||
if (( _USE_CACHE > 0 ))
|
|
||||||
then
|
|
||||||
print "NOTE: results were retrieved from a cache file. If you wish to use the real log files then"
|
|
||||||
print " remove ${_HC_REPORT_CACHE_TODAY_FILE} and/or disable HC_REPORT_CACHE_TODAY in ${CONFIG_FILE}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# add general notes
|
# general note: history or not?
|
||||||
# history or not?
|
|
||||||
if (( ARG_HISTORY > 0 ))
|
if (( ARG_HISTORY > 0 ))
|
||||||
then
|
then
|
||||||
print "NOTE: showing results with all history (archive) included (--with-history)"
|
print "NOTE: showing results with all history (archive) included (--with-history)"
|
||||||
else
|
else
|
||||||
print "NOTE: showing only results of current entries (use --with-history to view all entries)"
|
print "NOTE: showing results only of current log entries (use --with-history to view all entries)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check consistency of log(s)
|
# check consistency of log(s)
|
||||||
# note: should no longer be necessary as of release 19/05/2019 but we keep the
|
|
||||||
# check alive for now
|
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
find ${_LOG_STASH} -type f -print 2>/dev/null | while read -r _CHECK_FILE
|
find ${_LOG_STASH} -type f -print 2>/dev/null | while read -r _CHECK_FILE
|
||||||
do
|
do
|
||||||
|
@ -29,8 +29,6 @@
|
|||||||
# @(#) 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]
|
||||||
# @(#) 2020-09-05: fix log_hc call for failed checksum + quote fix [Patrick Van der Veken]
|
|
||||||
# @(#) 2021-01-13: fix log_hc call (wrong logic) [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 +38,7 @@ function check_aix_file_change
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2021-01-13" # YYYY-MM-DD
|
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -277,7 +275,7 @@ do
|
|||||||
openssl-sha256)
|
openssl-sha256)
|
||||||
if (( _USE_OPENSSL == 1 ))
|
if (( _USE_OPENSSL == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
||||||
_FILE_TYPE="openssl-sha256"
|
_FILE_TYPE="openssl-sha256"
|
||||||
else
|
else
|
||||||
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
||||||
@ -287,7 +285,7 @@ do
|
|||||||
cksum-crc32)
|
cksum-crc32)
|
||||||
if (( _USE_CKSUM == 1 ))
|
if (( _USE_CKSUM == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_CKSUM_BIN} "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
_FILE_CKSUM=$(${_CKSUM_BIN} ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
||||||
_FILE_TYPE="cksum-crc32"
|
_FILE_TYPE="cksum-crc32"
|
||||||
else
|
else
|
||||||
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
||||||
@ -303,11 +301,11 @@ do
|
|||||||
# new file
|
# new file
|
||||||
if (( _USE_OPENSSL == 1 ))
|
if (( _USE_OPENSSL == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
||||||
_FILE_TYPE="openssl-sha256"
|
_FILE_TYPE="openssl-sha256"
|
||||||
elif (( _USE_CKSUM == 1 ))
|
elif (( _USE_CKSUM == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_CKSUM_BIN} "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
_FILE_CKSUM=$(${_CKSUM_BIN} ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
||||||
_FILE_TYPE="cksum-crc32"
|
_FILE_TYPE="cksum-crc32"
|
||||||
else
|
else
|
||||||
_MSG="cannot compute checksum (openssl/cksum) for ${_FILE_TO_CHECK}"
|
_MSG="cannot compute checksum (openssl/cksum) for ${_FILE_TO_CHECK}"
|
||||||
@ -323,7 +321,7 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# bounce failures back and jump to next file
|
# bounce failures back and jump to next file
|
||||||
if (( _LOG_HEALTHY > 0 && _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
continue
|
continue
|
||||||
@ -349,7 +347,7 @@ do
|
|||||||
printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE}
|
printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE}
|
||||||
|
|
||||||
# report with curr/exp values
|
# report with curr/exp values
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}"
|
||||||
continue
|
continue
|
||||||
|
@ -1,349 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# @(#) check_aix_uptime
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# @(#) Copyright (C) 2020 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_aix_uptime
|
|
||||||
# DOES: see _show_usage()
|
|
||||||
# EXPECTS: see _show_usage()
|
|
||||||
# REQUIRES: data_is_numeric(), data_timestring_to_mins(), data_comma2space(),
|
|
||||||
# init_hc(), log_hc(), warn()
|
|
||||||
#
|
|
||||||
# @(#) HISTORY:
|
|
||||||
# @(#) 2020-12-21: initial version [Patrick Van der Veken]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function check_aix_uptime
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
|
||||||
typeset _STATE_FILE="${STATE_PERM_DIR}/current.uptime"
|
|
||||||
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
|
||||||
typeset _SUPPORTED_PLATFORMS="AIX" # 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 _LOG_HEALTHY=0
|
|
||||||
typeset _CFG_HEALTHY=""
|
|
||||||
typeset _CFG_CHECK_REBOOT=""
|
|
||||||
typeset _CFG_REBOOT_TIME=""
|
|
||||||
typeset _CFG_CHECK_OLD_AGE=""
|
|
||||||
typeset _CFG_OLD_AGE_TIME=""
|
|
||||||
typeset _CHECK_REBOOT=""
|
|
||||||
typeset _REBOOT_TIME=""
|
|
||||||
typeset _REBOOT_TIME_MINS=""
|
|
||||||
typeset _CHECK_OLD_AGE=""
|
|
||||||
typeset _OLD_AGE_TIME=""
|
|
||||||
typeset _OLD_AGE_TIME_MINS=""
|
|
||||||
typeset _CURRENT_UPTIME=""
|
|
||||||
typeset _CURRENT_UPTIME_MINS=""
|
|
||||||
typeset _INIT_TIME=""
|
|
||||||
typeset _PREVIOUS_UPTIME=""
|
|
||||||
typeset _PREVIOUS_UPTIME_MINS=""
|
|
||||||
typeset _THRESHOLD_UPTIME_MINS=""
|
|
||||||
|
|
||||||
# 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 config 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 required config values
|
|
||||||
_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
|
|
||||||
_CFG_CHECK_REBOOT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_reboot')
|
|
||||||
case "${_CFG_CHECK_REBOOT}" in
|
|
||||||
no|No|NO)
|
|
||||||
_CHECK_REBOOT=0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_CHECK_REBOOT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
_CFG_REBOOT_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'reboot_time')
|
|
||||||
if [[ -z "${_CFG_REBOOT_TIME}" ]]
|
|
||||||
then
|
|
||||||
# default
|
|
||||||
_REBOOT_TIME="60m"
|
|
||||||
else
|
|
||||||
_REBOOT_TIME="${_CFG_REBOOT_TIME}"
|
|
||||||
fi
|
|
||||||
_CFG_CHECK_OLD_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_old_age')
|
|
||||||
case "${_CFG_CHECK_OLD_AGE}" in
|
|
||||||
yes|Yes|Yes)
|
|
||||||
_CHECK_OLD_AGE=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_CHECK_OLD_AGE=0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
_CFG_OLD_AGE_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'old_age_time')
|
|
||||||
if [[ -z "${_CFG_OLD_AGE_TIME}" ]]
|
|
||||||
then
|
|
||||||
# default
|
|
||||||
_OLD_AGE_TIME="365d"
|
|
||||||
else
|
|
||||||
_OLD_AGE_TIME="${_CFG_OLD_AGE_TIME}"
|
|
||||||
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
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# read uptime from init process
|
|
||||||
# shellcheck disable=SC1007
|
|
||||||
_INIT_TIME=$(UNIX95= ps -p 1 -o etime 2>/dev/null | tail -1)
|
|
||||||
if [[ -n "${_INIT_TIME}" ]]
|
|
||||||
then
|
|
||||||
# calculate exact uptime (seconds)
|
|
||||||
_CURRENT_UPTIME=$(print "${_INIT_TIME}" |\
|
|
||||||
awk '
|
|
||||||
BEGIN { days = 0; hours = 0; mins = 0; seconds = 0 };
|
|
||||||
{
|
|
||||||
gsub(/[ \t]/, "");
|
|
||||||
# get days
|
|
||||||
split ($0, day_str, "-");
|
|
||||||
if (2 in day_str) {
|
|
||||||
# string has days
|
|
||||||
days = day_str[1];
|
|
||||||
split (day_str[2], hour_str, ":");
|
|
||||||
} else {
|
|
||||||
split (day_str[1], hour_str, ":");
|
|
||||||
}
|
|
||||||
# get hours/minutes/seconds
|
|
||||||
hours = hour_str[1];
|
|
||||||
mins = hour_str[2];
|
|
||||||
if (3 in hour_str) {
|
|
||||||
# string has seconds
|
|
||||||
secs = hour_str[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END {
|
|
||||||
time = (days * 24 * 60 * 60) + (hours * 60 * 60) + (mins * 60) + secs;
|
|
||||||
print time;
|
|
||||||
}' 2>/dev/null)
|
|
||||||
data_is_numeric "${_CURRENT_UPTIME}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate uptime value (seconds)"
|
|
||||||
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME=${_CURRENT_UPTIME}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "uptime of INIT (1) process cannot be determined"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# read state file
|
|
||||||
if [[ -r ${_STATE_FILE} ]]
|
|
||||||
then
|
|
||||||
_PREVIOUS_UPTIME=$(<"${_STATE_FILE}")
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "failed to read state file at ${_STATE_FILE}"
|
|
||||||
_PREVIOUS_UPTIME=""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# convert uptimes values
|
|
||||||
_CURRENT_UPTIME_MINS=$(( _CURRENT_UPTIME / 60 ))
|
|
||||||
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate current uptime value (minutes)"
|
|
||||||
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME_MINS=${_CURRENT_UPTIME_MINS}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_PREVIOUS_UPTIME_MINS=$(( _PREVIOUS_UPTIME / 60 ))
|
|
||||||
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate previous uptime value (minutes)"
|
|
||||||
(( ARG_DEBUG )) && debug "_PREVIOUS_UPTIME_MINS=${_PREVIOUS_UPTIME_MINS}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# check reboot event
|
|
||||||
if (( _CHECK_REBOOT > 0 ))
|
|
||||||
then
|
|
||||||
# convert _REBOOT_TIME to minutes
|
|
||||||
_REBOOT_TIME_MINS=$(data_timestring_to_mins "${_REBOOT_TIME}")
|
|
||||||
data_is_numeric "${_REBOOT_TIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate 'reboot_time' value from configuration file ${_CONFIG_FILE}"
|
|
||||||
(( ARG_DEBUG )) && debug "_REBOOT_TIME=${_REBOOT_TIME}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# previous uptime missing?
|
|
||||||
if [[ -z "${_PREVIOUS_UPTIME}" ]]
|
|
||||||
then
|
|
||||||
if (( ARG_LOG > 0 ))
|
|
||||||
then
|
|
||||||
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "failed to update state file at ${_STATE_FILE}"
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
log "unable to find previously recorded uptime, resetting to current uptime"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "unable to find previously recorded uptime, resetting to current uptime"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# current uptime + reboot time is smaller than previous uptime?
|
|
||||||
_THRESHOLD_UPTIME_MINS=$(( _CURRENT_UPTIME_MINS + _REBOOT_TIME_MINS ))
|
|
||||||
if (( _THRESHOLD_UPTIME_MINS < _PREVIOUS_UPTIME_MINS ))
|
|
||||||
then
|
|
||||||
_MSG="reboot check: current uptime is NOK; check if reboot occurred"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="reboot check: current uptime is OK"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_THRESHOLD_UPTIME_MINS}" "${_PREVIOUS_UPTIME_MINS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# update state file
|
|
||||||
if (( ARG_LOG > 0 ))
|
|
||||||
then
|
|
||||||
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "failed to update state file at ${_STATE_FILE}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "reboot check: not enabled"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# check old age event
|
|
||||||
if (( _CHECK_OLD_AGE > 0 ))
|
|
||||||
then
|
|
||||||
# convert _OLD_AGE_TIME to minutes
|
|
||||||
_OLD_AGE_TIME_MINS=$(data_timestring_to_mins "${_OLD_AGE_TIME}")
|
|
||||||
data_is_numeric "${_OLD_AGE_TIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate 'old_age_time' value from configuration file ${_CONFIG_FILE}"
|
|
||||||
(( ARG_DEBUG )) && debug "_OLD_AGE_TIME=${_OLD_AGE_TIME}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# are we old age yet?
|
|
||||||
if (( _CURRENT_UPTIME_MINS > _OLD_AGE_TIME_MINS ))
|
|
||||||
then
|
|
||||||
_MSG="old_age check: current uptime is NOK; old age has arrived (>${_OLD_AGE_TIME})"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="old_age check: current uptime is OK"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_CURRENT_UPTIME_MINS}" "${_OLD_AGE_TIME_MINS}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "old age check: not enabled"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function _show_usage
|
|
||||||
{
|
|
||||||
cat <<- EOT
|
|
||||||
NAME : $1
|
|
||||||
VERSION : $2
|
|
||||||
CONFIG : $3 with:
|
|
||||||
log_healthy=<yes|no>
|
|
||||||
check_reboot=<yes|no>
|
|
||||||
reboot_time=<timestring>
|
|
||||||
check_old_age=<yes|no>
|
|
||||||
old_age_time=<timestring>
|
|
||||||
PURPOSE : Checks for unexpected/unplanned reboot events based on uptime
|
|
||||||
values.
|
|
||||||
Checks whether the host has been up and running for too much time.
|
|
||||||
LOG HEALTHY : Supported
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# END of script
|
|
||||||
#------------------------------------------------------------------------------
|
|
@ -19,15 +19,11 @@
|
|||||||
# @(#) MAIN: check_exadata_cell_megaraid
|
# @(#) MAIN: check_exadata_cell_megaraid
|
||||||
# DOES: see _show_usage()
|
# DOES: see _show_usage()
|
||||||
# EXPECTS: see _show_usage()
|
# EXPECTS: see _show_usage()
|
||||||
# REQUIRES: data_comma2space(), data_comma2newline(), data_contains_string(),
|
# REQUIRES: data_comma2space(), data_comma2newline(), data_get_lvalue_from_config,
|
||||||
# data_get_lvalue_from_config, dump_logs(), exadata_exec_dcli(),
|
# dump_logs(), exadata_exec_dcli(), init_hc(), log_hc(), warn()
|
||||||
# init_hc(), log_hc(), warn()
|
|
||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2019-05-14: initial version [Patrick Van der Veken]
|
# @(#) 2019-05-14: initial version [Patrick Van der Veken]
|
||||||
# @(#) 2019-07-08: update _CELL_COMMAND [Patrick Van der Veken]
|
|
||||||
# @(#) 2019-07-18: added supercap check, see Oracle bug 28564584 + exclusion
|
|
||||||
# logic for components (cell_exclude) [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,11 +33,10 @@ function check_exadata_cell_megaraid
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2019-07-18" # YYYY-MM-DD
|
typeset _VERSION="2019-05-14" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# cell query command -- DO NOT CHANGE --
|
# cell query command -- DO NOT CHANGE --
|
||||||
typeset _CELL_COMMAND="/opt/MegaRAID/storcli/storcli64 -ShowSummary -aALL"
|
typeset _CELL_COMMAND="/opt/MegaRAID/MegaCli/MegaCli64 -ShowSummary -aALL"
|
||||||
typeset _SUPERCAP_COMMAND="/opt/MegaRAID/storcli/storcli64 /c0/cv show all"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
@ -60,19 +55,15 @@ typeset _CFG_CHECK_CONTROLLER=""
|
|||||||
typeset _CHECK_CONTROLLER=0
|
typeset _CHECK_CONTROLLER=0
|
||||||
typeset _CFG_CHECK_BBU=""
|
typeset _CFG_CHECK_BBU=""
|
||||||
typeset _CHECK_BBU=0
|
typeset _CHECK_BBU=0
|
||||||
typeset _CFG_CHECK_SUPERCAP=""
|
|
||||||
typeset _CHECK_SUPERCAP=0
|
|
||||||
typeset _CFG_CHECK_PHYSICAL=""
|
typeset _CFG_CHECK_PHYSICAL=""
|
||||||
typeset _CHECK_PHYSICAL=0
|
typeset _CHECK_PHYSICAL=0
|
||||||
typeset _CFG_CHECK_VIRTUAL=""
|
typeset _CFG_CHECK_VIRTUAL=""
|
||||||
typeset _CHECK_VIRTUAL=0
|
typeset _CHECK_VIRTUAL=0
|
||||||
typeset _CFG_EXCLUDES=""
|
|
||||||
typeset _CELL_OUTPUT=""
|
typeset _CELL_OUTPUT=""
|
||||||
typeset _CELL_DATA=""
|
typeset _CELL_DATA=""
|
||||||
typeset _RAID_DEVICE=""
|
typeset _RAID_DEVICE=""
|
||||||
typeset _RAID_DEVICE_TYPE=""
|
typeset _RAID_DEVICE_TYPE=""
|
||||||
typeset _RAID_STATUS=""
|
typeset _RAID_STATUS=""
|
||||||
typeset _SUPERCAP_STATUS=""
|
|
||||||
typeset _CELL_ALL_RC=0
|
typeset _CELL_ALL_RC=0
|
||||||
typeset _CELL_RC=0
|
typeset _CELL_RC=0
|
||||||
|
|
||||||
@ -135,17 +126,7 @@ case "${_CFG_CHECK_BBU}" in
|
|||||||
_CHECK_BBU=1
|
_CHECK_BBU=1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
(( _CHECK_BBU > 0 )) || log "checking bbu (battery) has been disabled"
|
(( _CHECK_BBU > 0 )) || log "checking bbu has been disabled"
|
||||||
_CFG_CHECK_SUPERCAP=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_supercap')
|
|
||||||
case "${_CFG_CHECK_SUPERCAP}" in
|
|
||||||
no|NO|No)
|
|
||||||
_CHECK_SUPERCAP=0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_CHECK_SUPERCAP=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
(( _CHECK_SUPERCAP > 0 )) || log "checking bbu (supercap) has been disabled"
|
|
||||||
_CFG_CHECK_PHYSICAL=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_physical')
|
_CFG_CHECK_PHYSICAL=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_physical')
|
||||||
case "${_CFG_CHECK_PHYSICAL}" in
|
case "${_CFG_CHECK_PHYSICAL}" in
|
||||||
no|NO|No)
|
no|NO|No)
|
||||||
@ -166,7 +147,6 @@ case "${_CFG_CHECK_VIRTUAL}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
(( _CHECK_VIRTUAL > 0 )) || log "checking virtual has been disabled"
|
(( _CHECK_VIRTUAL > 0 )) || log "checking virtual has been disabled"
|
||||||
_CFG_EXCLUDES=$(grep -i -E -e '^cell_exclude:' ${_CONFIG_FILE} 2>/dev/null)
|
|
||||||
|
|
||||||
# log_healthy
|
# log_healthy
|
||||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
@ -290,10 +270,6 @@ do
|
|||||||
case "${_RAID_DEVICE_TYPE}" in
|
case "${_RAID_DEVICE_TYPE}" in
|
||||||
CONTROLLER)
|
CONTROLLER)
|
||||||
if (( _CHECK_CONTROLLER > 0 ))
|
if (( _CHECK_CONTROLLER > 0 ))
|
||||||
then
|
|
||||||
# check for exclusion
|
|
||||||
$(data_contains_string "${_CFG_EXCLUDES}" "${_CELL_SERVER}:controller")
|
|
||||||
if (( $? == 0 ))
|
|
||||||
then
|
then
|
||||||
_TARGET_STATUS="Optimal"
|
_TARGET_STATUS="Optimal"
|
||||||
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
||||||
@ -309,26 +285,19 @@ do
|
|||||||
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
(( ARG_DEBUG > 0 )) && debug "excluded check for controller on ${_CELL_SERVER}"
|
(( ARG_DEBUG > 0 )) && debug "skipping check for controller (disabled)"
|
||||||
fi
|
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "skipping check for controller (disabled) [${_CELL_SERVER}]"
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
BBU)
|
BBU)
|
||||||
if (( _CHECK_BBU > 0 ))
|
if (( _CHECK_BBU > 0 ))
|
||||||
then
|
|
||||||
# check for exclusion
|
|
||||||
$(data_contains_string "${_CFG_EXCLUDES}" "${_CELL_SERVER}:bbu")
|
|
||||||
if (( $? == 0 ))
|
|
||||||
then
|
then
|
||||||
_TARGET_STATUS="Healthy"
|
_TARGET_STATUS="Healthy"
|
||||||
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
||||||
then
|
then
|
||||||
_MSG="state of bbu (battery) on ${_CELL_SERVER} is NOK (${_RAID_STATUS}!=${_TARGET_STATUS})"
|
_MSG="state of bbu on ${_CELL_SERVER} is NOK (${_RAID_STATUS}!=${_TARGET_STATUS})"
|
||||||
_STC=1
|
_STC=1
|
||||||
else
|
else
|
||||||
_MSG="state of bbu (battery) on ${_CELL_SERVER} is OK (${_RAID_STATUS}==${_TARGET_STATUS})"
|
_MSG="state of bbu on ${_CELL_SERVER} is OK (${_RAID_STATUS}==${_TARGET_STATUS})"
|
||||||
_STC=0
|
_STC=0
|
||||||
fi
|
fi
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
@ -336,18 +305,11 @@ do
|
|||||||
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
(( ARG_DEBUG > 0 )) && debug "excluded check for BBU (battery) on ${_CELL_SERVER}"
|
(( ARG_DEBUG > 0 )) && debug "skipping check for bbu (disabled)"
|
||||||
fi
|
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "skipping check for bbu (battery) (disabled) [${_CELL_SERVER}]"
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
PHYSICAL)
|
PHYSICAL)
|
||||||
if (( _CHECK_PHYSICAL > 0 ))
|
if (( _CHECK_PHYSICAL > 0 ))
|
||||||
then
|
|
||||||
# check for exclusion
|
|
||||||
$(data_contains_string "${_CFG_EXCLUDES}" "${_CELL_SERVER}:physical")
|
|
||||||
if (( $? == 0 ))
|
|
||||||
then
|
then
|
||||||
_TARGET_STATUS="Online"
|
_TARGET_STATUS="Online"
|
||||||
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
||||||
@ -362,19 +324,12 @@ do
|
|||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "excluded check for physical devices on ${_CELL_SERVER}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
(( ARG_DEBUG > 0 )) && debug "skipping check for physical device [${_CELL_SERVER}:/${_RAID_DEVICE}] (disabled)"
|
(( ARG_DEBUG > 0 )) && debug "skipping check for physical device [${_CELL_SERVER}:/${_RAID_DEVICE}] (disabled)"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
VIRTUAL)
|
VIRTUAL)
|
||||||
if (( _CHECK_VIRTUAL > 0 ))
|
if (( _CHECK_VIRTUAL > 0 ))
|
||||||
then
|
|
||||||
# check for exclusion
|
|
||||||
$(data_contains_string "${_CFG_EXCLUDES}" "${_CELL_SERVER}:virtual")
|
|
||||||
if (( $? == 0 ))
|
|
||||||
then
|
then
|
||||||
_TARGET_STATUS="Optimal"
|
_TARGET_STATUS="Optimal"
|
||||||
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
||||||
@ -389,9 +344,6 @@ do
|
|||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "excluded check for virtual devices on ${_CELL_SERVER}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
(( ARG_DEBUG > 0 )) && debug "skipping check for virtual device [${_CELL_SERVER}:/${_RAID_DEVICE}] (disabled)"
|
(( ARG_DEBUG > 0 )) && debug "skipping check for virtual device [${_CELL_SERVER}:/${_RAID_DEVICE}] (disabled)"
|
||||||
fi
|
fi
|
||||||
@ -400,76 +352,9 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# add dcli output to stdout log
|
# add dcli output to stdout log
|
||||||
print "==== {dcli ${_CELL_COMMAND} [${_CFG_CELL_SERVER}]} ====" >>${HC_STDOUT_LOG}
|
print "==== {dcli ${_CELL_COMMAND}} ====" >>${HC_STDOUT_LOG}
|
||||||
print "${_CELL_DATA}" >>${HC_STDOUT_LOG}
|
print "${_CELL_DATA}" >>${HC_STDOUT_LOG}
|
||||||
|
|
||||||
# check if we need to check the BBU (supercap). Use different storcli query
|
|
||||||
# see Oracle Bug 28564584 : X5-2 Aspen w/storcli utility shows false bbu failed status
|
|
||||||
if (( _CHECK_SUPERCAP > 0 ))
|
|
||||||
then
|
|
||||||
_CELL_DATA=""
|
|
||||||
# gather cell data (serialized way to have better control of output & errors)
|
|
||||||
data_comma2newline "${_CFG_CELL_SERVERS}" | while read -r _CFG_CELL_SERVER
|
|
||||||
do
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "executing remote cell script on ${_CFG_CELL_SERVER}"
|
|
||||||
_CELL_OUTPUT=$(exadata_exec_dcli "" "${_CFG_DCLI_USER}" "${_CFG_CELL_SERVER}" "" "${_SUPERCAP_COMMAND}" 2>>${HC_STDERR_LOG})
|
|
||||||
_CELL_RC=$?
|
|
||||||
if (( _CELL_RC > 0 )) || [[ -z "${_CELL_OUTPUT}" ]]
|
|
||||||
then
|
|
||||||
_CELL_ALL_RC=$(( _CELL_ALL_RC + _CELL_RC ))
|
|
||||||
warn "unable to discover cell data on ${_CFG_CELL_SERVER}"
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
# _CELL_OUTPUT is always prefixed by cell server name, so no mangling needed
|
|
||||||
# shellcheck disable=SC1117
|
|
||||||
_CELL_DATA=$(printf "%s\n%s\n" "${_CELL_DATA}" "${_CELL_OUTPUT}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# validate cell data
|
|
||||||
if (( _CELL_ALL_RC > 0 )) || [[ -z "${_CELL_DATA}" ]]
|
|
||||||
then
|
|
||||||
_MSG="did not discover cell data or one of the discoveries failed"
|
|
||||||
_STC=2
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# perform checks on cell data
|
|
||||||
_TARGET_STATUS="Optimal"
|
|
||||||
data_comma2newline "${_CFG_CELL_SERVERS}" | while read -r _CFG_CELL_SERVER
|
|
||||||
do
|
|
||||||
# check for exclusion
|
|
||||||
$(data_contains_string "${_CFG_EXCLUDES}" "${_CELL_SERVER}:supercap")
|
|
||||||
if (( $? == 0 ))
|
|
||||||
then
|
|
||||||
_SUPERCAP_STATUS=$(print -R "${_CELL_DATA}" | grep -c -E -e "^${_CFG_CELL_SERVER}: *State *${_TARGET_STATUS}" 2>/dev/null)
|
|
||||||
if (( _SUPERCAP_STATUS == 0 ))
|
|
||||||
then
|
|
||||||
_MSG="state of BBU (supercap) device on ${_CFG_CELL_SERVER} is NOK"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="state of BBU (supercap) device on ${_CFG_CELL_SERVER} is OK"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "Non-optimal" "${_TARGET_STATUS}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "excluded check for bbu (supercap) on ${_CELL_SERVER}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# add dcli output to stdout log
|
|
||||||
print "==== {dcli ${_SUPERCAP_COMMAND}} ====" >>${HC_STDOUT_LOG}
|
|
||||||
print "${_CELL_DATA}" >>${HC_STDOUT_LOG}
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,20 +370,15 @@ CONFIG : $3 with parameters:
|
|||||||
cell_servers=<list_of_cell_servers>
|
cell_servers=<list_of_cell_servers>
|
||||||
check_controller=<yes|no>
|
check_controller=<yes|no>
|
||||||
check_bbu=<yes|no>
|
check_bbu=<yes|no>
|
||||||
check_supercap=<yes|no>
|
|
||||||
check_physical=<yes|no>
|
check_physical=<yes|no>
|
||||||
check_virtual=<yes|no>
|
check_virtual=<yes|no>
|
||||||
and formatted stanzas of:
|
PURPOSE : Checks the status of MegaRAID device(s) on cell servers (via dcli)
|
||||||
cell_exclude:<cell_server>:<component>
|
|
||||||
PURPOSE : 1) Checks the status of MegaRAID device(s) on cell servers (via dcli)
|
|
||||||
dcli> /opt/MegaRAID/MegaCli/MegaCli64 -ShowSummary -aALL
|
dcli> /opt/MegaRAID/MegaCli/MegaCli64 -ShowSummary -aALL
|
||||||
Target attributes:
|
Target attributes:
|
||||||
* Controller: Optimal [optional]
|
* Controller: Optimal [optional]
|
||||||
* BBU (battery): Healthy [optional]
|
* BBU: Healthy [optional]
|
||||||
* Physical devices: Online [optional]
|
* Physical devices: Online [optional]
|
||||||
* Virtual devices: Optimal [optional]
|
* Virtual devices: Optimal [optional]
|
||||||
2) Checks the status of the Supercap (battery):
|
|
||||||
dcli> /opt/MegaRAID/storcli/storcli64 /c0/cv show all
|
|
||||||
CAVEAT : Requires a working dcli setup for the root user
|
CAVEAT : Requires a working dcli setup for the root user
|
||||||
LOG HEALTHY : Supported
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
|
@ -1,171 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) check_exadata_ib_status.sh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2020 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_exadata_ib_status
|
|
||||||
# DOES: see _show_usage()
|
|
||||||
# EXPECTS: see _show_usage()
|
|
||||||
# REQUIRES: data_comma2space(), dump_logs(), init_hc(), log_hc(), warn()
|
|
||||||
#
|
|
||||||
# @(#) HISTORY:
|
|
||||||
# @(#) 2020-07-07: initial version [Patrick Van der Veken]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function check_exadata_ib_status
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _VERSION="2020-07-07" # YYYY-MM-DD
|
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
|
||||||
typeset _IBSTATUS_BIN="/usr/sbin/ibstatus"
|
|
||||||
typeset _IBSWITCHES_BIN="/usr/sbin/ibswitches"
|
|
||||||
# ------------------------- 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 _LOG_HEALTHY=0
|
|
||||||
typeset _IBSTATUS_OUTPUT=""
|
|
||||||
typeset _IBSWITCHES_OUTPUT=""
|
|
||||||
typeset _NUM_INACTIVE_PORTS=0
|
|
||||||
typeset _NUM_SWITCHES=0
|
|
||||||
|
|
||||||
# handle arguments (originally comma-separated)
|
|
||||||
for _ARG in ${_ARGS}
|
|
||||||
do
|
|
||||||
case "${_ARG}" in
|
|
||||||
help)
|
|
||||||
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# log_healthy
|
|
||||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
|
||||||
if (( _LOG_HEALTHY > 0 ))
|
|
||||||
then
|
|
||||||
if (( ARG_LOG > 0 ))
|
|
||||||
then
|
|
||||||
log "logging/showing passed health checks"
|
|
||||||
else
|
|
||||||
log "showing passed health checks (but not logging)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "not logging/showing passed health checks"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check IB tools
|
|
||||||
if [[ ! -x ${_IBSTATUS_BIN} || -z "${_IBSWITCHES_BIN}" ]]
|
|
||||||
then
|
|
||||||
warn "IB tools are not installed here. This is not an Exadata compute node?"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# gather infiniband status data
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "executing command {${_IBSTATUS_BIN}}"
|
|
||||||
_IBSTATUS_OUTPUT=$(${_IBSTATUS_BIN} 2>>${HC_STDERR_LOG})
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $?> 0 )) || [[ -z "${_IBSTATUS_OUTPUT}" ]]
|
|
||||||
then
|
|
||||||
_MSG="unable to run command {${_IBSTATUS_BIN}}"
|
|
||||||
_STC=2
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "executing command {${_IBSWITCHES_BIN}}"
|
|
||||||
_IBSWITCHES_OUTPUT=$(${_IBSWITCHES_BIN} 2>>${HC_STDERR_LOG})
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $?> 0 )) || [[ -z "${_IBSWITCHES_OUTPUT}" ]]
|
|
||||||
then
|
|
||||||
_MSG="unable to run command {${_IBSWITCHES_BIN}}"
|
|
||||||
_STC=2
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# perform checks on IB status data
|
|
||||||
_NUM_INACTIVE_PORTS=$(print -R "${_IBSTATUS_OUTPUT}" | grep -E -e '^[[:space:]]+state:' 2>/dev/null | grep -c -v "ACTIVE" 2>/dev/null)
|
|
||||||
if (( _HAS_OFFLINE_PORTS > 0 ))
|
|
||||||
then
|
|
||||||
_MSG="${_NUM_INACTIVE_PORTS} IB port(s) are/is in state INACTIVE"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="all IB port(s) are/is in ACTIVE state"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# perform checks on IB switches data
|
|
||||||
_NUM_SWITCHES=$(print -R "${_IBSWITCHES_OUTPUT}" | wc -l 2>/dev/null)
|
|
||||||
if (( _NUM_SWITCHES != 2 ))
|
|
||||||
then
|
|
||||||
_MSG="only ${_NUM_SWITCHES} IB switch(es) are/is reporting (${_NUM_SWITCHES}<>2)"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="${_NUM_SWITCHES} IB switch(es) are/is reporting"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# add IB output to stdout log
|
|
||||||
print "==== {${_IBSTATUS_BIN}} ====" >>${HC_STDOUT_LOG}
|
|
||||||
print "${_IBSTATUS_OUTPUT}" >>${HC_STDOUT_LOG}
|
|
||||||
|
|
||||||
print "==== {${_IBSWITCHES_BIN}} ====" >>${HC_STDOUT_LOG}
|
|
||||||
print "${_IBSWITCHES_OUTPUT}" >>${HC_STDOUT_LOG}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function _show_usage
|
|
||||||
{
|
|
||||||
cat <<- EOT
|
|
||||||
NAME : $1
|
|
||||||
VERSION : $2
|
|
||||||
PURPOSE : 1) Checks that (local) Infiniband ports are in active
|
|
||||||
2) Checks that Infiniband switches are present (should be 2)
|
|
||||||
LOG HEALTHY : Supported
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -19,13 +19,11 @@
|
|||||||
# @(#) MAIN: check_exadata_megaraid
|
# @(#) MAIN: check_exadata_megaraid
|
||||||
# DOES: see _show_usage()
|
# DOES: see _show_usage()
|
||||||
# EXPECTS: see _show_usage()
|
# EXPECTS: see _show_usage()
|
||||||
# REQUIRES: data_comma2space(), data_comma2newline(), data_contains_string(),
|
# REQUIRES: data_comma2space(), data_comma2newline(), data_get_lvalue_from_config,
|
||||||
# data_get_lvalue_from_config, dump_logs(), init_hc(), log_hc(), warn()
|
# dump_logs(), init_hc(), log_hc(), warn()
|
||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2019-05-14: initial version [Patrick Van der Veken]
|
# @(#) 2019-05-14: initial version [Patrick Van der Veken]
|
||||||
# @(#) 2019-07-08: update _MEGACLI_BIN [Patrick Van der Veken]
|
|
||||||
# @(#) 2019-07-18: added supercap check, see Oracle bug 28564584 [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,11 +33,10 @@ function check_exadata_megaraid
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2019-07-18" # YYYY-MM-DD
|
typeset _VERSION="2019-05-14" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
typeset _MEGACLI_BIN="/opt/MegaRAID/storcli/storcli64"
|
typeset _MEGACLI_BIN="/opt/MegaRAID/MegaCli/MegaCli64"
|
||||||
typeset _MEGACLI_COMMAND="-ShowSummary -aALL"
|
typeset _MEGACLI_COMMAND="-ShowSummary -aALL"
|
||||||
typeset _SUPERCAP_COMMAND="/c0/cv show all"
|
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
@ -55,8 +52,6 @@ typeset _CFG_CHECK_CONTROLLER=""
|
|||||||
typeset _CHECK_CONTROLLER=0
|
typeset _CHECK_CONTROLLER=0
|
||||||
typeset _CFG_CHECK_BBU=""
|
typeset _CFG_CHECK_BBU=""
|
||||||
typeset _CHECK_BBU=0
|
typeset _CHECK_BBU=0
|
||||||
typeset _CFG_CHECK_SUPERCAP=""
|
|
||||||
typeset _CHECK_SUPERCAP=0
|
|
||||||
typeset _CFG_CHECK_PHYSICAL=""
|
typeset _CFG_CHECK_PHYSICAL=""
|
||||||
typeset _CHECK_PHYSICAL=0
|
typeset _CHECK_PHYSICAL=0
|
||||||
typeset _CFG_CHECK_VIRTUAL=""
|
typeset _CFG_CHECK_VIRTUAL=""
|
||||||
@ -66,7 +61,6 @@ typeset _CLI_DATA=""
|
|||||||
typeset _RAID_DEVICE=""
|
typeset _RAID_DEVICE=""
|
||||||
typeset _RAID_DEVICE_TYPE=""
|
typeset _RAID_DEVICE_TYPE=""
|
||||||
typeset _RAID_STATUS=""
|
typeset _RAID_STATUS=""
|
||||||
typeset _SUPERCAP_STATUS=""
|
|
||||||
|
|
||||||
# handle arguments (originally comma-separated)
|
# handle arguments (originally comma-separated)
|
||||||
for _ARG in ${_ARGS}
|
for _ARG in ${_ARGS}
|
||||||
@ -116,16 +110,6 @@ case "${_CFG_CHECK_BBU}" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
(( _CHECK_BBU > 0 )) || log "checking bbu has been disabled"
|
(( _CHECK_BBU > 0 )) || log "checking bbu has been disabled"
|
||||||
_CFG_CHECK_SUPERCAP=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_supercap')
|
|
||||||
case "${_CFG_CHECK_SUPERCAP}" in
|
|
||||||
no|NO|No)
|
|
||||||
_CHECK_SUPERCAP=0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_CHECK_SUPERCAP=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
(( _CHECK_SUPERCAP > 0 )) || log "checking bbu (supercap) has been disabled"
|
|
||||||
_CFG_CHECK_PHYSICAL=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_physical')
|
_CFG_CHECK_PHYSICAL=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_physical')
|
||||||
case "${_CFG_CHECK_PHYSICAL}" in
|
case "${_CFG_CHECK_PHYSICAL}" in
|
||||||
no|NO|No)
|
no|NO|No)
|
||||||
@ -184,7 +168,7 @@ then
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# perform checks on MegaCLI data
|
# perform checks on cell data
|
||||||
print -R "${_CLI_OUTPUT}" | awk '
|
print -R "${_CLI_OUTPUT}" | awk '
|
||||||
|
|
||||||
BEGIN { found_controller = 0; controller_status = "";
|
BEGIN { found_controller = 0; controller_status = "";
|
||||||
@ -277,7 +261,7 @@ do
|
|||||||
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_RAID_STATUS}" "${_TARGET_STATUS}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
(( ARG_DEBUG > 0 )) && debug "excluded check for controller"
|
(( ARG_DEBUG > 0 )) && debug "skipping check for controller (disabled)"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
BBU)
|
BBU)
|
||||||
@ -286,10 +270,10 @@ do
|
|||||||
_TARGET_STATUS="Healthy"
|
_TARGET_STATUS="Healthy"
|
||||||
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
if [[ "${_RAID_STATUS}" != "${_TARGET_STATUS}" ]]
|
||||||
then
|
then
|
||||||
_MSG="state of bbu (battery) is NOK (${_RAID_STATUS}!=${_TARGET_STATUS})"
|
_MSG="state of bbu is NOK (${_RAID_STATUS}!=${_TARGET_STATUS})"
|
||||||
_STC=1
|
_STC=1
|
||||||
else
|
else
|
||||||
_MSG="state of bbu (battery) is OK (${_RAID_STATUS}==${_TARGET_STATUS})"
|
_MSG="state of bbu is OK (${_RAID_STATUS}==${_TARGET_STATUS})"
|
||||||
_STC=0
|
_STC=0
|
||||||
fi
|
fi
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
@ -347,49 +331,6 @@ done
|
|||||||
print "==== {${_MEGACLI_COMMAND}} ====" >>${HC_STDOUT_LOG}
|
print "==== {${_MEGACLI_COMMAND}} ====" >>${HC_STDOUT_LOG}
|
||||||
print "${_CLI_DATA}" >>${HC_STDOUT_LOG}
|
print "${_CLI_DATA}" >>${HC_STDOUT_LOG}
|
||||||
|
|
||||||
# check if we need to check the BBU (supercap). Use different storcli query
|
|
||||||
# see Oracle Bug 28564584 : X5-2 Aspen w/storcli utility shows false bbu failed status
|
|
||||||
if (( _CHECK_SUPERCAP > 0 ))
|
|
||||||
then
|
|
||||||
# gather MegaCLI data
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "executing Supercap command"
|
|
||||||
_CLI_OUTPUT=$(${_MEGACLI_BIN} "${_SUPERCAP_COMMAND}" 2>>${HC_STDERR_LOG})
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $?> 0 )) || [[ -z "${_CLI_OUTPUT}" ]]
|
|
||||||
then
|
|
||||||
_MSG="unable to query MegaRAID controller"
|
|
||||||
_STC=2
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# perform checks on MegaCLI data
|
|
||||||
_TARGET_STATUS="Optimal"
|
|
||||||
_SUPERCAP_STATUS=$(print -R "${_CLI_OUTPUT}" | grep -c -E -e "^State *${_TARGET_STATUS}" 2>/dev/null)
|
|
||||||
if (( _SUPERCAP_STATUS == 0 ))
|
|
||||||
then
|
|
||||||
_MSG="state of BBU (supercap) device is NOK"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="state of BBU (supercap) device is OK"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "Non-optimal" "${_TARGET_STATUS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# add dcli output to stdout log
|
|
||||||
print "==== {dcli ${_SUPERCAP_COMMAND}} ====" >>${HC_STDOUT_LOG}
|
|
||||||
print "${_CELL_DATA}" >>${HC_STDOUT_LOG}
|
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "excluded check for bbu (supercap) on ${_CELL_SERVER}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,18 +344,15 @@ CONFIG : $3 with parameters:
|
|||||||
log_healthy=<yes|no>
|
log_healthy=<yes|no>
|
||||||
check_controller=<yes|no>
|
check_controller=<yes|no>
|
||||||
check_bbu=<yes|no>
|
check_bbu=<yes|no>
|
||||||
check_supercap=<yes|no>
|
|
||||||
check_physical=<yes|no>
|
check_physical=<yes|no>
|
||||||
check_virtual=<yes|no>
|
check_virtual=<yes|no>
|
||||||
PURPOSE : 1) Checks the status of MegaRAID device(s)
|
PURPOSE : Checks the status of MegaRAID device(s)
|
||||||
# /opt/MegaRAID/MegaCli/MegaCli64 -ShowSummary -aALL
|
# /opt/MegaRAID/MegaCli/MegaCli64 -ShowSummary -aALL
|
||||||
Target attributes:
|
Target attributes:
|
||||||
* Controller: Optimal [optional]
|
* Controller: Optimal [optional]
|
||||||
* BBU (battery): Healthy [optional]
|
* BBU: Healthy [optional]
|
||||||
* Physical devices: Online [optional]
|
* Physical devices: Online [optional]
|
||||||
* Virtual devices: Optimal [optional]
|
* Virtual devices: Optimal [optional]
|
||||||
2) Checks the status of the Supercap (battery):
|
|
||||||
dcli> /opt/MegaRAID/storcli/storcli64 /c0/cv show all
|
|
||||||
LOG HEALTHY : Supported
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
@ -1,264 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) check_exadata_zfs_cluster.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_exadata_zfs_cluster
|
|
||||||
# DOES: see _show_usage()
|
|
||||||
# EXPECTS: see _show_usage()
|
|
||||||
# REQUIRES: data_comma2space(), data_get_lvalue_from_config, dump_logs(),
|
|
||||||
# data_strip_outer_space(), init_hc(), linux_exec_ssh(), log_hc(), warn()
|
|
||||||
#
|
|
||||||
# @(#) HISTORY:
|
|
||||||
# @(#) 2019-07-05: initial version [Patrick Van der Veken]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function check_exadata_zfs_cluster
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
|
||||||
typeset _VERSION="2019-07-05" # YYYY-MM-DD
|
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
|
||||||
# cluster query script -- DO NOT CHANGE --
|
|
||||||
# state=AKCS_CLUSTERED
|
|
||||||
# link=clustron3_ng3:0/clustron_uart:0 = AKCIOS_ACTIVE
|
|
||||||
# link=clustron3_ng3:0/clustron_uart:1 = AKCIOS_ACTIVE
|
|
||||||
# link=clustron3_ng3:0/dlpi:0 = AKCIOS_ACTIVE
|
|
||||||
typeset _ZFS_SCRIPT="
|
|
||||||
script
|
|
||||||
run('configuration cluster');
|
|
||||||
printf('state=%s\n', get('state'));
|
|
||||||
var links = run('links');
|
|
||||||
var links_array = links.split('\n');
|
|
||||||
for (var i = 0; i < links_array.length; ++i) {
|
|
||||||
if (links_array[i] != '') {
|
|
||||||
printf('link=%s\n', links_array[i].replace(/^\s+|\s+$/g,''));
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
# target state of the cluster
|
|
||||||
typeset _CLUSTER_TARGET="AKCS_CLUSTERED"
|
|
||||||
# target state of the cluster links
|
|
||||||
typeset _LINK_TARGET="AKCIOS_ACTIVE"
|
|
||||||
# ------------------------- 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_SSH_KEY_FILE=""
|
|
||||||
typeset _CFG_SSH_OPTS=""
|
|
||||||
typeset _CFG_SSH_USER=""
|
|
||||||
typeset _CFG_SPACE_THRESHOLD=""
|
|
||||||
typeset _CFG_ZFS_HOSTS=""
|
|
||||||
typeset _CFG_ZFS_HOST=""
|
|
||||||
typeset _CFG_ZFS_LINE=""
|
|
||||||
typeset _SSH_BIN=""
|
|
||||||
typeset _SSH_OUTPUT=""
|
|
||||||
typeset _ZFS_DATA=""
|
|
||||||
|
|
||||||
# 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_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
|
|
||||||
_CFG_SSH_USER=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'ssh_user')
|
|
||||||
if [[ -z "${_CFG_SSH_USER}" ]]
|
|
||||||
then
|
|
||||||
_CFG_SSH_USER="root"
|
|
||||||
fi
|
|
||||||
_CFG_SSH_KEY_FILE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'ssh_key_file')
|
|
||||||
_CFG_SSH_OPTS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'ssh_opts')
|
|
||||||
# add quiet mode
|
|
||||||
_CFG_SSH_OPTS="${_CFG_SSH_OPTS} -q"
|
|
||||||
if [[ -n "${_CFG_SSH_KEY_FILE}" ]]
|
|
||||||
then
|
|
||||||
if [[ -r "${_CFG_SSH_KEY_FILE}" ]]
|
|
||||||
then
|
|
||||||
log "will use SSH key ${_CFG_SSH_KEY_FILE}"
|
|
||||||
_CFG_SSH_OPTS="${_CFG_SSH_OPTS} -i ${_CFG_SSH_KEY_FILE}"
|
|
||||||
else
|
|
||||||
warn "will use SSH key ${_CFG_SSH_KEY_FILE}, but file does not exist"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
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 ssh
|
|
||||||
_SSH_BIN="$(command -v ssh 2>>${HC_STDERR_LOG})"
|
|
||||||
if [[ ! -x ${_SSH_BIN} || -z "${_SSH_BIN}" ]]
|
|
||||||
then
|
|
||||||
warn "SSH is not installed here"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# gather ZFS hostnames (for this we need at least one data line, possibly with wildcards)
|
|
||||||
_CFG_ZFS_HOSTS=$(grep -i -E -e '^zfs:' ${_CONFIG_FILE} 2>/dev/null | cut -f2 -d':' 2>/dev/null | sort -u 2>/dev/null)
|
|
||||||
if [[ -z "${_CFG_ZFS_HOSTS}" ]]
|
|
||||||
then
|
|
||||||
warn "no monitoring rules defined in ${_CONFIG_FILE}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# gather ZFS usage data
|
|
||||||
print "${_CFG_ZFS_HOSTS}" | while read -r _CFG_ZFS_HOST
|
|
||||||
do
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "executing remote ZFS script on ${_CFG_ZFS_HOST}"
|
|
||||||
_SSH_OUTPUT=$(linux_exec_ssh "${_CFG_SSH_OPTS}" "${_CFG_SSH_USER}" "${_CFG_ZFS_HOST}" "${_ZFS_SCRIPT}" 2>>${HC_STDERR_LOG})
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 )) || [[ -z "${_SSH_OUTPUT}" ]]
|
|
||||||
then
|
|
||||||
warn "unable to discover usage data on ${_CFG_ZFS_HOST}"
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
continue
|
|
||||||
else
|
|
||||||
# mangle SSH output by prefixing with hostname
|
|
||||||
print "${_SSH_OUTPUT}" | while read -r _SSH_LINE
|
|
||||||
do
|
|
||||||
if [[ -z "${_ZFS_DATA}" ]]
|
|
||||||
then
|
|
||||||
_ZFS_DATA="${_CFG_ZFS_HOST}#${_SSH_LINE}"
|
|
||||||
else
|
|
||||||
# shellcheck disable=SC1117
|
|
||||||
_ZFS_DATA=$(printf "%s\n%s#%s" "${_ZFS_DATA}" "${_CFG_ZFS_HOST}" "${_SSH_LINE}")
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# process usage status data
|
|
||||||
if [[ -z "${_ZFS_DATA}" ]]
|
|
||||||
then
|
|
||||||
_MSG="did not discover any ZFS share data"
|
|
||||||
_STC=2
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
print "${_ZFS_DATA}" | while IFS='#' read -r _ZFS_HOST _CLUSTER_LINE
|
|
||||||
do
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "parsing cluster data for appliance: ${_ZFS_HOST}"
|
|
||||||
|
|
||||||
# split up cluster data & perform checks
|
|
||||||
case "${_CLUSTER_LINE}" in
|
|
||||||
link=*)
|
|
||||||
_LINK_STATE=$(data_strip_outer_space "$(print "${_CLUSTER_LINE}" | cut -f3 -d'=' 2>/dev/null)")
|
|
||||||
|
|
||||||
if [[ "${_LINK_STATE}" != "${_LINK_TARGET}" ]]
|
|
||||||
then
|
|
||||||
_MSG="${_ZFS_HOST} cluster link state is NOK ([${_LINK_STATE}!=${_LINK_TARGET})"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="${_ZFS_HOST} cluster link state is OK (${_LINK_STATE}==${_LINK_TARGET})"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_LINK_STATE}" "${_LINK_TARGET}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
state=*)
|
|
||||||
_CLUSTER_STATE=$(print "${_CLUSTER_LINE##state=}")
|
|
||||||
|
|
||||||
if [[ "${_CLUSTER_STATE}" != "${_CLUSTER_TARGET}" ]]
|
|
||||||
then
|
|
||||||
_MSG="${_ZFS_HOST} cluster state is NOK (${_CLUSTER_STATE}!=${_CLUSTER_TARGET})"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="${_ZFS_HOST} cluster state is OK (${_CLUSTER_STATE}==${_CLUSTER_TARGET})"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_CLUSTER_STATE}" "${_CLUSTER_TARGET}"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function _show_usage
|
|
||||||
{
|
|
||||||
cat <<- EOT
|
|
||||||
NAME : $1
|
|
||||||
VERSION : $2
|
|
||||||
CONFIG : $3 with parameters:
|
|
||||||
log_healthy=<yes|no>
|
|
||||||
ssh_user=<ssh_user_account>
|
|
||||||
ssh_key_file=<ssh_private_key_file>
|
|
||||||
ssh_opts=<ssh_options>
|
|
||||||
and formatted stanzas of:
|
|
||||||
zfs:<host_name>
|
|
||||||
PURPOSE : Checks the state of the cluster and its links
|
|
||||||
CLI: zfs > configuration > cluster > show
|
|
||||||
LOG HEALTHY : Supported
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -26,7 +26,6 @@
|
|||||||
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
# @(#) 2019-05-14: _STC fix [Patrick Van der Veken]
|
# @(#) 2019-05-14: _STC fix [Patrick Van der Veken]
|
||||||
# @(#) 2019-07-05: help fix [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 +35,7 @@ function check_exadata_zfs_logs
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2019-07-05" # YYYY-MM-DD
|
typeset _VERSION="2019-05-14" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -455,7 +454,6 @@ CONFIG : $3 with parameters:
|
|||||||
log_healthy=<yes|no>
|
log_healthy=<yes|no>
|
||||||
ssh_user=<ssh_user_account>
|
ssh_user=<ssh_user_account>
|
||||||
ssh_key_file=<ssh_private_key_file>
|
ssh_key_file=<ssh_private_key_file>
|
||||||
ssh_opts=<ssh_options>
|
|
||||||
and formatted stanzas of:
|
and formatted stanzas of:
|
||||||
zfs:<host_name>:<alert|fltlog|scrk|system>:<filters>
|
zfs:<host_name>:<alert|fltlog|scrk|system>:<filters>
|
||||||
PURPOSE : Checks the ZFS logs for (new) entries with particular alert level(s)
|
PURPOSE : Checks the ZFS logs for (new) entries with particular alert level(s)
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2019-04-12: initial version [Patrick Van der Veken]
|
# @(#) 2019-04-12: initial version [Patrick Van der Veken]
|
||||||
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
||||||
# @(#) 2019-07-05: help fix [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 +34,7 @@ function check_exadata_zfs_pool_usage
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2019-07-05" # YYYY-MM-DD
|
typeset _VERSION="2019-05-14" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# usage query script -- DO NOT CHANGE --
|
# usage query script -- DO NOT CHANGE --
|
||||||
# prj1:share1:16
|
# prj1:share1:16
|
||||||
@ -278,7 +277,6 @@ CONFIG : $3 with parameters:
|
|||||||
log_healthy=<yes|no>
|
log_healthy=<yes|no>
|
||||||
ssh_user=<ssh_user_account>
|
ssh_user=<ssh_user_account>
|
||||||
ssh_key_file=<ssh_private_key_file>
|
ssh_key_file=<ssh_private_key_file>
|
||||||
ssh_opts=<ssh_options>
|
|
||||||
max_space_usage=<general_max_space_treshold>
|
max_space_usage=<general_max_space_treshold>
|
||||||
and formatted stanzas of:
|
and formatted stanzas of:
|
||||||
zfs:<host_name>:<pool_name>:<max_space_threshold>
|
zfs:<host_name>:<pool_name>:<max_space_threshold>
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
||||||
# @(#) 2019-07-05: help fix [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 +35,7 @@ function check_exadata_zfs_services
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2019-07-05" # YYYY-MM-DD
|
typeset _VERSION="2019-05-14" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# usage query script -- DO NOT CHANGE --
|
# usage query script -- DO NOT CHANGE --
|
||||||
# svc1:online
|
# svc1:online
|
||||||
@ -245,7 +244,6 @@ CONFIG : $3 with parameters:
|
|||||||
log_healthy=<yes|no>
|
log_healthy=<yes|no>
|
||||||
ssh_user=<ssh_user_account>
|
ssh_user=<ssh_user_account>
|
||||||
ssh_key_file=<ssh_private_key_file>
|
ssh_key_file=<ssh_private_key_file>
|
||||||
ssh_opts=<ssh_options>
|
|
||||||
and formatted stanzas of:
|
and formatted stanzas of:
|
||||||
zfs:<host_name>:<service_name>:<service_state>
|
zfs:<host_name>:<service_name>:<service_state>
|
||||||
PURPOSE : Checks the state of services for the configured ZFS hosts/shares
|
PURPOSE : Checks the state of services for the configured ZFS hosts/shares
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
# @(#) MAIN: check_exadata_zfs_share_replication
|
# @(#) MAIN: check_exadata_zfs_share_replication
|
||||||
# DOES: see _show_usage()
|
# DOES: see _show_usage()
|
||||||
# EXPECTS: see _show_usage()
|
# EXPECTS: see _show_usage()
|
||||||
# REQUIRES: data_comma2space(), data_contains_string(), data_expand_numerical_range(),
|
# REQUIRES: data_comma2space(), data_contains_string(), data_get_lvalue_from_config(),
|
||||||
# data_get_lvalue_from_config(), data_has_newline(), data_is_numeric(),
|
# dump_logs(), init_hc(), linux_exec_ssh(), log_hc(), warn()
|
||||||
# data_lc(), data_strip_space(), dump_logs(), init_hc(), linux_exec_ssh(),
|
|
||||||
# log_hc(), warn()
|
|
||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
||||||
@ -30,10 +28,6 @@
|
|||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
# @(#) 2019-04-12: small fixes [Patrick Van der Veken]
|
# @(#) 2019-04-12: small fixes [Patrick Van der Veken]
|
||||||
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
||||||
# @(#) 2020-01-27: addition of day check option +
|
|
||||||
# @(#) newline config value check [Patrick Van der Veken]
|
|
||||||
# @(#) 2020-03-05: addition of hour check option + fix
|
|
||||||
# @(#) 2020-03-26: fix for expanding numerical range
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -43,7 +37,7 @@ function check_exadata_zfs_share_replication
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2020-03-26" # YYYY-MM-DD
|
typeset _VERSION="2019-05-14" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# replication query script -- DO NOT CHANGE --
|
# replication query script -- DO NOT CHANGE --
|
||||||
# prj1/share1:true:idle:success:111
|
# prj1/share1:true:idle:success:111
|
||||||
@ -80,17 +74,12 @@ typeset _CFG_SSH_USER=""
|
|||||||
typeset _CFG_ZFS_HOSTS=""
|
typeset _CFG_ZFS_HOSTS=""
|
||||||
typeset _CFG_ZFS_HOST=""
|
typeset _CFG_ZFS_HOST=""
|
||||||
typeset _CFG_ZFS_LINE=""
|
typeset _CFG_ZFS_LINE=""
|
||||||
typeset _CFG_REPLICATION_DAYS=""
|
|
||||||
typeset _CFG_REPLICATION_HOURS=""
|
|
||||||
typeset _REPLICATION_ENABLED=""
|
typeset _REPLICATION_ENABLED=""
|
||||||
typeset _REPLICATION_HOURS=""
|
|
||||||
typeset _REPLICATION_LAG=""
|
typeset _REPLICATION_LAG=""
|
||||||
typeset _REPLICATION_RESULT=""
|
typeset _REPLICATION_RESULT=""
|
||||||
typeset _SSH_BIN=""
|
typeset _SSH_BIN=""
|
||||||
typeset _SSH_OUTPUT=""
|
typeset _SSH_OUTPUT=""
|
||||||
typeset _ZFS_DATA=""
|
typeset _ZFS_DATA=""
|
||||||
typeset _WEEKDAY=$(data_lc "$(date '+%a' 2>/dev/null)") # Sun
|
|
||||||
typeset _HOUR=$(data_strip_space "$(date '+%H' 2>/dev/null)") # 7,23 etc
|
|
||||||
|
|
||||||
# handle arguments (originally comma-separated)
|
# handle arguments (originally comma-separated)
|
||||||
for _ARG in ${_ARGS}
|
for _ARG in ${_ARGS}
|
||||||
@ -220,8 +209,6 @@ do
|
|||||||
_CFG_REPLICATION_ENABLED=""
|
_CFG_REPLICATION_ENABLED=""
|
||||||
_CFG_REPLICATION_RESULT=""
|
_CFG_REPLICATION_RESULT=""
|
||||||
_CFG_REPLICATION_LAG=""
|
_CFG_REPLICATION_LAG=""
|
||||||
_CFG_REPLICATION_DAYS=""
|
|
||||||
_CFG_REPLICATION_HOURS=""
|
|
||||||
|
|
||||||
# which values to use (general or custom?), keep in mind wildcards (custom will overrule wildcard entry)
|
# which values to use (general or custom?), keep in mind wildcards (custom will overrule wildcard entry)
|
||||||
_CFG_ZFS_LINE=$(grep -E -e "^zfs:${_ZFS_HOST}:[*]:" ${_CONFIG_FILE} 2>/dev/null)
|
_CFG_ZFS_LINE=$(grep -E -e "^zfs:${_ZFS_HOST}:[*]:" ${_CONFIG_FILE} 2>/dev/null)
|
||||||
@ -231,8 +218,6 @@ do
|
|||||||
_CFG_REPLICATION_ENABLED=$(print "${_CFG_ZFS_LINE}" | cut -f4 -d':' 2>/dev/null)
|
_CFG_REPLICATION_ENABLED=$(print "${_CFG_ZFS_LINE}" | cut -f4 -d':' 2>/dev/null)
|
||||||
_CFG_REPLICATION_RESULT=$(print "${_CFG_ZFS_LINE}" | cut -f5 -d':' 2>/dev/null)
|
_CFG_REPLICATION_RESULT=$(print "${_CFG_ZFS_LINE}" | cut -f5 -d':' 2>/dev/null)
|
||||||
_CFG_REPLICATION_LAG=$(print "${_CFG_ZFS_LINE}" | cut -f6 -d':' 2>/dev/null)
|
_CFG_REPLICATION_LAG=$(print "${_CFG_ZFS_LINE}" | cut -f6 -d':' 2>/dev/null)
|
||||||
_CFG_REPLICATION_DAYS=$(print "${_CFG_ZFS_LINE}" | cut -f7 -d':' 2>/dev/null)
|
|
||||||
_CFG_REPLICATION_HOURS=$(print "${_CFG_ZFS_LINE}" | cut -f8 -d':' 2>/dev/null)
|
|
||||||
# null value means general threshold
|
# null value means general threshold
|
||||||
if [[ -z "${_CFG_REPLICATION_LAG}" ]]
|
if [[ -z "${_CFG_REPLICATION_LAG}" ]]
|
||||||
then
|
then
|
||||||
@ -243,19 +228,10 @@ do
|
|||||||
_CFG_ZFS_LINE=$(grep -E -e "^zfs:${_ZFS_HOST}:${_REPLICATION_NAME}:" ${_CONFIG_FILE} 2>/dev/null)
|
_CFG_ZFS_LINE=$(grep -E -e "^zfs:${_ZFS_HOST}:${_REPLICATION_NAME}:" ${_CONFIG_FILE} 2>/dev/null)
|
||||||
if [[ -n "${_CFG_ZFS_LINE}" ]]
|
if [[ -n "${_CFG_ZFS_LINE}" ]]
|
||||||
then
|
then
|
||||||
data_has_newline "${_CFG_ZFS_LINE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "ignoring ${_ZFS_HOST}:${_REPLICATION_NAME} because it parses to multiple results in ${_CONFIG_FILE}"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "found custom definition for ${_ZFS_HOST}:${_REPLICATION_NAME} in configuration file ${_CONFIG_FILE}"
|
(( ARG_DEBUG > 0 )) && debug "found custom definition for ${_ZFS_HOST}:${_REPLICATION_NAME} in configuration file ${_CONFIG_FILE}"
|
||||||
_CFG_REPLICATION_ENABLED=$(print "${_CFG_ZFS_LINE}" | cut -f4 -d':' 2>/dev/null)
|
_CFG_REPLICATION_ENABLED=$(print "${_CFG_ZFS_LINE}" | cut -f4 -d':' 2>/dev/null)
|
||||||
_CFG_REPLICATION_RESULT=$(print "${_CFG_ZFS_LINE}" | cut -f5 -d':' 2>/dev/null)
|
_CFG_REPLICATION_RESULT=$(print "${_CFG_ZFS_LINE}" | cut -f5 -d':' 2>/dev/null)
|
||||||
_CFG_REPLICATION_LAG=$(print "${_CFG_ZFS_LINE}" | cut -f6 -d':' 2>/dev/null)
|
_CFG_REPLICATION_LAG=$(print "${_CFG_ZFS_LINE}" | cut -f6 -d':' 2>/dev/null)
|
||||||
_CFG_REPLICATION_DAYS=$(print "${_CFG_ZFS_LINE}" | cut -f7 -d':' 2>/dev/null)
|
|
||||||
_CFG_REPLICATION_HOURS=$(print "${_CFG_ZFS_LINE}" | cut -f8 -d':' 2>/dev/null)
|
|
||||||
# null value means general threshold
|
# null value means general threshold
|
||||||
if [[ -z "${_CFG_REPLICATION_LAG}" ]]
|
if [[ -z "${_CFG_REPLICATION_LAG}" ]]
|
||||||
then
|
then
|
||||||
@ -285,25 +261,8 @@ do
|
|||||||
# fixed defaults if missing
|
# fixed defaults if missing
|
||||||
[[ -z "${_CFG_REPLICATION_ENABLED}" || "${_CFG_REPLICATION_ENABLED}" = '*' ]] && _CFG_REPLICATION_ENABLED="true"
|
[[ -z "${_CFG_REPLICATION_ENABLED}" || "${_CFG_REPLICATION_ENABLED}" = '*' ]] && _CFG_REPLICATION_ENABLED="true"
|
||||||
[[ -z "${_CFG_REPLICATION_RESULT}" || "${_CFG_REPLICATION_RESULT}" = '*' ]] && _CFG_REPLICATION_RESULT="success"
|
[[ -z "${_CFG_REPLICATION_RESULT}" || "${_CFG_REPLICATION_RESULT}" = '*' ]] && _CFG_REPLICATION_RESULT="success"
|
||||||
_CFG_REPLICATION_DAYS=$(data_lc "${_CFG_REPLICATION_DAYS}")
|
|
||||||
[[ -z "${_CFG_REPLICATION_DAYS}" || "${_CFG_REPLICATION_DAYS}" = '*' ]] && _CFG_REPLICATION_DAYS="${_WEEKDAY}"
|
|
||||||
if [[ -z "${_CFG_REPLICATION_HOURS}" || "${_CFG_REPLICATION_HOURS}" = '*' ]]
|
|
||||||
then
|
|
||||||
_REPLICATION_HOURS="${_HOUR}"
|
|
||||||
else
|
|
||||||
# expand range with leading zeroes
|
|
||||||
_REPLICATION_HOURS=$(data_expand_numerical_range "${_CFG_REPLICATION_HOURS}" 1)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# perform checks
|
# perform checks
|
||||||
# do we need to perform the check today?
|
|
||||||
data_contains_string "${_CFG_REPLICATION_DAYS}" "${_WEEKDAY}"
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
# do we need to perform the check this hour?
|
|
||||||
data_contains_string "${_REPLICATION_HOURS}" "${_HOUR}"
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
# check replication enabled state (active or not?)
|
# check replication enabled state (active or not?)
|
||||||
if [[ $(data_lc "${_REPLICATION_ENABLED}") != $(data_lc "${_CFG_REPLICATION_ENABLED}") ]]
|
if [[ $(data_lc "${_REPLICATION_ENABLED}") != $(data_lc "${_CFG_REPLICATION_ENABLED}") ]]
|
||||||
then
|
then
|
||||||
@ -353,12 +312,6 @@ do
|
|||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_REPLICATION_LAG}" "${_CFG_REPLICATION_LAG}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_REPLICATION_LAG}" "${_CFG_REPLICATION_LAG}"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
warn "check of ${_ZFS_HOST}:${_REPLICATION_NAME} is only configured for this/these hour(s): ${_REPLICATION_HOURS}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "check of ${_ZFS_HOST}:${_REPLICATION_NAME} is not configured for today"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -376,8 +329,8 @@ CONFIG : $3 with parameters:
|
|||||||
ssh_key_file=<ssh_private_key_file>
|
ssh_key_file=<ssh_private_key_file>
|
||||||
max_replication_lag=<general_max_replication>
|
max_replication_lag=<general_max_replication>
|
||||||
and formatted stanzas of:
|
and formatted stanzas of:
|
||||||
zfs:<host_name>:<replication_name>:<replication_enabled>:<replication_result>:<max_replication_lag>:<day1,day2>:<start_hour>-<end_hour>
|
zfs:<host_name>:<replication_name>:<replication_enabled>:<replication_result>:<max_replication_lag>
|
||||||
PURPOSE : Checks the replication state, sync status and maximum lag of the configured ZFS hosts/shares on certain days
|
PURPOSE : Checks the replication state, sync status and maximum lag of the configured ZFS hosts/shares
|
||||||
CLI: zfs > shares > replications > packages > select (action) > show
|
CLI: zfs > shares > replications > packages > select (action) > show
|
||||||
LOG HEALTHY : Supported
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
# @(#) MAIN: check_exadata_zfs_share_usage
|
# @(#) MAIN: check_exadata_zfs_share_usage
|
||||||
# DOES: see _show_usage()
|
# DOES: see _show_usage()
|
||||||
# EXPECTS: see _show_usage()
|
# EXPECTS: see _show_usage()
|
||||||
# REQUIRES: data_comma2space(), data_get_lvalue_from_config, data_has_newline(),
|
# REQUIRES: data_comma2space(), data_get_lvalue_from_config, dump_logs(),
|
||||||
# dump_logs(), init_hc(), linux_exec_ssh(), log_hc(), warn()
|
# init_hc(), linux_exec_ssh(), log_hc(), warn()
|
||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
# @(#) 2019-02-18: initial version [Patrick Van der Veken]
|
||||||
@ -28,7 +28,6 @@
|
|||||||
# @(#) 2019-04-09: fix bad math in ZFS script & HC message [Patrick Van der Veken]
|
# @(#) 2019-04-09: fix bad math in ZFS script & HC message [Patrick Van der Veken]
|
||||||
# @(#) 2019-04-12: small fixes [Patrick Van der Veken]
|
# @(#) 2019-04-12: small fixes [Patrick Van der Veken]
|
||||||
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
# @(#) 2019-05-14: small fixes [Patrick Van der Veken]
|
||||||
# @(#) 2020-01-27: newline config value check [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 +37,7 @@ function check_exadata_zfs_share_usage
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2020-01-27" # YYYY-MM-DD
|
typeset _VERSION="2019-05-14" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# usage query script -- DO NOT CHANGE --
|
# usage query script -- DO NOT CHANGE --
|
||||||
# prj1:share1:16
|
# prj1:share1:16
|
||||||
@ -233,13 +232,6 @@ do
|
|||||||
_CFG_ZFS_LINE=$(grep -E -e "^zfs:${_ZFS_HOST}:${_PROJECT_NAME}:${_SHARE_NAME}:" ${_CONFIG_FILE} 2>/dev/null)
|
_CFG_ZFS_LINE=$(grep -E -e "^zfs:${_ZFS_HOST}:${_PROJECT_NAME}:${_SHARE_NAME}:" ${_CONFIG_FILE} 2>/dev/null)
|
||||||
if [[ -n "${_CFG_ZFS_LINE}" ]]
|
if [[ -n "${_CFG_ZFS_LINE}" ]]
|
||||||
then
|
then
|
||||||
data_has_newline "${_CFG_ZFS_LINE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "ignoring ${_ZFS_HOST}:${_PROJECT_NAME}:${_SHARE_NAME} because it parses to multiple results in ${_CONFIG_FILE}"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "found custom definition for ${_ZFS_HOST}:${_PROJECT_NAME}/${_SHARE_NAME} in configuration file ${_CONFIG_FILE}"
|
(( ARG_DEBUG > 0 )) && debug "found custom definition for ${_ZFS_HOST}:${_PROJECT_NAME}/${_SHARE_NAME} in configuration file ${_CONFIG_FILE}"
|
||||||
_CFG_SPACE_THRESHOLD=$(print "${_CFG_ZFS_LINE}" | cut -f5 -d':' 2>/dev/null)
|
_CFG_SPACE_THRESHOLD=$(print "${_CFG_ZFS_LINE}" | cut -f5 -d':' 2>/dev/null)
|
||||||
# null value means general threshold
|
# null value means general threshold
|
||||||
|
@ -1,257 +0,0 @@
|
|||||||
#!/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
|
|
||||||
#******************************************************************************
|
|
@ -19,13 +19,12 @@
|
|||||||
# @(#) MAIN: check_hpux_cron_status
|
# @(#) MAIN: check_hpux_cron_status
|
||||||
# DOES: see _show_usage()
|
# DOES: see _show_usage()
|
||||||
# EXPECTS: n/a
|
# EXPECTS: n/a
|
||||||
# REQUIRES: data_is_numeric(), data_comma2space(), init_hc(), log_hc()
|
# REQUIRES: data_comma2space(), init_hc(), log_hc()
|
||||||
#
|
#
|
||||||
# @(#) HISTORY:
|
# @(#) HISTORY:
|
||||||
# @(#) 2018-02-08: initial version [Patrick Van der Veken]µ
|
# @(#) 2018-02-08: initial version [Patrick Van der Veken]µ
|
||||||
# @(#) 2018-02-13: fix to avoid log check if cron is not active [Patrick Van der Veken]
|
# @(#) 2018-02-13: fix to avoid log check if cron is not active [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
# @(#) 2021-03-25: make _WAIT_TIME & _CRON_LOG_FILE configurable [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,25 +33,20 @@
|
|||||||
function check_hpux_cron_status
|
function check_hpux_cron_status
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CRON_LOG_FILE="/var/adm/cron/log"
|
||||||
typeset _VERSION="2021-03-25" # YYYY-MM-DD
|
typeset _WAIT_TIME=10
|
||||||
|
typeset _VERSION="2019-02-16" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||||
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 _MSG=""
|
typeset _MSG=""
|
||||||
typeset _STC=0
|
typeset _STC=0
|
||||||
typeset _CFG_HEALTHY=""
|
|
||||||
typeset _LOG_HEALTHY=0
|
typeset _LOG_HEALTHY=0
|
||||||
typeset _CFG_CRON_LOG_FILE=""
|
|
||||||
typeset _CFG_WAIT_TIME=""
|
|
||||||
typeset _LOG_HEALTHY=0
|
|
||||||
typeset _CRON_LOG_FILE=""
|
|
||||||
typeset _WAIT_TIME=""
|
|
||||||
typeset _JOB_ID=""
|
typeset _JOB_ID=""
|
||||||
typeset _AT_BIN=""
|
typeset _AT_BIN=""
|
||||||
|
|
||||||
@ -61,56 +55,11 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage "${0}" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||||
;;
|
;;
|
||||||
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
|
|
||||||
_CFG_WAIT_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'wait_time')
|
|
||||||
if [[ -z "${_CFG_WAIT_TIME}" ]]
|
|
||||||
then
|
|
||||||
# default
|
|
||||||
_WAIT_TIME=10
|
|
||||||
log "setting value for parameter wait_time to its default (${_WAIT_TIME})"
|
|
||||||
else
|
|
||||||
data_is_numeric "${_CFG_WAIT_TIME}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "wait time parameter is not numeric in configuration file ${_CONFIG_FILE}"
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
_WAIT_TIME=${_CFG_WAIT_TIME}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
_CFG_CRON_LOG_FILE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'cron_log')
|
|
||||||
if [[ -z "${_CFG_CRON_LOG_FILE}" ]]
|
|
||||||
then
|
|
||||||
# default
|
|
||||||
_CRON_LOG_FILE="/var/adm/cron/log"
|
|
||||||
log "setting value for parameter cron_log to its default (${_CRON_LOG_FILE})"
|
|
||||||
else
|
|
||||||
_CRON_LOG_FILE="${_CFG_CRON_LOG_FILE}"
|
|
||||||
log "setting value for parameter cron_log (${_CRON_LOG_FILE})"
|
|
||||||
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
|
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
||||||
if (( _LOG_HEALTHY > 0 ))
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
@ -125,20 +74,10 @@ else
|
|||||||
log "not logging/showing passed health checks"
|
log "not logging/showing passed health checks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check timeout (_WAIT_TIME must be at least 30 secs smaller than health check timeout)
|
|
||||||
if (( _WAIT_TIME > 0 ))
|
|
||||||
then
|
|
||||||
if (( (_WAIT_TIME + 30) > HC_TIME_OUT ))
|
|
||||||
then
|
|
||||||
warn "wait time value will conflict with health check timeout. Specify a (larger) --timeout value"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---- process state ----
|
# ---- process state ----
|
||||||
# try the pgrep way (note: old pgreps do not support '-c')
|
# try the pgrep way (note: old pgreps do not support '-c')
|
||||||
(( ARG_DEBUG > 0 )) && debug "checking cron service via pgrep"
|
(( ARG_DEBUG > 0 )) && debug "checking cron service via pgrep"
|
||||||
(( $(pgrep -u root cron 2>>"${HC_STDERR_LOG}" | wc -l 2>/dev/null) == 0 )) && _STC=1
|
(( $(pgrep -u root cron 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1
|
||||||
|
|
||||||
# evaluate results
|
# evaluate results
|
||||||
case ${_STC} in
|
case ${_STC} in
|
||||||
@ -160,30 +99,18 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ---- log state ----
|
# ---- log state ----
|
||||||
# check cron log file
|
_AT_BIN="$(command -v at 2>>${HC_STDERR_LOG})"
|
||||||
if [[ ! -r ${_CRON_LOG_FILE} ]]
|
|
||||||
then
|
|
||||||
_MSG="cron log does not exist (${_CRON_LOG_FILE})"
|
|
||||||
_STC=1
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" 1 "${_MSG}"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
# create test event
|
|
||||||
_AT_BIN=$(command -v at 2>>"${HC_STDERR_LOG}")
|
|
||||||
if [[ -x ${_AT_BIN} && -n "${_AT_BIN}" ]]
|
if [[ -x ${_AT_BIN} && -n "${_AT_BIN}" ]]
|
||||||
then
|
then
|
||||||
# start test job
|
# start test job
|
||||||
(( ARG_DEBUG > 0 )) && debug "checking cron log via {${_AT_BIN}}"
|
(( ARG_DEBUG > 0 )) && debug "checking cron log via {${_AT_BIN}}"
|
||||||
(echo "*** CHECK LOG ***" >/dev/null | ${_AT_BIN} now) >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
(echo "*** CHECK LOG ***" >/dev/null | ${_AT_BIN} now) >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||||
sleep "${_WAIT_TIME}"
|
sleep ${_WAIT_TIME}
|
||||||
if (( $(grep -c 'cron may not be running' "${HC_STDERR_LOG}" 2>/dev/null) == 0 ))
|
if (( $(grep -c 'cron may not be running' ${HC_STDERR_LOG} 2>/dev/null) == 0 ))
|
||||||
then
|
then
|
||||||
# find job results
|
# find job results
|
||||||
_JOB_ID=$(grep -E -e '^job' "${HC_STDERR_LOG}" 2>/dev/null | awk '{ print $2}' 2>/dev/null)
|
_JOB_ID=$(grep -E -e '^job' ${HC_STDERR_LOG} 2>/dev/null | awk '{ print $2}' 2>/dev/null)
|
||||||
if [[ -n "${_JOB_ID}" ]] && (( $(grep -c "${_JOB_ID}" "${_CRON_LOG_FILE}" 2>/dev/null) > 0 ))
|
if [[ -n "${_JOB_ID}" ]] && (( $(grep -c "${_JOB_ID}" ${_CRON_LOG_FILE} 2>/dev/null) > 0 ))
|
||||||
then
|
then
|
||||||
_MSG="cron is logging correctly, schedule via {${_AT_BIN}} OK"
|
_MSG="cron is logging correctly, schedule via {${_AT_BIN}} OK"
|
||||||
_STC=0
|
_STC=0
|
||||||
@ -198,7 +125,7 @@ then
|
|||||||
else
|
else
|
||||||
# check cron log itself
|
# check cron log itself
|
||||||
(( ARG_DEBUG > 0 )) && debug "checking cron log via file check"
|
(( ARG_DEBUG > 0 )) && debug "checking cron log via file check"
|
||||||
if [[ -s ${_CRON_LOG_FILE} ]]
|
if [[ -r ${_CRON_LOG_FILE} ]] && [[ -s ${_CRON_LOG_FILE} ]]
|
||||||
then
|
then
|
||||||
_MSG="cron is logging correctly (${_CRON_LOG_FILE})"
|
_MSG="cron is logging correctly (${_CRON_LOG_FILE})"
|
||||||
_STC=0
|
_STC=0
|
||||||
@ -221,12 +148,9 @@ function _show_usage
|
|||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
CONFIG : $3 with parameters:
|
CONFIG : $3
|
||||||
log_healthy=<yes|no>
|
|
||||||
wait_time=<seconds>
|
|
||||||
cron_log=<file_path>
|
|
||||||
PURPOSE : Checks whether cron (CRON) service is running and whether cron is
|
PURPOSE : Checks whether cron (CRON) service is running and whether cron is
|
||||||
actually logging to the cron log file.
|
actually logging to ${_CRON_LOG_FILE}.
|
||||||
LOG HEALTHY : Supported
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
@ -1,212 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) check_hpux_defunct_processes.sh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2021 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_defunct_processes
|
|
||||||
# DOES: see _show_usage()
|
|
||||||
# EXPECTS: n/a
|
|
||||||
# REQUIRES: data_comma2space(), data_is_numeric(), init_hc(), log_hc()
|
|
||||||
#
|
|
||||||
# @(#) HISTORY:
|
|
||||||
# @(#) 2021-04-07: initial version [Patrick Van der Veken]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function check_hpux_defunct_processes
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
|
||||||
typeset _VERSION="2021-04-07" # YYYY-MM-DD
|
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # 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_GROUP_BY_PPID=""
|
|
||||||
typeset _GROUP_BY_PPID=""
|
|
||||||
typeset _CFG_PROCESS_THRESHOLD=""
|
|
||||||
typeset _PROCESS_THRESHOLD=""
|
|
||||||
typeset _CFG_HEALTHY=""
|
|
||||||
typeset _LOG_HEALTHY=0
|
|
||||||
typeset _DEFUNCT_PROCS=""
|
|
||||||
typeset _NUM_DEFUNCT_PROCS=""
|
|
||||||
typeset _PPID=""
|
|
||||||
|
|
||||||
# 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 required configuration values
|
|
||||||
_CFG_PROCESS_THRESHOLD=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'process_threshold')
|
|
||||||
if [[ -z "${_CFG_PROCESS_THRESHOLD}" ]]
|
|
||||||
then
|
|
||||||
# default
|
|
||||||
_PROCESS_THRESHOLD=10
|
|
||||||
log "setting value for parameter process_threshold to its default (10)"
|
|
||||||
else
|
|
||||||
data_is_numeric "${_CFG_PROCESS_THRESHOLD}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "value for parameter process_threshold in configuration file ${_CONFIG_FILE} is invalid"
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
_PROCESS_THRESHOLD=${_CFG_PROCESS_THRESHOLD}
|
|
||||||
log "setting value for parameter collect_interval (${_PROCESS_THRESHOLD})"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
_CFG_GROUP_BY_PPID=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'group_by_ppid')
|
|
||||||
case "${_CFG_GROUP_BY_PPID}" in
|
|
||||||
no|NO|No)
|
|
||||||
_GROUP_BY_PPID=0
|
|
||||||
log "setting value for parameter group_by_ppid (No)"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# default
|
|
||||||
_GROUP_BY_PPID=1
|
|
||||||
log "setting value for parameter group_by_ppid to its default (Yes)"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
_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
|
|
||||||
|
|
||||||
# collect defunct processes
|
|
||||||
# shellcheck disable=SC2009
|
|
||||||
_DEFUNCT_PROCS=$(UNIX95=1 ps -eo ppid,pid,comm,etime 2>"${HC_STDERR_LOG}" | tee -a "${HC_STDOUT_LOG}" 2>/dev/null | grep '[d]efunct' 2>/dev/null)
|
|
||||||
|
|
||||||
# check defunct processes
|
|
||||||
if [[ -z "${_DEFUNCT_PROCS}" ]]
|
|
||||||
then
|
|
||||||
_MSG="no defunct process(es) detected"
|
|
||||||
_STC=0
|
|
||||||
if (( _LOG_HEALTHY > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
if (( _GROUP_BY_PPID > 0 ))
|
|
||||||
then
|
|
||||||
# per by PPID
|
|
||||||
print -R "${_DEFUNCT_PROCS}" | awk '
|
|
||||||
|
|
||||||
{
|
|
||||||
# count PIDs per PPID
|
|
||||||
counts[$1]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
END {
|
|
||||||
for (i in counts) print i ":" counts[i]
|
|
||||||
}' 2>/dev/null | while IFS=":" read -r _PPID _NUM_DEFUNCT_PROCS
|
|
||||||
do
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "awk found PPID: ${_PPID} with # procs: ${_NUM_DEFUNCT_PROCS}"
|
|
||||||
if (( _NUM_DEFUNCT_PROCS <= _PROCESS_THRESHOLD ))
|
|
||||||
then
|
|
||||||
_MSG="defunct process(es) detected for PPID (${_PPID}) but are still under threshold (${_NUM_DEFUNCT_PROCS}<=${_PROCESS_THRESHOLD})"
|
|
||||||
_STC=0
|
|
||||||
else
|
|
||||||
_MSG="defunct process(es) detected for PPID (${_PPID}) and are over threshold (${_NUM_DEFUNCT_PROCS}>${_PROCESS_THRESHOLD})"
|
|
||||||
_STC=1
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_NUM_DEFUNCT_PROCS}" "${_PROCESS_THRESHOLD}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
_NUM_DEFUNCT_PROCS=$(print -R "${_DEFUNCT_PROCS}" | wc -l 2>/dev/null)
|
|
||||||
if (( _NUM_DEFUNCT_PROCS <= _PROCESS_THRESHOLD ))
|
|
||||||
then
|
|
||||||
_MSG="defunct process(es) detected but are still under threshold (${_NUM_DEFUNCT_PROCS}<=${_PROCESS_THRESHOLD})"
|
|
||||||
_STC=0
|
|
||||||
else
|
|
||||||
_MSG="defunct process(es) detected and are over threshold (${_NUM_DEFUNCT_PROCS}>${_PROCESS_THRESHOLD})"
|
|
||||||
_STC=1
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_NUM_DEFUNCT_PROCS}" "${_PROCESS_THRESHOLD}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function _show_usage
|
|
||||||
{
|
|
||||||
cat <<- EOT
|
|
||||||
NAME : $1
|
|
||||||
VERSION : $2
|
|
||||||
CONFIG : $3 with parameters:
|
|
||||||
log_healthy=<yes|no>
|
|
||||||
process_threshold=<#_of_processes>
|
|
||||||
group_by_ppid=<yes|no>
|
|
||||||
PURPOSE : Checks whether there are (too many) defunct processes on the host.
|
|
||||||
LOG HEALTHY : Supported
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -29,8 +29,6 @@
|
|||||||
# @(#) 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]
|
||||||
# @(#) 2020-09-05: fix log_hc call for failed checksum + quote fix [Patrick Van der Veken]
|
|
||||||
# @(#) 2021-01-13: fix log_hc call (wrong logic) [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 +38,7 @@ function check_hpux_file_change
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2021-01-13" # YYYY-MM-DD
|
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -277,7 +275,7 @@ do
|
|||||||
openssl-sha256)
|
openssl-sha256)
|
||||||
if (( _USE_OPENSSL == 1 ))
|
if (( _USE_OPENSSL == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
||||||
_FILE_TYPE="openssl-sha256"
|
_FILE_TYPE="openssl-sha256"
|
||||||
else
|
else
|
||||||
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
||||||
@ -287,7 +285,7 @@ do
|
|||||||
cksum-crc32)
|
cksum-crc32)
|
||||||
if (( _USE_CKSUM == 1 ))
|
if (( _USE_CKSUM == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_CKSUM_BIN} "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
_FILE_CKSUM=$(${_CKSUM_BIN} ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
||||||
_FILE_TYPE="cksum-crc32"
|
_FILE_TYPE="cksum-crc32"
|
||||||
else
|
else
|
||||||
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
_MSG="cannot compute checksum [${_FILE_TYPE}] for ${_FILE_TO_CHECK}"
|
||||||
@ -303,11 +301,11 @@ do
|
|||||||
# new file
|
# new file
|
||||||
if (( _USE_OPENSSL == 1 ))
|
if (( _USE_OPENSSL == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
_FILE_CKSUM=$(${_OPENSSL_BIN} dgst -sha256 ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f2 -d'=' | tr -d ' ')
|
||||||
_FILE_TYPE="openssl-sha256"
|
_FILE_TYPE="openssl-sha256"
|
||||||
elif (( _USE_CKSUM == 1 ))
|
elif (( _USE_CKSUM == 1 ))
|
||||||
then
|
then
|
||||||
_FILE_CKSUM=$(${_CKSUM_BIN} "${_FILE_TO_CHECK}" 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
_FILE_CKSUM=$(${_CKSUM_BIN} ${_FILE_TO_CHECK} 2>>${HC_STDERR_LOG} | cut -f1 -d' ')
|
||||||
_FILE_TYPE="cksum-crc32"
|
_FILE_TYPE="cksum-crc32"
|
||||||
else
|
else
|
||||||
_MSG="cannot compute checksum (openssl/cksum) for ${_FILE_TO_CHECK}"
|
_MSG="cannot compute checksum (openssl/cksum) for ${_FILE_TO_CHECK}"
|
||||||
@ -323,7 +321,7 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# bounce failures back and jump to next file
|
# bounce failures back and jump to next file
|
||||||
if (( _LOG_HEALTHY > 0 && _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
continue
|
continue
|
||||||
@ -349,7 +347,7 @@ do
|
|||||||
printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE}
|
printf "%s|%s|%s\n" "${_FILE_TO_CHECK}" "${_FILE_TYPE}" "${_FILE_CKSUM}" >>${_TMP2_FILE}
|
||||||
|
|
||||||
# report with curr/exp values
|
# report with curr/exp values
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}"
|
log_hc "$0" ${_STC} "${_MSG}" "${_FILE_CKSUM}" "${_STATE_FILE_CKSUM}"
|
||||||
continue
|
continue
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
# @(#) 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 support for --log-healthy [Patrick Van der Veken]
|
# @(#) 2019-03-09: added support for --log-healthy [Patrick Van der Veken]
|
||||||
# @(#) 2021-04-07: quotes & shellcheck fixes [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!
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -44,13 +43,13 @@ function check_hpux_ioscan
|
|||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _IOSCAN_BIN="/usr/sbin/ioscan"
|
typeset _IOSCAN_BIN="/usr/sbin/ioscan"
|
||||||
typeset _IOSCAN_OPTS="-Fn"
|
typeset _IOSCAN_OPTS="-Fn"
|
||||||
typeset _VERSION="2021-04-07" # YYYY-MM-DD
|
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||||
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 _MSG=""
|
typeset _MSG=""
|
||||||
@ -72,7 +71,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage "${0}" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -155,8 +154,7 @@ else
|
|||||||
_IOSCAN_OPTS="${_IOSCAN_OPTS}u"
|
_IOSCAN_OPTS="${_IOSCAN_OPTS}u"
|
||||||
fi
|
fi
|
||||||
log "executing ioscan with options: ${_IOSCAN_OPTS}"
|
log "executing ioscan with options: ${_IOSCAN_OPTS}"
|
||||||
${_IOSCAN_BIN} ${_IOSCAN_OPTS} >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
${_IOSCAN_BIN} ${_IOSCAN_OPTS} >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
if (( $? > 0 ))
|
||||||
then
|
then
|
||||||
_MSG="unable to run command: {${_IOSCAN_BIN}}"
|
_MSG="unable to run command: {${_IOSCAN_BIN}}"
|
||||||
@ -168,13 +166,13 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# check for requested device classes
|
# check for requested device classes
|
||||||
grep -E -e ".*:.*:.*:.*:.*:.*:.*:.*:${_IOSCAN_CLASSES}:.*" "${HC_STDOUT_LOG}" 2>/dev/null |\
|
grep -E -e ".*:.*:.*:.*:.*:.*:.*:.*:${_IOSCAN_CLASSES}:.*" ${HC_STDOUT_LOG} 2>/dev/null |\
|
||||||
while read -r _IOSCAN_LINE
|
while read _IOSCAN_LINE
|
||||||
do
|
do
|
||||||
# possible states are: CLAIMED, UNCLAIMED, DIFF_HW, NO_HW, ERROR, SCAN
|
# possible states are: CLAIMED, UNCLAIMED, DIFF_HW, NO_HW, ERROR, SCAN
|
||||||
_HW_CLASS=$(print "${_IOSCAN_LINE}" | cut -f9 -d':')
|
_HW_CLASS="$(print ${_IOSCAN_LINE} | cut -f9 -d':')"
|
||||||
_HW_PATH=$(print "${_IOSCAN_LINE}" | cut -f11 -d':')
|
_HW_PATH="$(print ${_IOSCAN_LINE} | cut -f11 -d':')"
|
||||||
_HW_STATE=$(print "${_IOSCAN_LINE}" | cut -f16 -d':')
|
_HW_STATE="$(print ${_IOSCAN_LINE} | cut -f16 -d':')"
|
||||||
|
|
||||||
case "${_HW_STATE}" in
|
case "${_HW_STATE}" in
|
||||||
NO_HW)
|
NO_HW)
|
||||||
@ -216,6 +214,7 @@ function _show_usage
|
|||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
|
CONFIG : $3 with:
|
||||||
CONFIG : $3 with parameters:
|
CONFIG : $3 with parameters:
|
||||||
log_healthy=<yes|no>
|
log_healthy=<yes|no>
|
||||||
ioscan_classes=<list_of_device_classes_to_check>
|
ioscan_classes=<list_of_device_classes_to_check>
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
# @(#) with offset calculation [Patrick Van der Veken]
|
# @(#) with offset calculation [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: Text updates [Patrick Van der Veken]
|
# @(#) 2019-03-09: Text updates [Patrick Van der Veken]
|
||||||
# @(#) 2020-12-21: fixes 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,14 +39,14 @@ function check_hpux_ntp_status
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||||
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
typeset _NTPQ_BIN="/usr/sbin/ntpq"
|
typeset _NTPQ_BIN="/usr/sbin/ntpq"
|
||||||
typeset _NTPQ_OPTS="-pn"
|
typeset _NTPQ_OPTS="-pn"
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
typeset _ARGS=$(data_comma2space "$*")
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
typeset _ARG=""
|
typeset _ARG=""
|
||||||
@ -66,7 +65,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -149,10 +148,7 @@ case "${_NTP_PEER}" in
|
|||||||
_MSG="NTP is synchronizing against ${_NTP_PEER##*\*}"
|
_MSG="NTP is synchronizing against ${_NTP_PEER##*\*}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
fi
|
|
||||||
|
|
||||||
# 2) offset value
|
# 2) offset value
|
||||||
if (( _STC == 0 ))
|
if (( _STC == 0 ))
|
||||||
@ -169,10 +165,7 @@ then
|
|||||||
else
|
else
|
||||||
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
_MSG="NTP offset of ${_CURR_OFFSET} is within the acceptable range"
|
||||||
fi
|
fi
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# not numeric
|
# not numeric
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
# @(#) 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]
|
||||||
# @(#) 2020-12-27: add configuration check + quoting fixes [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,17 +34,16 @@
|
|||||||
function check_hpux_postfix_status
|
function check_hpux_postfix_status
|
||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _VERSION="2020-12-27" # YYYY-MM-DD
|
typeset _VERSION="2019-03-09" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||||
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 _POSTFIX_BIN=""
|
typeset _POSTFIX_BIN=""
|
||||||
typeset _POSTFIX_CHECKER=""
|
|
||||||
typeset _MSG=""
|
typeset _MSG=""
|
||||||
typeset _STC=0
|
typeset _STC=0
|
||||||
typeset _LOG_HEALTHY=0
|
typeset _LOG_HEALTHY=0
|
||||||
@ -55,7 +53,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -74,14 +72,10 @@ else
|
|||||||
log "not logging/showing passed health checks"
|
log "not logging/showing passed health checks"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# process state
|
|
||||||
|
|
||||||
_POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})"
|
_POSTFIX_BIN="$(command -v postfix 2>>${HC_STDERR_LOG})"
|
||||||
if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]]
|
if [[ -x ${_POSTFIX_BIN} && -n "${_POSTFIX_BIN}" ]]
|
||||||
then
|
then
|
||||||
${_POSTFIX_BIN} status >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
${_POSTFIX_BIN} status >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? == 0 ))
|
if (( $? == 0 ))
|
||||||
then
|
then
|
||||||
_MSG="postfix is running"
|
_MSG="postfix is running"
|
||||||
@ -93,34 +87,12 @@ else
|
|||||||
warn "postfix is not installed here"
|
warn "postfix is not installed here"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
# report result
|
||||||
# configuration state
|
|
||||||
_POSTFIX_CHECKER="$(command -v postconf 2>>${HC_STDERR_LOG})"
|
|
||||||
if [[ -x ${_POSTFIX_CHECKER} && -n "${_POSTFIX_CHECKER}" ]]
|
|
||||||
then
|
|
||||||
# dump configuration
|
|
||||||
${_POSTFIX_CHECKER} -n >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
_MSG="postfix configuration files have syntax error(s) {${_POSTFIX_CHECKER} -n}"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="postfix configuration files are syntactically correct"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
warn "skipping syntax check (unable to find syntax check tool)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -131,8 +103,7 @@ function _show_usage
|
|||||||
cat <<- EOT
|
cat <<- EOT
|
||||||
NAME : $1
|
NAME : $1
|
||||||
VERSION : $2
|
VERSION : $2
|
||||||
PURPOSE : Checks whether postfix (mail system) is running and whether the
|
PURPOSE : Checks whether postfix (mail system) is running
|
||||||
postfix configuration files are syntactically correct
|
|
||||||
LOG HEALTHY : Supported
|
LOG HEALTHY : Supported
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
# @(#) 2018-02-13: fix to avoid log check if syslogd is not active [Patrick Van der Veken]
|
# @(#) 2018-02-13: fix to avoid log check if syslogd is not active [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-09: text updates [Patrick Van der Veken]
|
# @(#) 2019-03-09: text updates [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
# @(#) 2019-10-07: fixed syslog.log checking [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,8 +35,8 @@ function check_hpux_syslogd_status
|
|||||||
{
|
{
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
# ------------------------- CONFIGURATION starts here -------------------------
|
||||||
typeset _SYSLOGD_PID_FILE="/var/run/syslog.pid"
|
typeset _SYSLOGD_PID_FILE="/var/run/syslog.pid"
|
||||||
typeset _SYSLOGD_LOG_FILE="/var/adm/syslog/syslog.log"
|
typeset _SYSLOGD_LOG_FILE="/var/adm/syslog.log"
|
||||||
typeset _VERSION="2019-10-07" # YYYY-MM-DD
|
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
@ -122,23 +121,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ---- log state ----
|
# ---- log state ----
|
||||||
# check syslog.log
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "checking syslogd log via file check"
|
|
||||||
if [[ -r ${_SYSLOGD_LOG_FILE} ]] && [[ -s ${_SYSLOGD_LOG_FILE} ]]
|
|
||||||
then
|
|
||||||
_MSG="syslog.log is present (${_SYSLOGD_LOG_FILE})"
|
|
||||||
_STC=0
|
|
||||||
else
|
|
||||||
_MSG="syslog.log is not present or empty (${_SYSLOGD_LOG_FILE})"
|
|
||||||
_STC=1
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
# check logger if syslog.log check did not fail
|
|
||||||
if (( _STC == 0 ))
|
|
||||||
then
|
|
||||||
_LOGGER_BIN="$(command -v logger 2>>${HC_STDERR_LOG})"
|
_LOGGER_BIN="$(command -v logger 2>>${HC_STDERR_LOG})"
|
||||||
if [[ -x ${_LOGGER_BIN} && -n "${_LOGGER_BIN}" ]]
|
if [[ -x ${_LOGGER_BIN} && -n "${_LOGGER_BIN}" ]]
|
||||||
then
|
then
|
||||||
@ -153,14 +135,22 @@ then
|
|||||||
_MSG="syslogd is not logging (correctly), write via {${_LOGGER_BIN}} NOK"
|
_MSG="syslogd is not logging (correctly), write via {${_LOGGER_BIN}} NOK"
|
||||||
_STC=1
|
_STC=1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
# check the syslog itself
|
||||||
|
(( ARG_DEBUG > 0 )) && debug "checking syslogd log via file check"
|
||||||
|
if [[ -r ${_SYSLOGD_LOG_FILE} ]] && [[ -s ${_SYSLOGD_LOG_FILE} ]]
|
||||||
|
then
|
||||||
|
_MSG="syslogd is logging correctly (${_CRON_LOG_FILE})"
|
||||||
|
_STC=0
|
||||||
|
else
|
||||||
|
_MSG="syslogd is not logging (correctly) (${_SYSLOGD_LOG_FILE})"
|
||||||
|
_STC=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
||||||
then
|
then
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
log_hc "$0" ${_STC} "${_MSG}"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "no logger facility found, skipping logger check"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1,349 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# @(#) check_hpux_uptime
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# @(#) Copyright (C) 2020 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_uptime
|
|
||||||
# DOES: see _show_usage()
|
|
||||||
# EXPECTS: see _show_usage()
|
|
||||||
# REQUIRES: data_is_numeric(), data_timestring_to_mins(), data_comma2space(),
|
|
||||||
# init_hc(), log_hc(), warn()
|
|
||||||
#
|
|
||||||
# @(#) HISTORY:
|
|
||||||
# @(#) 2020-12-21: initial version [Patrick Van der Veken]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function check_hpux_uptime
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
|
||||||
typeset _STATE_FILE="${STATE_PERM_DIR}/current.uptime"
|
|
||||||
typeset _VERSION="2020-12-21" # YYYY-MM-DD
|
|
||||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # 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 _LOG_HEALTHY=0
|
|
||||||
typeset _CFG_HEALTHY=""
|
|
||||||
typeset _CFG_CHECK_REBOOT=""
|
|
||||||
typeset _CFG_REBOOT_TIME=""
|
|
||||||
typeset _CFG_CHECK_OLD_AGE=""
|
|
||||||
typeset _CFG_OLD_AGE_TIME=""
|
|
||||||
typeset _CHECK_REBOOT=""
|
|
||||||
typeset _REBOOT_TIME=""
|
|
||||||
typeset _REBOOT_TIME_MINS=""
|
|
||||||
typeset _CHECK_OLD_AGE=""
|
|
||||||
typeset _OLD_AGE_TIME=""
|
|
||||||
typeset _OLD_AGE_TIME_MINS=""
|
|
||||||
typeset _CURRENT_UPTIME=""
|
|
||||||
typeset _CURRENT_UPTIME_MINS=""
|
|
||||||
typeset _INIT_TIME=""
|
|
||||||
typeset _PREVIOUS_UPTIME=""
|
|
||||||
typeset _PREVIOUS_UPTIME_MINS=""
|
|
||||||
typeset _THRESHOLD_UPTIME_MINS=""
|
|
||||||
|
|
||||||
# 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 config 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 required config values
|
|
||||||
_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
|
|
||||||
_CFG_CHECK_REBOOT=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_reboot')
|
|
||||||
case "${_CFG_CHECK_REBOOT}" in
|
|
||||||
no|No|NO)
|
|
||||||
_CHECK_REBOOT=0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_CHECK_REBOOT=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
_CFG_REBOOT_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'reboot_time')
|
|
||||||
if [[ -z "${_CFG_REBOOT_TIME}" ]]
|
|
||||||
then
|
|
||||||
# default
|
|
||||||
_REBOOT_TIME="60m"
|
|
||||||
else
|
|
||||||
_REBOOT_TIME="${_CFG_REBOOT_TIME}"
|
|
||||||
fi
|
|
||||||
_CFG_CHECK_OLD_AGE=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_old_age')
|
|
||||||
case "${_CFG_CHECK_OLD_AGE}" in
|
|
||||||
yes|Yes|Yes)
|
|
||||||
_CHECK_OLD_AGE=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_CHECK_OLD_AGE=0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
_CFG_OLD_AGE_TIME=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'old_age_time')
|
|
||||||
if [[ -z "${_CFG_OLD_AGE_TIME}" ]]
|
|
||||||
then
|
|
||||||
# default
|
|
||||||
_OLD_AGE_TIME="365d"
|
|
||||||
else
|
|
||||||
_OLD_AGE_TIME="${_CFG_OLD_AGE_TIME}"
|
|
||||||
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
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# read uptime from init process
|
|
||||||
# shellcheck disable=SC1007
|
|
||||||
_INIT_TIME=$(UNIX95= ps -p 1 -o etime 2>/dev/null | tail -1)
|
|
||||||
if [[ -n "${_INIT_TIME}" ]]
|
|
||||||
then
|
|
||||||
# calculate exact uptime (seconds)
|
|
||||||
_CURRENT_UPTIME=$(print "${_INIT_TIME}" |\
|
|
||||||
awk '
|
|
||||||
BEGIN { days = 0; hours = 0; mins = 0; seconds = 0 };
|
|
||||||
{
|
|
||||||
gsub(/[ \t]/, "");
|
|
||||||
# get days
|
|
||||||
split ($0, day_str, "-");
|
|
||||||
if (2 in day_str) {
|
|
||||||
# string has days
|
|
||||||
days = day_str[1];
|
|
||||||
split (day_str[2], hour_str, ":");
|
|
||||||
} else {
|
|
||||||
split (day_str[1], hour_str, ":");
|
|
||||||
}
|
|
||||||
# get hours/minutes/seconds
|
|
||||||
hours = hour_str[1];
|
|
||||||
mins = hour_str[2];
|
|
||||||
if (3 in hour_str) {
|
|
||||||
# string has seconds
|
|
||||||
secs = hour_str[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
END {
|
|
||||||
time = (days * 24 * 60 * 60) + (hours * 60 * 60) + (mins * 60) + secs;
|
|
||||||
print time;
|
|
||||||
}' 2>/dev/null)
|
|
||||||
data_is_numeric "${_CURRENT_UPTIME}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate uptime value (seconds)"
|
|
||||||
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME=${_CURRENT_UPTIME}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "uptime of INIT (1) process cannot be determined"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# read state file
|
|
||||||
if [[ -r ${_STATE_FILE} ]]
|
|
||||||
then
|
|
||||||
_PREVIOUS_UPTIME=$(<"${_STATE_FILE}")
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "failed to read state file at ${_STATE_FILE}"
|
|
||||||
_PREVIOUS_UPTIME=""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# convert uptimes values
|
|
||||||
_CURRENT_UPTIME_MINS=$(( _CURRENT_UPTIME / 60 ))
|
|
||||||
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate current uptime value (minutes)"
|
|
||||||
(( ARG_DEBUG )) && debug "_CURRENT_UPTIME_MINS=${_CURRENT_UPTIME_MINS}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
_PREVIOUS_UPTIME_MINS=$(( _PREVIOUS_UPTIME / 60 ))
|
|
||||||
data_is_numeric "${_CURRENT_UPTIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate previous uptime value (minutes)"
|
|
||||||
(( ARG_DEBUG )) && debug "_PREVIOUS_UPTIME_MINS=${_PREVIOUS_UPTIME_MINS}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# check reboot event
|
|
||||||
if (( _CHECK_REBOOT > 0 ))
|
|
||||||
then
|
|
||||||
# convert _REBOOT_TIME to minutes
|
|
||||||
_REBOOT_TIME_MINS=$(data_timestring_to_mins "${_REBOOT_TIME}")
|
|
||||||
data_is_numeric "${_REBOOT_TIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate 'reboot_time' value from configuration file ${_CONFIG_FILE}"
|
|
||||||
(( ARG_DEBUG )) && debug "_REBOOT_TIME=${_REBOOT_TIME}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# previous uptime missing?
|
|
||||||
if [[ -z "${_PREVIOUS_UPTIME}" ]]
|
|
||||||
then
|
|
||||||
if (( ARG_LOG > 0 ))
|
|
||||||
then
|
|
||||||
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "failed to update state file at ${_STATE_FILE}"
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
log "unable to find previously recorded uptime, resetting to current uptime"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "unable to find previously recorded uptime, resetting to current uptime"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# current uptime + reboot time is smaller than previous uptime?
|
|
||||||
_THRESHOLD_UPTIME_MINS=$(( _CURRENT_UPTIME_MINS + _REBOOT_TIME_MINS ))
|
|
||||||
if (( _THRESHOLD_UPTIME_MINS < _PREVIOUS_UPTIME_MINS ))
|
|
||||||
then
|
|
||||||
_MSG="reboot check: current uptime is NOK; check if reboot occurred"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="reboot check: current uptime is OK"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_THRESHOLD_UPTIME_MINS}" "${_PREVIOUS_UPTIME_MINS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# update state file
|
|
||||||
if (( ARG_LOG > 0 ))
|
|
||||||
then
|
|
||||||
print "${_CURRENT_UPTIME}" >"${_STATE_FILE}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "failed to update state file at ${_STATE_FILE}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "reboot check: not enabled"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# check old age event
|
|
||||||
if (( _CHECK_OLD_AGE > 0 ))
|
|
||||||
then
|
|
||||||
# convert _OLD_AGE_TIME to minutes
|
|
||||||
_OLD_AGE_TIME_MINS=$(data_timestring_to_mins "${_OLD_AGE_TIME}")
|
|
||||||
data_is_numeric "${_OLD_AGE_TIME_MINS}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
warn "unable to calculate 'old_age_time' value from configuration file ${_CONFIG_FILE}"
|
|
||||||
(( ARG_DEBUG )) && debug "_OLD_AGE_TIME=${_OLD_AGE_TIME}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# are we old age yet?
|
|
||||||
if (( _CURRENT_UPTIME_MINS > _OLD_AGE_TIME_MINS ))
|
|
||||||
then
|
|
||||||
_MSG="old_age check: current uptime is NOK; old age has arrived (>${_OLD_AGE_TIME})"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="old_age check: current uptime is OK"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" "${_CURRENT_UPTIME_MINS}" "${_OLD_AGE_TIME_MINS}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "old age check: not enabled"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function _show_usage
|
|
||||||
{
|
|
||||||
cat <<- EOT
|
|
||||||
NAME : $1
|
|
||||||
VERSION : $2
|
|
||||||
CONFIG : $3 with:
|
|
||||||
log_healthy=<yes|no>
|
|
||||||
check_reboot=<yes|no>
|
|
||||||
reboot_time=<timestring>
|
|
||||||
check_old_age=<yes|no>
|
|
||||||
old_age_time=<timestring>
|
|
||||||
PURPOSE : Checks for unexpected/unplanned reboot events based on uptime
|
|
||||||
values.
|
|
||||||
Checks whether the host has been up and running for too much time.
|
|
||||||
LOG HEALTHY : Supported
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# END of script
|
|
||||||
#------------------------------------------------------------------------------
|
|
@ -1,263 +0,0 @@
|
|||||||
#!/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-10-24" # 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")
|
|
||||||
(( $? > 0)) && {
|
|
||||||
_MSG="error in function {linux_has_service}"
|
|
||||||
log_hc "$0" 1 "${_MSG}"
|
|
||||||
# dump debug info
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
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)
|
|
||||||
(( $? > 0)) && {
|
|
||||||
_MSG="error in function {linux_runs_service }"
|
|
||||||
log_hc "$0" 1 "${_MSG}"
|
|
||||||
# dump debug info
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
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")
|
|
||||||
(( $? > 0)) && {
|
|
||||||
_MSG="error in function {linux_runs_service }"
|
|
||||||
log_hc "$0" 1 "${_MSG}"
|
|
||||||
# dump debug info
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
done
|
|
||||||
# check again if autofs is running
|
|
||||||
_IS_ACTIVE=$(linux_runs_service "autofs")
|
|
||||||
(( $? > 0)) && {
|
|
||||||
_MSG="error in function {linux_runs_service }"
|
|
||||||
log_hc "$0" 1 "${_MSG}"
|
|
||||||
# dump debug info
|
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
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
|
|
||||||
#******************************************************************************
|
|
@ -34,8 +34,6 @@
|
|||||||
# @(#) added support for --log-healthy [Patrick Van der Veken]
|
# @(#) added support for --log-healthy [Patrick Van der Veken]
|
||||||
# @(#) 2019-03-10: fix for burp v2
|
# @(#) 2019-03-10: fix for burp v2
|
||||||
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
# @(#) 2019-03-16: replace 'which' [Patrick Van der Veken]
|
||||||
# @(#) 2021-03-28: updated code for changing 'burp -v' option as of burp v2.2 +
|
|
||||||
# quote fixes [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!
|
||||||
#******************************************************************************
|
#******************************************************************************
|
||||||
@ -47,12 +45,12 @@ 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="2021-03-28" # YYYY-MM-DD
|
typeset _VERSION="2019-03-16" # YYYY-MM-DD
|
||||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
(( ARG_DEBUG > 0 && ARG_DEBUG_LEVEL > 0 )) && set ${DEBUG_OPTS}
|
||||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||||
typeset _ARGS=$(data_comma2space "$*")
|
typeset _ARGS=$(data_comma2space "$*")
|
||||||
typeset _ARG=""
|
typeset _ARG=""
|
||||||
@ -66,7 +64,6 @@ typeset _BURP_BACKUP_DIR=""
|
|||||||
typeset _BURP_CLIENTCONF_DIR=""
|
typeset _BURP_CLIENTCONF_DIR=""
|
||||||
typeset _BURP_CLIENT=""
|
typeset _BURP_CLIENT=""
|
||||||
typeset _BURP_VERSION=""
|
typeset _BURP_VERSION=""
|
||||||
typeset _BURP_V_OUTPUT=""
|
|
||||||
typeset _BURP_WARNINGS=""
|
typeset _BURP_WARNINGS=""
|
||||||
typeset _GNU_DATE=""
|
typeset _GNU_DATE=""
|
||||||
typeset _COUNT=1
|
typeset _COUNT=1
|
||||||
@ -78,7 +75,7 @@ for _ARG in ${_ARGS}
|
|||||||
do
|
do
|
||||||
case "${_ARG}" in
|
case "${_ARG}" in
|
||||||
help)
|
help)
|
||||||
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
_show_usage $0 ${_VERSION} ${_CONFIG_FILE} && return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -102,7 +99,7 @@ case "${_CFG_HEALTHY}" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# check for old-style configuration file (non-prefixed stanzas)
|
# check for old-style configuration file (non-prefixed stanzas)
|
||||||
_IS_OLD_STYLE=$(grep -c -E -e "^client:" "${_CONFIG_FILE}" 2>/dev/null)
|
_IS_OLD_STYLE=$(grep -c -E -e "^client:" ${_CONFIG_FILE} 2>/dev/null)
|
||||||
if (( _IS_OLD_STYLE == 0 ))
|
if (( _IS_OLD_STYLE == 0 ))
|
||||||
then
|
then
|
||||||
warn "no 'client:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
|
warn "no 'client:' stanza(s) found in ${_CONFIG_FILE}; possibly an old-style configuration?"
|
||||||
@ -126,7 +123,6 @@ 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)
|
||||||
data_is_numeric "${_GNU_DATE}"
|
data_is_numeric "${_GNU_DATE}"
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
if (( $? > 0 ))
|
||||||
then
|
then
|
||||||
warn "no capable GNU date found here"
|
warn "no capable GNU date found here"
|
||||||
@ -141,20 +137,8 @@ then
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# burp v1 or v2? (up to v2.1 burp -v; as of burp v2.2 use burp -V but we can still use burp -v with a workaround)
|
# burp v1 or v2?
|
||||||
_BURP_V_OUTPUT="$(${_BURP_BIN} -v 2>/dev/null)"
|
_BURP_VERSION="$(${_BURP_BIN} -v 2>/dev/null)"
|
||||||
# check if the output contains 'server version'
|
|
||||||
case "${_BURP_V_OUTPUT}" in
|
|
||||||
*Server\ version*)
|
|
||||||
# burp 2.2 and above
|
|
||||||
_BURP_VERSION=$(print "${_BURP_V_OUTPUT}" | grep "Server version" | awk -F":" '{ print $NF}')
|
|
||||||
_BURP_VERSION="burp-"$(data_strip_outer_space "${_BURP_VERSION}")
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# burp 2.1 and below
|
|
||||||
_BURP_VERSION="${_BURP_V_OUTPUT}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
(( ARG_DEBUG > 0 )) && debug "burp version: ${_BURP_VERSION}"
|
(( ARG_DEBUG > 0 )) && debug "burp version: ${_BURP_VERSION}"
|
||||||
case "${_BURP_VERSION}" in
|
case "${_BURP_VERSION}" in
|
||||||
burp-2*)
|
burp-2*)
|
||||||
@ -199,8 +183,8 @@ case "${_BURP_VERSION}" in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# check backup runs of clients
|
# check backup runs of clients
|
||||||
grep -E -e "^client:" "${_CONFIG_FILE}" 2>/dev/null |\
|
grep -E -e "^client:" ${_CONFIG_FILE} 2>/dev/null |\
|
||||||
while IFS=':' read -r _ _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=""
|
||||||
@ -238,10 +222,10 @@ do
|
|||||||
# ex.:
|
# ex.:
|
||||||
# Backup: 0000078 2016-11-27 03:39:03 (deletable)
|
# Backup: 0000078 2016-11-27 03:39:03 (deletable)
|
||||||
# Backup: 0000079 2016-12-04 03:59:04
|
# Backup: 0000079 2016-12-04 03:59:04
|
||||||
_BACKUP_STATS="$(${_BURP_BIN} -a l -C "${_BURP_CLIENT}" 2>>"${HC_STDERR_LOG}" | grep '^Backup' | tail -n 1 | cut -f2- -d':')"
|
_BACKUP_STATS="$(${_BURP_BIN} -a l -C ${_BURP_CLIENT} 2>>${HC_STDERR_LOG} | grep '^Backup' | tail -n 1 | cut -f2- -d':')"
|
||||||
if [[ -n "${_BACKUP_STATS}" ]]
|
if [[ -n "${_BACKUP_STATS}" ]]
|
||||||
then
|
then
|
||||||
_BACKUP_RUN="$(print "${_BACKUP_STATS}" | awk '{print $1}')"
|
_BACKUP_RUN="$(print ${_BACKUP_STATS} | awk '{print $1}')"
|
||||||
# output format: YYYYMMDD HHMM
|
# output format: YYYYMMDD HHMM
|
||||||
_BACKUP_DATE=$(print "${_BACKUP_STATS}" | awk '{gsub(/-/,"",$2); gsub(/:/,"",$3); print $2" "substr($3,0,4)}' 2>/dev/null)
|
_BACKUP_DATE=$(print "${_BACKUP_STATS}" | awk '{gsub(/-/,"",$2); gsub(/:/,"",$3); print $2" "substr($3,0,4)}' 2>/dev/null)
|
||||||
# convert to UNIX seconds
|
# convert to UNIX seconds
|
||||||
@ -283,16 +267,16 @@ do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [[ -r "${_BURP_BACKUP_DIR}"/"${_BURP_CLIENT}"/current/log.gz ]]
|
if [[ -r ${_BURP_BACKUP_DIR}/${_BURP_CLIENT}/current/log.gz ]]
|
||||||
then
|
then
|
||||||
_BACKUP_WARNINGS=$(zcat "${_BURP_BACKUP_DIR}"/"${_BURP_CLIENT}"/current/log.gz 2>/dev/null | grep -c "WARNING:" 2>/dev/null)
|
_BACKUP_WARNINGS=$(zcat ${_BURP_BACKUP_DIR}/${_BURP_CLIENT}/current/log.gz 2>/dev/null | grep -c "WARNING:" 2>/dev/null)
|
||||||
else
|
else
|
||||||
warn "could not find ${_BURP_BACKUP_DIR}/${_BURP_CLIENT}/current/log.gz"
|
warn "could not find ${_BURP_BACKUP_DIR}/${_BURP_CLIENT}/current/log.gz"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
burp-1*)
|
burp-1*)
|
||||||
_BACKUP_WARNINGS=$(${_BURP_BIN} -c ${_BURP_SERVER_CONFIG_FILE} -a S -C "${_BURP_CLIENT}" -b "${_BACKUP_RUN}" -z backup_stats 2>>"${HC_STDERR_LOG}" |\
|
_BACKUP_WARNINGS=$(${_BURP_BIN} -c ${_BURP_SERVER_CONFIG_FILE} -a S -C ${_BURP_CLIENT} -b ${_BACKUP_RUN} -z backup_stats 2>>${HC_STDERR_LOG} |\
|
||||||
grep '^warnings' 2>/dev/null | cut -f2 -d':' 2>/dev/null)
|
grep '^warnings' 2>/dev/null | cut -f2 -d':' 2>/dev/null)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -341,16 +325,16 @@ do
|
|||||||
# 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}
|
||||||
case "${_BURP_VERSION}" in
|
case "${_BURP_VERSION}" in
|
||||||
burp-2*)
|
burp-2*)
|
||||||
if [[ -r "${_BURP_BACKUP_DIR}"/"${_BURP_CLIENT}"/current/log.gz ]]
|
if [[ -r ${_BURP_BACKUP_DIR}/${_BURP_CLIENT}/current/log.gz ]]
|
||||||
then
|
then
|
||||||
zcat "${_BURP_BACKUP_DIR}"/"${_BURP_CLIENT}"/current/log.gz >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
zcat ${_BURP_BACKUP_DIR}/${_BURP_CLIENT}/current/log.gz >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
burp-1*)
|
burp-1*)
|
||||||
${_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}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
@ -1,209 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) check_linux_dovecot_status.sh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2020 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_dovecot_status
|
|
||||||
# DOES: see _show_usage()
|
|
||||||
# EXPECTS: n/a
|
|
||||||
# REQUIRES: data_comma2space(), linux_get_init(), init_hc(), log_hc(), warn()
|
|
||||||
#
|
|
||||||
# @(#) HISTORY:
|
|
||||||
# @(#) 2020-12-27: initial version [Patrick Van der Veken]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function check_linux_dovecot_status
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _DOVECOT_INIT_SCRIPT="/etc/init.d/dovecot"
|
|
||||||
typeset _DOVECOT_SYSTEMD_SERVICE="dovecot.service"
|
|
||||||
typeset _VERSION="2020-12-27" # 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 _DOVECOT_BIN=""
|
|
||||||
typeset _DOVECOT_CHECKER=""
|
|
||||||
typeset _MSG=""
|
|
||||||
typeset _STC=0
|
|
||||||
typeset _LOG_HEALTHY=0
|
|
||||||
typeset _RC=0
|
|
||||||
typeset _CHECK_SYSTEMD_SERVICE=0
|
|
||||||
|
|
||||||
# handle arguments (originally comma-separated)
|
|
||||||
for _ARG in ${_ARGS}
|
|
||||||
do
|
|
||||||
case "${_ARG}" in
|
|
||||||
help)
|
|
||||||
_show_usage "$0" "${_VERSION}" "${_CONFIG_FILE}" && return 0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# log_healthy
|
|
||||||
(( ARG_LOG_HEALTHY > 0 )) && _LOG_HEALTHY=1
|
|
||||||
if (( _LOG_HEALTHY > 0 ))
|
|
||||||
then
|
|
||||||
if (( ARG_LOG > 0 ))
|
|
||||||
then
|
|
||||||
log "logging/showing passed health checks"
|
|
||||||
else
|
|
||||||
log "showing passed health checks (but not logging)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log "not logging/showing passed health checks"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# process state
|
|
||||||
|
|
||||||
# 1) try using the init ways
|
|
||||||
linux_get_init
|
|
||||||
case "${LINUX_INIT}" in
|
|
||||||
'systemd')
|
|
||||||
# Debian8/Ubuntu16 do not correctly report a unit file for dovecot,
|
|
||||||
# do not check for it and instead just query systemd service
|
|
||||||
linux_get_distro
|
|
||||||
if [[ "${LINUX_DISTRO}" = "Debian" ]] && (( ${LINUX_RELEASE%%.*} < 9 ))
|
|
||||||
then
|
|
||||||
_CHECK_SYSTEMD_SERVICE=1
|
|
||||||
elif [[ "${LINUX_DISTRO}" = "Ubuntu" ]] && (( ${LINUX_RELEASE%%.*} < 17 ))
|
|
||||||
then
|
|
||||||
_CHECK_SYSTEMD_SERVICE=1
|
|
||||||
else
|
|
||||||
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_DOVECOT_SYSTEMD_SERVICE}")
|
|
||||||
fi
|
|
||||||
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
|
||||||
then
|
|
||||||
systemctl --quiet is-active ${_DOVECOT_SYSTEMD_SERVICE} 2>>"${HC_STDERR_LOG}" || _STC=1
|
|
||||||
else
|
|
||||||
warn "systemd unit file not found {${_DOVECOT_SYSTEMD_SERVICE}}"
|
|
||||||
_RC=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'upstart')
|
|
||||||
warn "code for upstart managed systems not implemented, NOOP"
|
|
||||||
_RC=1
|
|
||||||
;;
|
|
||||||
'sysv')
|
|
||||||
# check running SysV
|
|
||||||
if [[ -x ${_DOVECOT_INIT_SCRIPT} ]]
|
|
||||||
then
|
|
||||||
if (( $(${_DOVECOT_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 {${_DOVECOT_INIT_SCRIPT}}"
|
|
||||||
_RC=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_RC=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# 2) try the dovecot way
|
|
||||||
if (( _RC > 0 ))
|
|
||||||
then
|
|
||||||
_DOVECOT_BIN="$(command -v dovecot 2>>${HC_STDERR_LOG})"
|
|
||||||
if [[ -x ${_DOVECOT_BIN} && -n "${_DOVECOT_BIN}" ]]
|
|
||||||
then
|
|
||||||
if (( $(${_DOVECOT_BIN} status 2>>"${HC_STDERR_LOG}" | grep -c -i 'is running' 2>/dev/null) == 0 ))
|
|
||||||
then
|
|
||||||
_RC=1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "dovecot is not installed here"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 3) try the pgrep way (note: old pgreps do not support '-c')
|
|
||||||
if (( _RC > 0 ))
|
|
||||||
then
|
|
||||||
(( $(pgrep -u dovecot 2>>"${HC_STDERR_LOG}" | wc -l 2>/dev/null) == 0 )) && _STC=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# evaluate results
|
|
||||||
case ${_STC} in
|
|
||||||
0)
|
|
||||||
_MSG="dovecot is running"
|
|
||||||
;;
|
|
||||||
1)
|
|
||||||
_MSG="dovecot is not running"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_MSG="could not determine status of dovecot"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# configuration state
|
|
||||||
_DOVECOT_CHECKER="$(command -v doveconf 2>>${HC_STDERR_LOG})"
|
|
||||||
if [[ -x ${_DOVECOT_CHECKER} && -n "${_DOVECOT_CHECKER}" ]]
|
|
||||||
then
|
|
||||||
# dump configuration
|
|
||||||
${_DOVECOT_CHECKER} -n >>"${HC_STDOUT_LOG}" 2>>"${HC_STDERR_LOG}"
|
|
||||||
# shellcheck disable=SC2181
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
_MSG="dovecot configuration files have syntax error(s) {${_DOVECOT_CHECKER} -n}"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_MSG="dovecot configuration files are syntactically correct"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "skipping syntax check (unable to find syntax check tool)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function _show_usage
|
|
||||||
{
|
|
||||||
cat <<- EOT
|
|
||||||
NAME : $1
|
|
||||||
VERSION : $2
|
|
||||||
PURPOSE : Checks whether dovecot (mail system) is running and whether the
|
|
||||||
dovecot configuration files are syntactically correct
|
|
||||||
LOG HEALTHY : Supported
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
@ -1,266 +0,0 @@
|
|||||||
#!/usr/bin/env ksh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) check_linux_fail2ban_status.sh
|
|
||||||
#******************************************************************************
|
|
||||||
# @(#) Copyright (C) 2020 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_fail2ban_status
|
|
||||||
# DOES: see _show_usage()
|
|
||||||
# EXPECTS: n/a
|
|
||||||
# REQUIRES: data_comma2newline(), data_comma2space(), linux_get_init(), init_hc(),
|
|
||||||
# log(), log_hc(), warn()
|
|
||||||
#
|
|
||||||
# @(#) HISTORY:
|
|
||||||
# @(#) 2020-10-18: initial version [Patrick Van der Veken]
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
|
||||||
#******************************************************************************
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function check_linux_fail2ban_status
|
|
||||||
{
|
|
||||||
# ------------------------- CONFIGURATION starts here -------------------------
|
|
||||||
typeset _FAIL2BAN_INIT_SCRIPT="/etc/init.d/fail2ban"
|
|
||||||
typeset _FAIL2BAN_SYSTEMD_SERVICE="fail2ban.service"
|
|
||||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
|
||||||
typeset _VERSION="2020-10-18" # 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 _CHECK_SYSTEMD_SERVICE=0
|
|
||||||
typeset _CFG_HEALTHY=""
|
|
||||||
typeset _LOG_HEALTHY=0
|
|
||||||
typeset _CFG_CHECK_JAILS=""
|
|
||||||
typeset _CFG_CHECK_TYPE=""
|
|
||||||
typeset _DO_PGREP=0
|
|
||||||
typeset _DO_CHECK_JAIL=1
|
|
||||||
typeset _CHECK_JAIL=""
|
|
||||||
typeset _JAIL_OUTPUT=""
|
|
||||||
typeset _FAILED_NUM=0
|
|
||||||
typeset _BANNED_NUM=0
|
|
||||||
typeset _RC=0
|
|
||||||
|
|
||||||
# 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_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_CHECK_JAILS=$(_CONFIG_FILE="${_CONFIG_FILE}" data_get_lvalue_from_config 'check_jails')
|
|
||||||
if [[ -n "${_CFG_CHECK_JAILS}" ]]
|
|
||||||
then
|
|
||||||
log "setting jail list to ${_CFG_CHECK_JAILS}"
|
|
||||||
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
|
|
||||||
(( 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 fail2ban-server
|
|
||||||
_FAIL2BAN_BIN="$(command -v fail2ban-server 2>>${HC_STDERR_LOG})"
|
|
||||||
if [[ -x ${_FAIL2BAN_BIN} && -n "${_FAIL2BAN_BIN}" ]]
|
|
||||||
then
|
|
||||||
log "fail2ban (server) is installed at {${_FAIL2BAN_BIN}}"
|
|
||||||
else
|
|
||||||
warn "fail2ban (server) is not installed here"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---- process state ----
|
|
||||||
# 1) try using the init ways
|
|
||||||
if (( _DO_PGREP == 0 ))
|
|
||||||
then
|
|
||||||
[[ -n "${LINUX_INIT}" ]] || linux_get_init
|
|
||||||
case "${LINUX_INIT}" in
|
|
||||||
'systemd')
|
|
||||||
_CHECK_SYSTEMD_SERVICE=$(linux_has_systemd_service "${_FAIL2BAN_SYSTEMD_SERVICE}")
|
|
||||||
if (( _CHECK_SYSTEMD_SERVICE > 0 ))
|
|
||||||
then
|
|
||||||
systemctl --quiet is-active ${_FAIL2BAN_SYSTEMD_SERVICE} 2>>${HC_STDERR_LOG} || _STC=1
|
|
||||||
else
|
|
||||||
warn "systemd unit file not found {${_FAIL2BAN_SYSTEMD_SERVICE}}"
|
|
||||||
_RC=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
'upstart')
|
|
||||||
warn "code for upstart managed systems not implemented, NOOP"
|
|
||||||
_RC=1
|
|
||||||
;;
|
|
||||||
'sysv')
|
|
||||||
# check running SysV
|
|
||||||
if [[ -x ${_FAIL2BAN_INIT_SCRIPT} ]]
|
|
||||||
then
|
|
||||||
if (( $(${_FAIL2BAN_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 {${_FAIL2BAN_INIT_SCRIPT}}"
|
|
||||||
_RC=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_RC=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2) try the pgrep way (note: old pgreps do not support '-c')
|
|
||||||
if (( _DO_PGREP > 0 || _RC > 0 ))
|
|
||||||
then
|
|
||||||
(( $(pgrep --full -u root "python.*${_FAIL2BAN_BIN}" 2>>${HC_STDERR_LOG} | wc -l 2>/dev/null) == 0 )) && _STC=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# evaluate results
|
|
||||||
case ${_STC} in
|
|
||||||
0)
|
|
||||||
_MSG="${_FAIL2BAN_BIN} is running"
|
|
||||||
;;
|
|
||||||
1)
|
|
||||||
_MSG="${_FAIL2BAN_BIN} is not running"
|
|
||||||
_DO_CHECK_JAIL=0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
_MSG="could not determine status of ${_FAIL2BAN_BIN}"
|
|
||||||
_DO_CHECK_JAIL=0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ---- jail states ----
|
|
||||||
if (( _DO_CHECK_JAIL == 0 ))
|
|
||||||
then
|
|
||||||
warn "fail2ban (server) is not running, skipping jail checks"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
_FAIL2BAN_BIN="$(command -v fail2ban-client 2>>${HC_STDERR_LOG})"
|
|
||||||
if [[ -x ${_FAIL2BAN_BIN} && -n "${_FAIL2BAN_BIN}" ]]
|
|
||||||
then
|
|
||||||
log "fail2ban (client) is installed at {${_FAIL2BAN_BIN}}"
|
|
||||||
else
|
|
||||||
warn "fail2ban (client) is not installed here, skipping jail checks"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
print "$(data_comma2newline ${_CFG_CHECK_JAILS})" | while read -r _CHECK_JAIL
|
|
||||||
do
|
|
||||||
_FAILED_NUM=0
|
|
||||||
_BANNED_NUM=0
|
|
||||||
_JAIL_OUTPUT=$(${_FAIL2BAN_BIN} status ${_CHECK_JAIL} 2>>${HC_STDERR_LOG})
|
|
||||||
if (( $? > 0 ))
|
|
||||||
then
|
|
||||||
_MSG="state of jail ${_CHECK_JAIL} is NOK"
|
|
||||||
_STC=1
|
|
||||||
else
|
|
||||||
_FAILED_NUM=$(print "${_JAIL_OUTPUT}" | grep -i 'currently failed' 2>/dev/null | awk -F':' '{ gsub(/[[:space:]]/,"",$2); print $2 }')
|
|
||||||
_BANNED_NUM=$(print "${_JAIL_OUTPUT}" | grep -i 'currently banned' 2>/dev/null | awk -F':' '{ gsub(/[[:space:]]/,"",$2); print $2 }')
|
|
||||||
_MSG="state of jail ${_CHECK_JAIL} is OK [failed=${_FAILED_NUM}/banned=${_BANNED_NUM}]"
|
|
||||||
_STC=0
|
|
||||||
fi
|
|
||||||
if (( _LOG_HEALTHY > 0 || _STC > 0 ))
|
|
||||||
then
|
|
||||||
# report only number of banned if OK
|
|
||||||
log_hc "$0" ${_STC} "${_MSG}" ${_BANNED_NUM} ${_BANNED_NUM}
|
|
||||||
fi
|
|
||||||
# add jail output to STDOUT
|
|
||||||
print "==== {${_FAIL2BAN_BIN} status ${_CHECK_JAIL}} ====" >>${HC_STDOUT_LOG}
|
|
||||||
print "${_JAIL_OUTPUT}" >>${HC_STDOUT_LOG}
|
|
||||||
done
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
function _show_usage
|
|
||||||
{
|
|
||||||
cat <<- EOT
|
|
||||||
NAME : $1
|
|
||||||
VERSION : $2
|
|
||||||
CONFIG : $3 with parameters:
|
|
||||||
log_healthy=<yes|no>
|
|
||||||
check_type=<auto|pgrep|sysv|systemd>
|
|
||||||
check_jails=<list_of_jails>
|
|
||||||
PURPOSE : Checks whether fail2ban (server service) is running and the state
|
|
||||||
of the configured jails.
|
|
||||||
LOG HEALTHY : Supported
|
|
||||||
|
|
||||||
EOT
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#******************************************************************************
|
|
||||||
# END of script
|
|
||||||
#******************************************************************************
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user