From e32f605e933723b0b64d6fa1fd398e5a1621f001 Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Wed, 20 Dec 2017 08:52:11 +0100 Subject: [PATCH] Added stubs for custom1->custom9 display plugins --- sources/bin/check_health.sh | 5 +- sources/lib/core/include_core.sh | 282 ++++++++++++++++++++++++++++++- 2 files changed, 282 insertions(+), 5 deletions(-) diff --git a/sources/bin/check_health.sh b/sources/bin/check_health.sh index 1135004..98d06e2 100644 --- a/sources/bin/check_health.sh +++ b/sources/bin/check_health.sh @@ -26,8 +26,7 @@ # display_usage(), do_cleanup, fix_symlinks(), read_config() # + include functions # For other pre-requisites see the documentation in display_usage() -# REQUIRES (OPTIONAL): display_csv(), display_terse(), display_init(), -# display_zenoss(), notify_eif(), notify_mail(), notify_sms() +# REQUIRES (OPTIONAL): display_*(), notify_*(), report_*() # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -38,7 +37,7 @@ # ------------------------- CONFIGURATION starts here ------------------------- # define the version (YYYY-MM-DD) -typeset -r SCRIPT_VERSION="2017-12-15" +typeset -r SCRIPT_VERSION="2017-12-20" # location of parent directory containing KSH functions/HC plugins typeset -r FPATH_PARENT="/opt/hc/lib" # location of custom HC configuration files diff --git a/sources/lib/core/include_core.sh b/sources/lib/core/include_core.sh index ddbbf25..ad7d8a1 100644 --- a/sources/lib/core/include_core.sh +++ b/sources/lib/core/include_core.sh @@ -91,6 +91,15 @@ DO_DISPLAY_CSV=0 DO_DISPLAY_INIT=0 DO_DISPLAY_TERSE=0 DO_DISPLAY_ZENOSS=0 +DO_DISPLAY_CUSTOM1=0 +DO_DISPLAY_CUSTOM2=0 +DO_DISPLAY_CUSTOM3=0 +DO_DISPLAY_CUSTOM4=0 +DO_DISPLAY_CUSTOM5=0 +DO_DISPLAY_CUSTOM6=0 +DO_DISPLAY_CUSTOM7=0 +DO_DISPLAY_CUSTOM8=0 +DO_DISPLAY_CUSTOM9=0 DO_NOTIFY_EIF=0 DO_NOTIFY_MAIL=0 DO_NOTIFY_SMS=0 @@ -99,6 +108,15 @@ HAS_DISPLAY_CSV=0 HAS_DISPLAY_INIT=0 HAS_DISPLAY_TERSE=0 HAS_DISPLAY_ZENOSS=0 +HAS_DISPLAY_CUSTOM1=0 +HAS_DISPLAY_CUSTOM2=0 +HAS_DISPLAY_CUSTOM3=0 +HAS_DISPLAY_CUSTOM4=0 +HAS_DISPLAY_CUSTOM5=0 +HAS_DISPLAY_CUSTOM6=0 +HAS_DISPLAY_CUSTOM7=0 +HAS_DISPLAY_CUSTOM8=0 +HAS_DISPLAY_CUSTOM9=0 HAS_NOTIFY_EIF=0 HAS_NOTIFY_MAIL=0 HAS_NOTIFY_SMS=0 @@ -126,6 +144,42 @@ do HAS_DISPLAY_ZENOSS=1 (( ARG_DEBUG != 0 )) && debug "display_zenoss plugin is available" ;; + *display_custom1.sh) + HAS_DISPLAY_CUSTOM1=1 + (( ARG_DEBUG != 0 )) && debug "display_custom1 plugin is available" + ;; + *display_custom2.sh) + HAS_DISPLAY_CUSTOM2=1 + (( ARG_DEBUG != 0 )) && debug "display_custom2 plugin is available" + ;; + *display_custom3.sh) + HAS_DISPLAY_CUSTOM3=1 + (( ARG_DEBUG != 0 )) && debug "display_custom3 plugin is available" + ;; + *display_custom4.sh) + HAS_DISPLAY_CUSTOM4=1 + (( ARG_DEBUG != 0 )) && debug "display_custom4 plugin is available" + ;; + *display_custom5.sh) + HAS_DISPLAY_CUSTOM5=1 + (( ARG_DEBUG != 0 )) && debug "display_custom5 plugin is available" + ;; + *display_custom6.sh) + HAS_DISPLAY_CUSTOM6=1 + (( ARG_DEBUG != 0 )) && debug "display_custom6 plugin is available" + ;; + *display_custom7.sh) + HAS_DISPLAY_CUSTOM7=1 + (( ARG_DEBUG != 0 )) && debug "display_custom7 plugin is available" + ;; + *display_custom8.sh) + HAS_DISPLAY_CUSTOM8=1 + (( ARG_DEBUG != 0 )) && debug "display_custom8 plugin is available" + ;; + *display_custom9.sh) + HAS_DISPLAY_CUSTOM9=1 + (( ARG_DEBUG != 0 )) && debug "display_custom9 plugin is available" + ;; *notify_mail.sh) HAS_NOTIFY_MAIL=1 (( ARG_DEBUG != 0 )) && debug "notify_mail plugin is available" @@ -186,6 +240,87 @@ then warn "zenoss plugin for '--display' not present" fi ;; + custom1) # custom1 format + if (( HAS_DISPLAY_CUSTOM1 == 1 )) + then + DO_DISPLAY_CUSTOM1=1 + ARG_VERBOSE=0 + else + warn "custom1 plugin for '--display' not present" + fi + ;; + custom2) # custom2 format + if (( HAS_DISPLAY_CUSTOM2 == 1 )) + then + DO_DISPLAY_CUSTOM2=1 + ARG_VERBOSE=0 + else + warn "custom2 plugin for '--display' not present" + fi + ;; + custom3) # custom3 format + if (( HAS_DISPLAY_CUSTOM3 == 1 )) + then + DO_DISPLAY_CUSTOM3=1 + ARG_VERBOSE=0 + else + warn "custom3 plugin for '--display' not present" + fi + ;; + custom4) # custom4 format + if (( HAS_DISPLAY_CUSTOM4 == 1 )) + then + DO_DISPLAY_CUSTOM4=1 + ARG_VERBOSE=0 + else + warn "custom4 plugin for '--display' not present" + fi + ;; + custom5) # custom5 format + if (( HAS_DISPLAY_CUSTOM5 == 1 )) + then + DO_DISPLAY_CUSTOM5=1 + ARG_VERBOSE=0 + else + warn "custom5 plugin for '--display' not present" + fi + ;; + custom6) # custom6 format + if (( HAS_DISPLAY_CUSTOM6 == 1 )) + then + DO_DISPLAY_CUSTOM6=1 + ARG_VERBOSE=0 + else + warn "custom6 plugin for '--display' not present" + fi + ;; + custom7) # custom7 format + if (( HAS_DISPLAY_CUSTOM7 == 1 )) + then + DO_DISPLAY_CUSTOM7=1 + ARG_VERBOSE=0 + else + warn "custom7 plugin for '--display' not present" + fi + ;; + custom8) # custom8 format + if (( HAS_DISPLAY_CUSTOM8 == 1 )) + then + DO_DISPLAY_CUSTOM8=1 + ARG_VERBOSE=0 + else + warn "custom8 plugin for '--display' not present" + fi + ;; + custom9) # custom9 format + if (( HAS_DISPLAY_CUSTOM9 == 1 )) + then + DO_DISPLAY_CUSTOM9=1 + ARG_VERBOSE=0 + else + warn "custom9 plugin for '--display' not present" + fi + ;; *) # stdout default ;; esac @@ -365,8 +500,7 @@ return 0 # DOES: handle HC results # EXPECTS: 1=HC name [string], $HC_MSG_FILE temporary file # RETURNS: 0 -# REQUIRES: die(), display_csv(), display_terse(), display_zenoss(), notify_mail(), -# notify_sms(), notify_eif(), warn() +# REQUIRES: die(), display_*(), notify_*(), warn() function handle_hc { (( ARG_DEBUG != 0 && ARG_DEBUG_LEVEL > 0 )) && set "${DEBUG_OPTS}" @@ -444,6 +578,87 @@ then else warn "display_zenoss plugin is not available, cannot display_results!" fi + elif (( DO_DISPLAY_CUSTOM1 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM1 == 1 )) + then + # call plugin + display_custom1 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom1 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM2 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM2 == 1 )) + then + # call plugin + display_custom2 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom2 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM3 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM3 == 1 )) + then + # call plugin + display_custom3 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom3 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM4 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM4 == 1 )) + then + # call plugin + display_custom4 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom4 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM5 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM5 == 1 )) + then + # call plugin + display_custom5 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom5 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM6 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM6 == 1 )) + then + # call plugin + display_custom6 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom6 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM7 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM7 == 1 )) + then + # call plugin + display_custom7 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom7 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM8 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM8 == 1 )) + then + # call plugin + display_custom8 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom8 plugin is not available, cannot display_results!" + fi + elif (( DO_DISPLAY_CUSTOM9 == 1 )) + then + if (( HAS_DISPLAY_CUSTOM9 == 1 )) + then + # call plugin + display_custom9 "${HC_NAME}" "${HC_FAIL_ID}" + else + warn "display_custom9 plugin is not available, cannot display_results!" + fi else # default STDOUT if (( ARG_VERBOSE != 0 )) @@ -610,6 +825,69 @@ case "${REPORT_STYLE}" in ARG_VERBOSE=0 fi ;; + custom1|CUSTOM1) # custom1 format + if (( HAS_DISPLAY_CUSTOM1 == 1 )) + then + DO_DISPLAY_CUSTOM1=1 + ARG_VERBOSE=0 + fi + ;; + custom2|CUSTOM2) # custom2 format + if (( HAS_DISPLAY_CUSTOM2 == 1 )) + then + DO_DISPLAY_CUSTOM2=1 + ARG_VERBOSE=0 + fi + ;; + custom3|CUSTOM3) # custom3 format + if (( HAS_DISPLAY_CUSTOM3 == 1 )) + then + DO_DISPLAY_CUSTOM3=1 + ARG_VERBOSE=0 + fi + ;; + custom4|CUSTOM4) # custom4 format + if (( HAS_DISPLAY_CUSTOM4 == 1 )) + then + DO_DISPLAY_CUSTOM4=1 + ARG_VERBOSE=0 + fi + ;; + custom5|CUSTOM5) # custom5 format + if (( HAS_DISPLAY_CUSTOM5 == 1 )) + then + DO_DISPLAY_CUSTOM5=1 + ARG_VERBOSE=0 + fi + ;; + custom6|CUSTOM6) # custom6 format + if (( HAS_DISPLAY_CUSTOM6 == 1 )) + then + DO_DISPLAY_CUSTOM6=1 + ARG_VERBOSE=0 + fi + ;; + custom7|CUSTOM7) # custom7 format + if (( HAS_DISPLAY_CUSTOM7 == 1 )) + then + DO_DISPLAY_CUSTOM7=1 + ARG_VERBOSE=0 + fi + ;; + custom8|CUSTOM8) # custom8 format + if (( HAS_DISPLAY_CUSTOM8 == 1 )) + then + DO_DISPLAY_CUSTOM8=1 + ARG_VERBOSE=0 + fi + ;; + custom9|CUSTOM9) # custom9 format + if (( HAS_DISPLAY_CUSTOM9 == 1 )) + then + DO_DISPLAY_CUSTOM9=1 + ARG_VERBOSE=0 + fi + ;; *) # init/boot default, stdout fallback if (( HAS_DISPLAY_INIT == 1 )) then