* Rewrite of HC_MSG handling
* Added JSON display plugin * Added dump_logs()
This commit is contained in:
parent
9fa69576ad
commit
703abca8c3
1
build/aix/hc_display_json/hc_display_json.reqs
Normal file
1
build/aix/hc_display_json/hc_display_json.reqs
Normal file
@ -0,0 +1 @@
|
||||
*prereq hc_aix.rte
|
27
build/aix/hc_display_json/hc_display_json.template
Normal file
27
build/aix/hc_display_json/hc_display_json.template
Normal file
@ -0,0 +1,27 @@
|
||||
Package Name: hc_display_json
|
||||
Package VRMF: %BUILD_DATE%
|
||||
Update: N
|
||||
Fileset
|
||||
Fileset Name: hc_display_json.rte
|
||||
Fileset VRMF: %BUILD_DATE%
|
||||
Fileset Description: Health Checker - core CSV plugin
|
||||
USRLIBLPPFiles
|
||||
EOUSRLIBLPPFiles
|
||||
ROOTLIBLPPFiles
|
||||
Post-installation Script: /export/nim/build/hc_display_json/scripts/hc_display_json.postinstall
|
||||
Unpost-installation Script: /export/nim/build/hc_display_json/scripts/hc_display_json.postuninstall
|
||||
EOROOTLIBLPPFiles
|
||||
Bosboot required: N
|
||||
License agreement acceptance required: N
|
||||
Include license files in this package: N
|
||||
Requisites: /export/nim/build/hc_display_json/hc_display_json.reqs
|
||||
USRFiles
|
||||
EOUSRFiles
|
||||
ROOT Part: Y
|
||||
ROOTFiles
|
||||
/opt/hc/lib
|
||||
/opt/hc/lib/core
|
||||
/opt/hc/lib/platform/aix/display_json.sh
|
||||
EOROOTFiles
|
||||
Relocatable: N
|
||||
EOFileset
|
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) post-install script for hc_display_json LPP package
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2017 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 ..."
|
||||
|
||||
# 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
|
||||
#******************************************************************************
|
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) post-uninstall script for hc_display_json LPP package
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2017 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 ..."
|
||||
|
||||
# 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
|
||||
#******************************************************************************
|
64
build/hpux/hc_display_json/hc_display_json.psf
Normal file
64
build/hpux/hc_display_json/hc_display_json.psf
Normal file
@ -0,0 +1,64 @@
|
||||
# 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-DISPLAY-JSON
|
||||
title "The Health Checker (HC) for UNIX (core JSON display plugin)"
|
||||
os_name HP-UX
|
||||
revision %BUILD_DATE%
|
||||
architecture HP-UX_B.11_32/64
|
||||
machine_type ia64*
|
||||
vendor_tag KUDOS
|
||||
contents HC-DISPLAY-JSON-MAIN,r=,a=,v=
|
||||
end
|
||||
|
||||
# Product definitions:
|
||||
product
|
||||
tag HC-DISPLAY-JSON-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 JSON display 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_display_json.postinstall
|
||||
postremove scripts/hc_display_json.postremove
|
||||
|
||||
# Fileset definitions:
|
||||
fileset
|
||||
tag core_plugins
|
||||
title UX Health Checker (core JSON display 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 ../../sources/lib/core=/opt/hc/lib/core
|
||||
file -m 755 display_json.sh
|
||||
end
|
||||
end
|
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) post-install script for HC-DISPLAY-JSON SD package
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2017 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 ..."
|
||||
|
||||
# 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
|
||||
#******************************************************************************
|
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) post-remove script for HC-DISPLAY-JSON SD package
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2017 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 ..."
|
||||
|
||||
# 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
|
||||
#******************************************************************************
|
69
build/linux/SPECS/hc-display-json.spec
Normal file
69
build/linux/SPECS/hc-display-json.spec
Normal file
@ -0,0 +1,69 @@
|
||||
%define build_timestamp %(date +"%Y%m%d")
|
||||
|
||||
Name: hc-display-json
|
||||
Version: %{build_timestamp}
|
||||
Release: 1
|
||||
|
||||
Summary: The KUDOS Health Checker (HC) for UNIX (JSON display 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 (display).
|
||||
|
||||
%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/lib/core/display_json.sh $RPM_BUILD_ROOT/opt/hc/lib/core/display_json.sh
|
||||
|
||||
%post
|
||||
# ------------------------- 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"
|
||||
|
||||
%postun
|
||||
# ------------------------- 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"
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,755)
|
||||
%dir /opt/hc/lib
|
||||
%dir /opt/hc/lib/core
|
||||
%attr(755, root, root) /opt/hc/lib/core/display_json.sh
|
||||
|
||||
%changelog
|
||||
* Sun May 20 2018 <patrick@kudos.be> - 0.0.1
|
||||
- Initial build
|
@ -37,7 +37,7 @@
|
||||
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
# define the version (YYYY-MM-DD)
|
||||
typeset -r SCRIPT_VERSION="2018-05-14"
|
||||
typeset -r SCRIPT_VERSION="2018-05-20"
|
||||
# location of parent directory containing KSH functions/HC plugins
|
||||
typeset -r FPATH_PARENT="/opt/hc/lib"
|
||||
# location of custom HC configuration files
|
||||
@ -58,8 +58,9 @@ typeset -r HOST_NAME="$(hostname)"
|
||||
typeset -r OS_NAME="$(uname -s)"
|
||||
typeset -r LOCK_DIR="${TMP_DIR}/.${SCRIPT_NAME}.lock"
|
||||
typeset -r HC_MSG_FILE="${TMP_DIR}/.${SCRIPT_NAME}.hc.msg.$$" # plugin messages files
|
||||
typeset -r LOG_SEP="|"
|
||||
typeset -r MSG_SEP="%%"
|
||||
typeset -r LOG_SEP="|" # single character only
|
||||
typeset -r MSG_SEP="%" # single character only
|
||||
typeset -r MAGIC_QUOTE="!_!" # magic quote
|
||||
typeset -r LOG_DIR="/var/opt/hc"
|
||||
typeset -r LOG_FILE="${LOG_DIR}/${SCRIPT_NAME}.log"
|
||||
typeset -r ARCHIVE_DIR="${LOG_DIR}/archive"
|
||||
|
@ -30,7 +30,7 @@
|
||||
function display_csv
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2018-05-14" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||
typeset _DISPLAY_SEP=";"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
@ -53,24 +53,47 @@ typeset _ID_BIT=""
|
||||
# parse $HC_MSG_VAR
|
||||
if [[ -n "${HC_MSG_VAR}" ]]
|
||||
then
|
||||
printf "%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s\n" "Health Check" "STC" "Message" "FAIL ID" \
|
||||
printf "%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s\n" "Health Check" "STC" "Message" "FAIL ID" \
|
||||
"Current Value" "Expected Value"
|
||||
|
||||
print "${HC_MSG_VAR}" | while read _HC_MSG_ENTRY
|
||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _DISPLAY_MSG_STC _DISPLAY_MSG_TIME _DISPLAY_MSG_TEXT _DISPLAY_MSG_CUR_VAL _DISPLAY_MSG_EXP_VAL
|
||||
do
|
||||
# split fields (awk is required for multi-char delimiter)
|
||||
_DISPLAY_MSG_STC=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $1'})
|
||||
_DISPLAY_MSG_TIME=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $2'})
|
||||
_DISPLAY_MSG_TEXT=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $3'})
|
||||
_DISPLAY_MSG_CUR_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $4'})
|
||||
_DISPLAY_MSG_EXP_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $5'})
|
||||
|
||||
# magically unquote if needed
|
||||
if [[ -n "${_DISPLAY_MSG_TEXT}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_TEXT}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_TEXT=$(data_magic_unquote "${_DISPLAY_MSG_TEXT}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_CUR_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_CUR_VAL=$(data_magic_unquote "${_DISPLAY_MSG_CUR_VAL}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_EXP_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}")
|
||||
fi
|
||||
fi
|
||||
if (( _DISPLAY_MSG_STC > 0 ))
|
||||
then
|
||||
_ID_BIT="${_DISPLAY_FAIL_ID}"
|
||||
else
|
||||
_ID_BIT=""
|
||||
fi
|
||||
# escape stuff
|
||||
_DISPLAY_MSG_TEXT=$(data_escape_csv "${_DISPLAY_MSG_TEXT}")
|
||||
_DISPLAY_MSG_CUR_VAL=$(data_escape_csv "${_DISPLAY_MSG_CUR_VAL}")
|
||||
_DISPLAY_MSG_EXP_VAL=$(data_escape_csv "${_DISPLAY_MSG_EXP_VAL}")
|
||||
|
||||
printf "%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s${_DISPLAY_SEP}%s\n" \
|
||||
"${_DISPLAY_HC}" \
|
||||
"${_DISPLAY_MSG_STC}" \
|
||||
|
113
sources/lib/core/display_json.sh
Normal file
113
sources/lib/core/display_json.sh
Normal file
@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env ksh
|
||||
#******************************************************************************
|
||||
# @(#) display_json.sh
|
||||
#******************************************************************************
|
||||
# @(#) Copyright (C) 2018 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: display_json
|
||||
# DOES: display HC results in JSON format (semi-colon as separator)
|
||||
# EXPECTS: 1=HC name [string], 2=HC FAIL_ID [string]
|
||||
# RETURNS: 0
|
||||
# REQUIRES: init_hc()
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
function display_json
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||
typeset _DISPLAY_SEP=";"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
init_hc "$0" "${_SUPPORTED_PLATFORMS}" "${_VERSION}"
|
||||
|
||||
typeset _DISPLAY_HC="$1"
|
||||
typeset _DISPLAY_FAIL_ID="$2"
|
||||
|
||||
typeset _HC_MSG_ENTRY=""
|
||||
typeset _DISPLAY_MSG_STC=""
|
||||
typeset _DISPLAY_MSG_TIME=""
|
||||
typeset _DISPLAY_MSG_TEXT=""
|
||||
typeset _DISPLAY_MSG_CUR_VAL=""
|
||||
typeset _DISPLAY_MSG_EXP_VAL=""
|
||||
typeset _ID_BIT=""
|
||||
|
||||
# parse $HC_MSG_VAR
|
||||
if [[ -n "${HC_MSG_VAR}" ]]
|
||||
then
|
||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _DISPLAY_MSG_STC _DISPLAY_MSG_TIME _DISPLAY_MSG_TEXT _DISPLAY_MSG_CUR_VAL _DISPLAY_MSG_EXP_VAL
|
||||
do
|
||||
# magically unquote if needed
|
||||
if [[ -n "${_DISPLAY_MSG_TEXT}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_TEXT}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_TEXT=$(data_magic_unquote "${_DISPLAY_MSG_TEXT}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_CUR_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_CUR_VAL=$(data_magic_unquote "${_DISPLAY_MSG_CUR_VAL}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_EXP_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}")
|
||||
fi
|
||||
fi
|
||||
if (( _DISPLAY_MSG_STC > 0 ))
|
||||
then
|
||||
_ID_BIT="${_DISPLAY_FAIL_ID}"
|
||||
else
|
||||
_ID_BIT=""
|
||||
fi
|
||||
# escape stuff
|
||||
_DISPLAY_MSG_TEXT=$(data_escape_json "${_DISPLAY_MSG_TEXT}")
|
||||
_DISPLAY_MSG_CUR_VAL=$(data_escape_json "${_DISPLAY_MSG_CUR_VAL}")
|
||||
_DISPLAY_MSG_EXP_VAL=$(data_escape_json "${_DISPLAY_MSG_EXP_VAL}")
|
||||
|
||||
|
||||
printf '{"hc":"%s","stc":"%s","time":"%s","fail_id":"%s","text":"%s","current_value":"%s","expected_value":"%s"}\n' \
|
||||
"${_DISPLAY_HC}" \
|
||||
"${_DISPLAY_MSG_STC}" \
|
||||
"${_DISPLAY_MSG_TIME}" \
|
||||
"${_ID_BIT}" \
|
||||
"${_DISPLAY_MSG_TEXT}" \
|
||||
"${_DISPLAY_MSG_CUR_VAL}" \
|
||||
"${_DISPLAY_MSG_EXP_VAL}"
|
||||
done
|
||||
else
|
||||
ARG_LOG=0 ARG_VERBOSE=1 log "INFO: no HC results to display"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#******************************************************************************
|
||||
# END of script
|
||||
#******************************************************************************
|
@ -30,7 +30,7 @@
|
||||
function display_terse
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2018-05-14" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -54,15 +54,33 @@ if [[ -n "${HC_MSG_VAR}" ]]
|
||||
then
|
||||
printf "%-30s\t%s\t%-16s\t%s\n" "HC" "STC" "FAIL ID" "Message"
|
||||
|
||||
print "${HC_MSG_VAR}" | while read _HC_MSG_ENTRY
|
||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _DISPLAY_MSG_STC _DISPLAY_MSG_TIME _DISPLAY_MSG_TEXT _DISPLAY_MSG_CUR_VAL _DISPLAY_MSG_EXP_VAL
|
||||
do
|
||||
# split fields (awk is required for multi-char delimiter)
|
||||
_DISPLAY_MSG_STC=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $1'})
|
||||
_DISPLAY_MSG_TIME=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $2'})
|
||||
_DISPLAY_MSG_TEXT=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $3'})
|
||||
_DISPLAY_MSG_CUR_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $4'})
|
||||
_DISPLAY_MSG_EXP_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $5'})
|
||||
|
||||
# magically unquote if needed
|
||||
if [[ -n "${_DISPLAY_MSG_TEXT}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_TEXT}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_TEXT=$(data_magic_unquote "${_DISPLAY_MSG_TEXT}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_CUR_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_CUR_VAL=$(data_magic_unquote "${_DISPLAY_MSG_CUR_VAL}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_EXP_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}")
|
||||
fi
|
||||
fi
|
||||
if (( _DISPLAY_MSG_STC > 0 ))
|
||||
then
|
||||
_ID_BIT="${_DISPLAY_FAIL_ID}"
|
||||
|
@ -32,7 +32,7 @@
|
||||
function display_zenoss
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2018-05-14" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -53,15 +53,33 @@ typeset _DISPLAY_MSG_EXP_VAL=""
|
||||
# parse $HC_MSG_VAR
|
||||
if [[ -n "${HC_MSG_VAR}" ]]
|
||||
then
|
||||
print "${HC_MSG_VAR}" | while read _HC_MSG_ENTRY
|
||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _DISPLAY_MSG_STC _DISPLAY_MSG_TIME _DISPLAY_MSG_TEXT _DISPLAY_MSG_CUR_VAL _DISPLAY_MSG_EXP_VAL
|
||||
do
|
||||
# split fields (awk is required for multi-char delimiter)
|
||||
_DISPLAY_MSG_STC=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $1'})
|
||||
_DISPLAY_MSG_TIME=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $2'})
|
||||
_DISPLAY_MSG_TEXT=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $3'})
|
||||
_DISPLAY_MSG_CUR_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $4'})
|
||||
_DISPLAY_MSG_EXP_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $5'})
|
||||
|
||||
# magically unquote if needed
|
||||
if [[ -n "${_DISPLAY_MSG_TEXT}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_TEXT}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_TEXT=$(data_magic_unquote "${_DISPLAY_MSG_TEXT}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_CUR_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_CUR_VAL=$(data_magic_unquote "${_DISPLAY_MSG_CUR_VAL}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_DISPLAY_MSG_EXP_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_DISPLAY_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_DISPLAY_MSG_EXP_VAL=$(data_magic_unquote "${_DISPLAY_MSG_EXP_VAL}")
|
||||
fi
|
||||
fi
|
||||
if (( _DISPLAY_MSG_STC > 0 ))
|
||||
then
|
||||
printf "NOK|data1=%s data2=%s data3=%s data4=\"%s\" data5=%s data6=%s\n" \
|
||||
|
@ -32,7 +32,7 @@
|
||||
function archive_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset HC_NAME="$1"
|
||||
typeset HC_NAME="${1}"
|
||||
typeset ARCHIVE_FILE=""
|
||||
typeset YEAR_MONTH=""
|
||||
typeset LOG_COUNT=0
|
||||
@ -69,7 +69,7 @@ do
|
||||
# compare with the sorted $HC_LOG
|
||||
sort ${HC_LOG} >${TMP1_FILE}
|
||||
comm -23 ${TMP1_FILE} ${ARCHIVE_FILE} 2>/dev/null >${TMP2_FILE}
|
||||
|
||||
|
||||
if [[ -s ${TMP2_FILE} ]]
|
||||
then
|
||||
mv ${TMP2_FILE} ${HC_LOG} 2>/dev/null || {
|
||||
@ -123,7 +123,7 @@ function die
|
||||
typeset NOW="$(date '+%d-%h-%Y %H:%M:%S')"
|
||||
typeset LOG_LINE=""
|
||||
|
||||
if [[ -n "$1" ]]
|
||||
if [[ -n "${1}" ]]
|
||||
then
|
||||
if (( ARG_LOG != 0 ))
|
||||
then
|
||||
@ -158,6 +158,7 @@ typeset NOTIFY_OPTS=""
|
||||
# init global flags for core plugins (no typeset!)
|
||||
DO_DISPLAY_CSV=0
|
||||
DO_DISPLAY_INIT=0
|
||||
DO_DISPLAY_JSON=0
|
||||
DO_DISPLAY_TERSE=0
|
||||
DO_DISPLAY_ZENOSS=0
|
||||
DO_DISPLAY_CUSTOM1=0
|
||||
@ -175,6 +176,7 @@ DO_NOTIFY_SMS=0
|
||||
DO_REPORT_STD=0
|
||||
HAS_DISPLAY_CSV=0
|
||||
HAS_DISPLAY_INIT=0
|
||||
HAS_DISPLAY_JSON=0
|
||||
HAS_DISPLAY_TERSE=0
|
||||
HAS_DISPLAY_ZENOSS=0
|
||||
HAS_DISPLAY_CUSTOM1=0
|
||||
@ -205,6 +207,10 @@ do
|
||||
HAS_DISPLAY_INIT=1
|
||||
(( ARG_DEBUG != 0 )) && debug "display_init plugin is available"
|
||||
;;
|
||||
*display_json.sh)
|
||||
HAS_DISPLAY_JSON=1
|
||||
(( ARG_DEBUG != 0 )) && debug "display_json plugin is available"
|
||||
;;
|
||||
*display_terse.sh)
|
||||
HAS_DISPLAY_TERSE=1
|
||||
(( ARG_DEBUG != 0 )) && debug "display_terse plugin is available"
|
||||
@ -291,6 +297,15 @@ then
|
||||
warn "init plugin for '--display' not present"
|
||||
fi
|
||||
;;
|
||||
json) # json format
|
||||
if (( HAS_DISPLAY_JSON == 1 ))
|
||||
then
|
||||
DO_DISPLAY_JSON=1
|
||||
ARG_VERBOSE=0
|
||||
else
|
||||
warn "json plugin for '--display' not present"
|
||||
fi
|
||||
;;
|
||||
terse) # terse format
|
||||
if (( HAS_DISPLAY_TERSE == 1 ))
|
||||
then
|
||||
@ -499,7 +514,7 @@ then
|
||||
if (( ARG_LAST != 0 )) || (( ARG_TODAY != 0 ))
|
||||
then
|
||||
ARG_HISTORY=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if (( DO_REPORT_STD == 0 )) && (( ARG_LAST != 0 ))
|
||||
then
|
||||
@ -525,6 +540,22 @@ fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: dump_logs()
|
||||
# DOES: current STDOUT+STDERR log via log()
|
||||
# EXPECTS: n/a
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function dump_logs
|
||||
{
|
||||
log "=== STDOUT ==="
|
||||
log "$(<${HC_STDOUT_LOG})"
|
||||
log "=== STDERR ==="
|
||||
log "$(<${HC_STDERR_LOG})"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: exists_hc()
|
||||
# DOES: check if a HC (function) exists in $FPATH
|
||||
@ -534,7 +565,7 @@ return 0
|
||||
function exists_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset EXISTS_HC="$1"
|
||||
typeset EXISTS_HC="${1}"
|
||||
typeset FDIR=""
|
||||
typeset EXISTS_RC=0
|
||||
|
||||
@ -561,7 +592,7 @@ return ${EXISTS_RC}
|
||||
function find_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset FIND_HC="$1"
|
||||
typeset FIND_HC="${1}"
|
||||
typeset FIND_PATH=""
|
||||
typeset FDIR=""
|
||||
|
||||
@ -582,7 +613,7 @@ return 0
|
||||
function handle_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset HC_NAME="$1"
|
||||
typeset HC_NAME="${1}"
|
||||
typeset HC_STDOUT_LOG_SHORT=""
|
||||
typeset HC_STDERR_LOG_SHORT=""
|
||||
typeset HC_MSG_ENTRY=""
|
||||
@ -596,7 +627,7 @@ typeset ALL_MSG_STC=0
|
||||
|
||||
if [[ -s ${HC_MSG_FILE} ]]
|
||||
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
|
||||
HC_MSG_VAR=$(<${HC_MSG_FILE})
|
||||
|
||||
@ -635,6 +666,15 @@ then
|
||||
else
|
||||
warn "display_init plugin is not available, cannot display_results!"
|
||||
fi
|
||||
elif (( DO_DISPLAY_JSON == 1 ))
|
||||
then
|
||||
if (( HAS_DISPLAY_JSON == 1 ))
|
||||
then
|
||||
# call plugin
|
||||
display_json "${HC_NAME}" "${HC_FAIL_ID}"
|
||||
else
|
||||
warn "display_json plugin is not available, cannot display_results!"
|
||||
fi
|
||||
elif (( DO_DISPLAY_TERSE == 1 ))
|
||||
then
|
||||
if (( HAS_DISPLAY_TERSE == 1 ))
|
||||
@ -738,22 +778,40 @@ then
|
||||
# default STDOUT
|
||||
if (( ARG_VERBOSE != 0 ))
|
||||
then
|
||||
print "${HC_MSG_VAR}" | while read HC_MSG_ENTRY
|
||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read ONE_MSG_STC ONE_MSG_TIME ONE_MSG_TEXT ONE_MSG_CUR_VAL ONE_MSG_EXP_VAL
|
||||
do
|
||||
# split fields (awk is required for mult-char delimiter)
|
||||
ONE_MSG_STC=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $1'})
|
||||
ONE_MSG_TIME=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $2'})
|
||||
ONE_MSG_TEXT=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $3'})
|
||||
ONE_MSG_CUR_VAL=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $4'})
|
||||
ONE_MSG_EXP_VAL=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $5'})
|
||||
|
||||
printf "%s" "INFO: ${HC_NAME} [STC=${ONE_MSG_STC}]: ${ONE_MSG_TEXT}"
|
||||
# magically unquote if needed
|
||||
if [[ -n "${ONE_MSG_TEXT}" ]]
|
||||
then
|
||||
data_contains_string "${ONE_MSG_TEXT}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
ONE_MSG_TEXT=$(data_magic_unquote "${ONE_MSG_TEXT}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${ONE_MSG_CUR_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${ONE_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
ONE_MSG_CUR_VAL=$(data_magic_unquote "${ONE_MSG_CUR_VAL}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${ONE_MSG_EXP_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${ONE_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
ONE_MSG_EXP_VAL=$(data_magic_unquote "${ONE_MSG_EXP_VAL}")
|
||||
fi
|
||||
fi
|
||||
printf "%s" "INFO: ${HC_NAME} [STC=${ONE_MSG_STC}]: ${ONE_MSG_TEXT}"
|
||||
if (( ONE_MSG_STC != 0 ))
|
||||
then
|
||||
printf " %s\n" "[FAIL_ID=${HC_FAIL_ID}]"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
@ -763,15 +821,33 @@ fi
|
||||
if (( ARG_LOG != 0 ))
|
||||
then
|
||||
# log routine (combined STC=0 or <>0)
|
||||
print "${HC_MSG_VAR}" | while read HC_MSG_ENTRY
|
||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read ONE_MSG_STC ONE_MSG_TIME ONE_MSG_TEXT ONE_MSG_CUR_VAL ONE_MSG_EXP_VAL
|
||||
do
|
||||
# split fields (awk is required for multi-char delimiter)
|
||||
ONE_MSG_STC=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $1'})
|
||||
ONE_MSG_TIME=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $2'})
|
||||
ONE_MSG_TEXT=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $3'})
|
||||
ONE_MSG_CUR_VAL=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $4'})
|
||||
ONE_MSG_EXP_VAL=$(print "${HC_MSG_ENTRY}" | awk -F "${MSG_SEP}" '{ print $5'})
|
||||
|
||||
# magically unquote if needed
|
||||
if [[ -n "${ONE_MSG_TEXT}" ]]
|
||||
then
|
||||
data_contains_string "${ONE_MSG_TEXT}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
ONE_MSG_TEXT=$(data_magic_unquote "${ONE_MSG_TEXT}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${ONE_MSG_CUR_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${ONE_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
ONE_MSG_CUR_VAL=$(data_magic_unquote "${ONE_MSG_CUR_VAL}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${ONE_MSG_EXP_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${ONE_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
ONE_MSG_EXP_VAL=$(data_magic_unquote "${ONE_MSG_EXP_VAL}")
|
||||
fi
|
||||
fi
|
||||
printf "%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}%s${LOG_SEP}" \
|
||||
"${ONE_MSG_TIME}" \
|
||||
"${HC_NAME}" \
|
||||
@ -794,20 +870,20 @@ then
|
||||
then
|
||||
# organize logs in sub-directories: YYYY/MM
|
||||
mkdir -p "${EVENTS_DIR}/${DIR_PREFIX}/${HC_FAIL_ID}" >/dev/null 2>&1 || \
|
||||
die "failed to create event directory at $1"
|
||||
die "failed to create event directory at ${1}"
|
||||
if [[ -f ${HC_STDOUT_LOG} ]]
|
||||
then
|
||||
# cut off the path and the .$$ part from the file location
|
||||
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 || \
|
||||
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
|
||||
if [[ -f ${HC_STDERR_LOG} ]]
|
||||
then
|
||||
# cut off the path and the .$$ part from the file location
|
||||
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 || \
|
||||
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
|
||||
|
||||
@ -856,7 +932,7 @@ else
|
||||
return ${HC_STC_RC}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: handle_timeout()
|
||||
# DOES: kill long running background jobs
|
||||
@ -900,6 +976,13 @@ case "${REPORT_STYLE}" in
|
||||
ARG_VERBOSE=0
|
||||
fi
|
||||
;;
|
||||
json|JSON) # json format
|
||||
if (( HAS_DISPLAY_JSON == 1 ))
|
||||
then
|
||||
DO_DISPLAY_JSON=1
|
||||
ARG_VERBOSE=0
|
||||
fi
|
||||
;;
|
||||
terse|TERSE) # terse format
|
||||
if (( HAS_DISPLAY_TERSE == 1 ))
|
||||
then
|
||||
@ -1008,8 +1091,8 @@ return 0
|
||||
function init_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset HC_PLATFORMS="$2"
|
||||
typeset HC_VERSION="$3"
|
||||
typeset HC_PLATFORMS="${2}"
|
||||
typeset HC_VERSION="${3}"
|
||||
typeset HC_OK=0
|
||||
|
||||
# check platform (don't use a pattern comparison here (~! mksh/pdksh))
|
||||
@ -1020,10 +1103,10 @@ HC_OK=$(print "${HC_PLATFORMS}" | grep -c "${OS_NAME}" 2>/dev/null)
|
||||
case "${HC_VERSION}" in
|
||||
[0-2][0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9])
|
||||
# OK
|
||||
(( ARG_DEBUG != 0 )) && debug "HC plugin $1 has version ${HC_VERSION}"
|
||||
(( ARG_DEBUG != 0 )) && debug "HC plugin ${1} has version ${HC_VERSION}"
|
||||
;;
|
||||
*)
|
||||
die "version of the HC plugin $1 is not in YYYY-MM-DD format (${HC_VERSION})"
|
||||
die "version of the HC plugin ${1} is not in YYYY-MM-DD format (${HC_VERSION})"
|
||||
;;
|
||||
esac
|
||||
|
||||
@ -1039,7 +1122,7 @@ return 0
|
||||
function is_scheduled
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset CRON_HC="$1"
|
||||
typeset CRON_HC="${1}"
|
||||
typeset CRON_COUNT=0
|
||||
typeset CRON_SYS_LOCATIONS='/etc/crontab /etc/cron.d/*'
|
||||
typeset CRON_ANACRON_LOCATIONS='/etc/anacrontab /etc/cron.*'
|
||||
@ -1077,7 +1160,7 @@ return ${CRON_COUNT}
|
||||
function list_core
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset FACTION="$1"
|
||||
typeset FACTION="${1}"
|
||||
typeset FCONFIG=""
|
||||
typeset FDIR=""
|
||||
typeset FNAME=""
|
||||
@ -1099,6 +1182,8 @@ do
|
||||
# exclude core helper librar(y|ies)
|
||||
ls -1 ${FDIR}/*.sh 2>/dev/null | grep -v "include_" | sort 2>/dev/null | while read -r FFILE
|
||||
do
|
||||
# reset state
|
||||
FSTATE="enabled"
|
||||
# find function name but skip helper functions in the plug-in file (function _name)
|
||||
FNAME=$(grep -E -e "^function[[:space:]]+[^_]" "${FFILE}" 2>&1)
|
||||
# look for version string (cut off comments but don't use [:space:] in tr)
|
||||
@ -1163,8 +1248,8 @@ return 0
|
||||
function list_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset FACTION="$1"
|
||||
typeset FNEEDLE="$2"
|
||||
typeset FACTION="${1}"
|
||||
typeset FNEEDLE="${2}"
|
||||
typeset FCONFIG=""
|
||||
typeset FDIR=""
|
||||
typeset FNAME=""
|
||||
@ -1215,6 +1300,7 @@ do
|
||||
else
|
||||
FSTATE="enabled"
|
||||
fi
|
||||
# reset state when unlinked
|
||||
[[ -h ${FFILE%%.*} ]] || FSTATE="unlinked"
|
||||
# check scheduling
|
||||
is_scheduled "${FNAME#function *}"
|
||||
@ -1278,7 +1364,7 @@ function log
|
||||
typeset NOW="$(date '+%d-%h-%Y %H:%M:%S')"
|
||||
typeset LOG_LINE=""
|
||||
|
||||
if [[ -n "$1" ]]
|
||||
if [[ -n "${1}" ]]
|
||||
then
|
||||
if (( ARG_LOG != 0 ))
|
||||
then
|
||||
@ -1310,20 +1396,47 @@ return 0
|
||||
function log_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset HC_NAME="$1"
|
||||
typeset HC_STC=$2
|
||||
typeset HC_MSG="$3"
|
||||
typeset HC_NAME="${1}"
|
||||
typeset HC_STC=${2}
|
||||
typeset HC_MSG="${3}"
|
||||
typeset HC_NOW="$(date '+%Y-%m-%d %H:%M:%S' 2>/dev/null)"
|
||||
typeset HC_MSG_CUR_VAL=""
|
||||
typeset HC_MSG_EXP_VAL=""
|
||||
|
||||
# assign optional parameters
|
||||
[[ -n "$3" ]] && HC_MSG_TEXT=$(data_newline2hash "$3")
|
||||
[[ -n "$4" ]] && HC_MSG_CUR_VAL=$(data_newline2hash "$4")
|
||||
[[ -n "$5" ]] && HC_MSG_EXP_VAL=$(data_newline2hash "$5")
|
||||
# assign optional parameters; magically quote if necessary
|
||||
if [[ -n "${3}" ]]
|
||||
then
|
||||
data_contains_string "${3}" "${MSG_SEP}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
HC_MSG_TEXT=$(data_magic_quote "${3}")
|
||||
else
|
||||
HC_MSG_TEXT="${3}"
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${4}" ]]
|
||||
then
|
||||
data_contains_string "${4}" "${MSG_SEP}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
HC_CUR_VAL=$(data_magic_quote "${4}")
|
||||
else
|
||||
HC_CUR_VAL="${4}"
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${5}" ]]
|
||||
then
|
||||
data_contains_string "${5}" "${MSG_SEP}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
HC_MSG_EXP_VAL=$(data_magic_quote "${5}")
|
||||
else
|
||||
HC_MSG_EXP_VAL="${5}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# save the HC failure message for now
|
||||
print "${HC_STC}${MSG_SEP}${HC_NOW}${MSG_SEP}${HC_MSG}${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}
|
||||
|
||||
return 0
|
||||
@ -1430,7 +1543,7 @@ return 0
|
||||
function stat_hc
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset STAT_HC="$1"
|
||||
typeset STAT_HC="${1}"
|
||||
typeset STAT_RC=1 # default: enabled
|
||||
|
||||
[[ -f "${STATE_PERM_DIR}/${STAT_HC}.disabled" ]] && STAT_RC=0
|
||||
@ -1450,7 +1563,7 @@ function warn
|
||||
typeset NOW="$(date '+%d-%h-%Y %H:%M:%S')"
|
||||
typeset LOG_LINE=""
|
||||
|
||||
if [[ -n "$1" ]]
|
||||
if [[ -n "${1}" ]]
|
||||
then
|
||||
if (( ARG_LOG != 0 ))
|
||||
then
|
||||
|
@ -76,8 +76,8 @@ function data_contains_string
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
typeset _HAYSTACK="$1"
|
||||
typeset _NEEDLE="$2"
|
||||
typeset _HAYSTACK="${1}"
|
||||
typeset _NEEDLE="${2}"
|
||||
typeset _RC=0
|
||||
|
||||
[[ "${_HAYSTACK#*${_NEEDLE}}" = "${_HAYSTACK}" ]] || _RC=1
|
||||
@ -85,11 +85,81 @@ typeset _RC=0
|
||||
return ${_RC}
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_magic_quote()
|
||||
# DOES: magically quotes a needle in a string (default needle is: %)
|
||||
# EXPECTS: to be magically quoted [string]; $2=needle [string]
|
||||
# OUTPUTS: magically quoted [string]
|
||||
# RETURNS: n/a
|
||||
# REQUIRES: n/a
|
||||
function data_magic_quote
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _SEP="${2:-%}"
|
||||
typeset _MAGIC="${MAGIC:-!_!}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | sed "s/${_SEP}/${_MAGIC}/g" 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_magic_unquote()
|
||||
# DOES: magically unquotes a needle in a string (default needle is: %)
|
||||
# EXPECTS: to be magically unquoted [string]; $2=needle [string]
|
||||
# OUTPUTS: magically unquoted [string]
|
||||
# RETURNS: n/a
|
||||
# REQUIRES: n/a
|
||||
function data_magic_unquote
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _SEP="${2:-%}"
|
||||
typeset _MAGIC="${MAGIC:-!_!}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | sed "s/${_MAGIC}/${_SEP}/g" 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_escape_csv()
|
||||
# DOES: escapes semi-colons
|
||||
# EXPECTS: to be escaped [string]
|
||||
# OUTPUTS: escaped [string]
|
||||
# RETURNS: n/a
|
||||
# REQUIRES: n/a
|
||||
function data_escape_csv
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
|
||||
print -R "${1}" 2>/dev/null | sed 's#\([;]\)#\\\1#g' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_escape_json()
|
||||
# DOES: escapes double quotes and backslashes
|
||||
# EXPECTS: to be escaped [string]
|
||||
# OUTPUTS: escaped [string]
|
||||
# RETURNS: n/a
|
||||
# REQUIRES: n/a
|
||||
function data_escape_json
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _NEEDLE='[\"]'
|
||||
|
||||
print -R "${1}" 2>/dev/null | sed 's#\(["\]\)#\\\1#g' 2>/dev/null
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# @(#) FUNCTION: data_decomma()
|
||||
# DOES: remove comma's
|
||||
# EXPECTS: [string] with comma's
|
||||
# OUTPUTS: [string] without comma's
|
||||
# DOES: remove commas
|
||||
# EXPECTS: [string] with commas
|
||||
# OUTPUTS: [string] without commas
|
||||
# RETURNS: 0
|
||||
# REQUIRES: n/a
|
||||
function data_decomma
|
||||
@ -478,7 +548,7 @@ return 0
|
||||
function data_dot2ip
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _DOT="$1"
|
||||
typeset _DOT="${1}"
|
||||
typeset _IP=0
|
||||
typeset _OLD_IFS="${IFS}"
|
||||
|
||||
@ -507,7 +577,7 @@ return 0
|
||||
function data_ip2dot
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _IP="$1"
|
||||
typeset _IP="${1}"
|
||||
typeset _W=""
|
||||
typeset _X=""
|
||||
typeset _Y=""
|
||||
@ -534,7 +604,7 @@ return 0
|
||||
function data_bits2mask
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _BITS=$1
|
||||
typeset _BITS=${1}
|
||||
typeset _MAX=4294967296
|
||||
typeset _OFFSET=0
|
||||
|
||||
@ -590,7 +660,7 @@ return 0
|
||||
function data_mask2bits
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _MASK="$1"
|
||||
typeset _MASK="${1}"
|
||||
typeset -i _I=32
|
||||
|
||||
while (( _I > 0 ))
|
||||
@ -611,7 +681,7 @@ return 0
|
||||
function data_is_ipv4
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _IP="$1"
|
||||
typeset _IP="${1}"
|
||||
typeset _RC=0
|
||||
|
||||
_RC=$(print "${_IP}" | grep -c -E -e '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 2>/dev/null)
|
||||
@ -636,12 +706,12 @@ return ${_RC}
|
||||
function data_date2epoch
|
||||
{
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}"
|
||||
typeset _YEAR="$1"
|
||||
typeset _MONTH="$2"
|
||||
typeset _DAY="$3"
|
||||
typeset _HOUR="$4"
|
||||
typeset _MINUTE="$5"
|
||||
typeset _SECOND="$6"
|
||||
typeset _YEAR="${1}"
|
||||
typeset _MONTH="${2}"
|
||||
typeset _DAY="${3}"
|
||||
typeset _HOUR="${4}"
|
||||
typeset _MINUTE="${5}"
|
||||
typeset _SECOND="${6}"
|
||||
typeset _DAYS_ACC
|
||||
typeset _YEAR_DAY
|
||||
typeset _EPOCH
|
||||
|
@ -30,7 +30,7 @@
|
||||
function notify_mail
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _VERSION="2018-05-14" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="AIX,HP-UX,Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -133,15 +133,33 @@ $(sed 's/[\$`]/\\&/g;s/<## @\([^ ]*\) ##>/${\1}/g' <${_MAIL_HEADER_TPL})
|
||||
__EOT" >>${_TMP1_MAIL_FILE}
|
||||
|
||||
# create body part (from $HC_MSG_VAR)
|
||||
print "${HC_MSG_VAR}" | while read _HC_MSG_ENTRY
|
||||
print "${HC_MSG_VAR}" | while IFS=${MSG_SEP} read _MAIL_MSG_STC _MAIL_MSG_TIME _DISP_MAIL_MSG_TEXTLAY_MSG_TEXT _MAIL_MSG_CUR_VAL _MAIL_MSG_EXP_VAL
|
||||
do
|
||||
# split fields (awk is required for multi-char delimiter)
|
||||
_MAIL_MSG_STC=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $1'})
|
||||
_MAIL_MSG_TIME=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $2'})
|
||||
_MAIL_MSG_TEXT=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $3'})
|
||||
_MAIL_MSG_CUR_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $4'})
|
||||
_MAIL_MSG_EXP_VAL=$(print "${_HC_MSG_ENTRY}" | awk -F "%%" '{ print $5'})
|
||||
|
||||
# magically unquote if needed
|
||||
if [[ -n "${_MAIL_MSG_TEXT}" ]]
|
||||
then
|
||||
data_contains_string "${_MAIL_MSG_TEXT}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_MAIL_MSG_TEXT=$(data_magic_unquote "${_MAIL_MSG_TEXT}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_MAIL_MSG_CUR_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_MAIL_MSG_CUR_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_MAIL_MSG_CUR_VAL=$(data_magic_unquote "${_MAIL_MSG_CUR_VAL}")
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${_MAIL_MSG_EXP_VAL}" ]]
|
||||
then
|
||||
data_contains_string "${_MAIL_MSG_EXP_VAL}" "${MAGIC_QUOTE}"
|
||||
if (( $? > 0 ))
|
||||
then
|
||||
_MAIL_MSG_EXP_VAL=$(data_magic_unquote "${_MAIL_MSG_EXP_VAL}")
|
||||
fi
|
||||
fi
|
||||
if (( _MAIL_MSG_STC > 0 ))
|
||||
then
|
||||
_HC_BODY=$(printf "%s\n%s\n" "${_HC_BODY}" "${_MAIL_MSG_TEXT}")
|
||||
|
@ -23,6 +23,7 @@
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2013-08-29: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -33,7 +34,7 @@ function check_hpux_autopath
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _AUTOPATH_BIN="/sbin/autopath"
|
||||
typeset _AUTOPATH_NEEDLE="Failed"
|
||||
typeset _VERSION="2013-08-29" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -71,6 +72,8 @@ ${_AUTOPATH_BIN} display >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? != 0 )) && {
|
||||
_MSG="unable to run {${_AUTOPATH_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,11 @@
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), data_get_lvalue_from_config(), data_date2epoch(),
|
||||
# data_lc(), data_strip_space(), data_strip_outer_space(),
|
||||
# init_hc(), log_hc(), warn()
|
||||
# dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2018-05-11: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -243,11 +244,7 @@ else
|
||||
_MSG="unable to run command: {${_DRD_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
if (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 ))
|
||||
then
|
||||
log "$(<${HC_STDOUT_LOG})"
|
||||
log "$(<${HC_STDERR_LOG})"
|
||||
fi
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -19,11 +19,12 @@
|
||||
# @(#) MAIN: check_hpux_hpvm_vpar_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-06-01: initial version [Patrick Van der Veken]
|
||||
# @(#) 2017-06-08: return 1 on error [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -34,7 +35,7 @@ function check_hpux_hpvm_vpar_status
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _HPVMSTATUS_BIN="/opt/hpvm/bin/hpvmstatus"
|
||||
typeset _VERSION="2017-06-08" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -75,8 +76,10 @@ fi
|
||||
|
||||
${_HPVMSTATUS_BIN} -M >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? != 0 )) && {
|
||||
_MSG="unable to run {hpmvmstatus}"
|
||||
_MSG="unable to run command: {${_HPVMSTATUS_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# @(#) MAIN: check_hpux_ioscan
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), data_comma2pipe(), data_dequote(),
|
||||
# REQUIRES: data_space2comma(), data_comma2pipe(), data_dequote(), dump_logs(),
|
||||
# init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
@ -28,6 +28,7 @@
|
||||
# @(#) 2016-06-08: introduced _AGILE_VIEW parameter [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2018-05-11: small optimizations [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -39,8 +40,8 @@ function check_hpux_ioscan
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _IOSCAN_BIN="/usr/sbin/ioscan"
|
||||
typeset _IOSCAN_OPTS="-Fn"
|
||||
typeset _VERSION="2018-05-11" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
# set defaults
|
||||
@ -129,6 +130,8 @@ else
|
||||
then
|
||||
_MSG="unable to run command: {${_IOSCAN_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
@ -179,7 +182,7 @@ cat <<- EOT
|
||||
NAME : $1
|
||||
VERSION : $2
|
||||
CONFIG : $3 with:
|
||||
ioscan_classes=<list_of_device_classes_to_check>
|
||||
ioscan_classes=<list_of_device_classes_to_check>
|
||||
kernel_mode=<yes|no>
|
||||
agile_view=<yes|no>
|
||||
PURPOSE : Checks whether 'ioscan' returns errors or not (NO_HW, ERROR)
|
||||
|
@ -19,11 +19,12 @@
|
||||
# @(#) MAIN: check_hpux_kernel_params
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-12-22: original version [Patrick Van der Veken]
|
||||
# @(#) 2018-01-05: added validation on config values [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -34,7 +35,7 @@ function check_hpux_kernel_params
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _KCTUNE_BIN="/usr/sbin/kctune"
|
||||
typeset _VERSION="2018-01-05" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -83,6 +84,8 @@ else
|
||||
then
|
||||
_MSG="unable to gather kctune information"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
@ -19,12 +19,13 @@
|
||||
# @(#) MAIN: check_hpux_kernel_usage
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-12-22: original version [Patrick Van der Veken]
|
||||
# @(#) 2018-01-08: extra config checks [Patrick Van der Veken]
|
||||
# @(#) 2018-01-09: bug fix [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -35,7 +36,7 @@ function check_hpux_kernel_usage
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _KCUSAGE_BIN="/usr/sbin/kcusage"
|
||||
typeset _VERSION="2018-01-09" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -99,6 +100,8 @@ else
|
||||
if (( $? != 0 ))
|
||||
then
|
||||
_MSG="unable to gather kcusage information"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
return 0
|
||||
fi
|
||||
|
@ -20,10 +20,12 @@
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), data_get_lvalue_from_config(), data_dequote(),
|
||||
# init_hc(), log_hc(), warn()
|
||||
# dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2018-05-11: initial version [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -37,7 +39,7 @@ typeset _SWLIST_BIN="/usr/sbin/swlist"
|
||||
typeset _SWLIST_OPTS=""
|
||||
typeset _SHOW_PATCHES_BIN="/usr/contrib/bin/show_patches"
|
||||
typeset _SHOW_PATCHES_OPTS=""
|
||||
typeset _VERSION="2018-05-11" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="HP-UX" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -109,6 +111,8 @@ then
|
||||
else
|
||||
_MSG="unable to run command: {${_SWLIST_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
@ -150,6 +154,8 @@ then
|
||||
else
|
||||
_MSG="unable to run command: {${_SHOW_PATCHES_BIN}}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
|
@ -19,12 +19,13 @@
|
||||
# @(#) MAIN: check_hpux_sg_cluster_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-03-25: initial version [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -79,8 +80,10 @@ then
|
||||
else
|
||||
cmviewcl -v -f line 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG}
|
||||
(( $? != 0 )) && {
|
||||
_MSG="unable to run 'cmviewcl'"
|
||||
_MSG="unable to run command: {cmviewcl}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
fi
|
||||
|
@ -19,12 +19,13 @@
|
||||
# @(#) MAIN: check_hpux_sg_package_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2016-03-08: initial version [Patrick Van der Veken]
|
||||
# @(#) 2016-12-01: more standardized error handling [Patrick Van der Veken]
|
||||
# @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -80,8 +81,10 @@ then
|
||||
else
|
||||
cmviewcl -v -f line -l package 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG}
|
||||
(( $? != 0)) && {
|
||||
_MSG="unable to run 'cmviewcl'"
|
||||
_MSG="unable to run command: {cmviewcl}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
fi
|
||||
|
@ -19,11 +19,12 @@
|
||||
# @(#) MAIN: check_linux_sg_cluster_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-04-01: initial version [Patrick Van der Veken]
|
||||
# @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -33,7 +34,7 @@ function check_linux_sg_cluster_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2017-05-07" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
@ -79,8 +80,10 @@ then
|
||||
else
|
||||
cmviewcl -v -f line 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG}
|
||||
(( $? != 0 )) && {
|
||||
_MSG="unable to run 'cmviewcl'"
|
||||
_MSG="unable to run command: {cmviewcl}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
fi
|
||||
|
@ -19,11 +19,12 @@
|
||||
# @(#) MAIN: check_linux_sg_package_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-04-01: initial version [Patrick Van der Veken]
|
||||
# @(#) 2017-05-07: made checks more detailed for log_hc() [Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -33,7 +34,7 @@ function check_linux_sg_package_status
|
||||
{
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VERSION="2017-05-07" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
typeset _SG_DAEMON="/opt/cmcluster/bin/cmcld"
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
@ -80,8 +81,10 @@ then
|
||||
else
|
||||
cmviewcl -v -f line -l package 2>>${HC_STDERR_LOG} | tr '|' ':' >>${HC_STDOUT_LOG}
|
||||
(( $? != 0)) && {
|
||||
_MSG="unable to run 'cmviewcl'"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
_MSG="unable to run command: {cmviewcl}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
fi
|
||||
|
@ -19,13 +19,14 @@
|
||||
# @(#) MAIN: check_linux_vz_ct_status
|
||||
# DOES: see _show_usage()
|
||||
# EXPECTS: see _show_usage()
|
||||
# REQUIRES: data_space2comma(), init_hc(), log_hc(), warn()
|
||||
# REQUIRES: data_space2comma(), dump_logs(), init_hc(), log_hc(), warn()
|
||||
#
|
||||
# @(#) HISTORY:
|
||||
# @(#) 2017-04-01: initial version [Patrick Van der Veken]
|
||||
# @(#) 2017-05-07: made checks more detailed for hc_log() [Patrick Van der Veken]
|
||||
# @(#) 2017-06-08: return 1 on error [Patrick Van der Veken]
|
||||
# @(#) 2018-04-30: fixes on variable names Patrick Van der Veken]
|
||||
# @(#) 2018-05-20: added dump_logs() [Patrick Van der Veken]
|
||||
# -----------------------------------------------------------------------------
|
||||
# DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
|
||||
#******************************************************************************
|
||||
@ -36,7 +37,7 @@ function check_linux_vz_ct_status
|
||||
# ------------------------- CONFIGURATION starts here -------------------------
|
||||
typeset _CONFIG_FILE="${CONFIG_DIR}/$0.conf"
|
||||
typeset _VZLIST_BIN="/usr/sbin/vzlist"
|
||||
typeset _VERSION="2018-04-30" # YYYY-MM-DD
|
||||
typeset _VERSION="2018-05-20" # YYYY-MM-DD
|
||||
typeset _SUPPORTED_PLATFORMS="Linux" # uname -s match
|
||||
# ------------------------- CONFIGURATION ends here ---------------------------
|
||||
|
||||
@ -78,8 +79,10 @@ fi
|
||||
# get container stati
|
||||
${_VZLIST_BIN} -a -H -o ctid,status,onboot >>${HC_STDOUT_LOG} 2>>${HC_STDERR_LOG}
|
||||
(( $? != 0 )) && {
|
||||
_MSG="unable to run {vzlist}"
|
||||
_MSG="unable to run command: {vzlist}"
|
||||
log_hc "$0" 1 "${_MSG}"
|
||||
# dump debug info
|
||||
(( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && dump_logs
|
||||
return 0
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user