Added stubs for custom1->custom9 display plugins

This commit is contained in:
Patrick Van der Veken 2017-12-20 08:52:11 +01:00
parent 0159043d36
commit e32f605e93
2 changed files with 282 additions and 5 deletions

View File

@ -26,8 +26,7 @@
# display_usage(), do_cleanup, fix_symlinks(), read_config() # display_usage(), do_cleanup, fix_symlinks(), 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_csv(), display_terse(), display_init(), # REQUIRES (OPTIONAL): display_*(), notify_*(), report_*()
# display_zenoss(), notify_eif(), notify_mail(), notify_sms()
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# 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 @@
# ------------------------- CONFIGURATION starts here ------------------------- # ------------------------- CONFIGURATION starts here -------------------------
# define the version (YYYY-MM-DD) # 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 # 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

View File

@ -91,6 +91,15 @@ DO_DISPLAY_CSV=0
DO_DISPLAY_INIT=0 DO_DISPLAY_INIT=0
DO_DISPLAY_TERSE=0 DO_DISPLAY_TERSE=0
DO_DISPLAY_ZENOSS=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_EIF=0
DO_NOTIFY_MAIL=0 DO_NOTIFY_MAIL=0
DO_NOTIFY_SMS=0 DO_NOTIFY_SMS=0
@ -99,6 +108,15 @@ HAS_DISPLAY_CSV=0
HAS_DISPLAY_INIT=0 HAS_DISPLAY_INIT=0
HAS_DISPLAY_TERSE=0 HAS_DISPLAY_TERSE=0
HAS_DISPLAY_ZENOSS=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_EIF=0
HAS_NOTIFY_MAIL=0 HAS_NOTIFY_MAIL=0
HAS_NOTIFY_SMS=0 HAS_NOTIFY_SMS=0
@ -126,6 +144,42 @@ do
HAS_DISPLAY_ZENOSS=1 HAS_DISPLAY_ZENOSS=1
(( ARG_DEBUG != 0 )) && debug "display_zenoss plugin is available" (( 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) *notify_mail.sh)
HAS_NOTIFY_MAIL=1 HAS_NOTIFY_MAIL=1
(( ARG_DEBUG != 0 )) && debug "notify_mail plugin is available" (( ARG_DEBUG != 0 )) && debug "notify_mail plugin is available"
@ -186,6 +240,87 @@ then
warn "zenoss plugin for '--display' not present" warn "zenoss plugin for '--display' not present"
fi 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 *) # stdout default
;; ;;
esac esac
@ -365,8 +500,7 @@ return 0
# 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 # RETURNS: 0
# REQUIRES: die(), display_csv(), display_terse(), display_zenoss(), notify_mail(), # REQUIRES: die(), display_*(), notify_*(), warn()
# notify_sms(), notify_eif(), 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}"
@ -444,6 +578,87 @@ then
else else
warn "display_zenoss plugin is not available, cannot display_results!" warn "display_zenoss plugin is not available, cannot display_results!"
fi 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 else
# default STDOUT # default STDOUT
if (( ARG_VERBOSE != 0 )) if (( ARG_VERBOSE != 0 ))
@ -610,6 +825,69 @@ case "${REPORT_STYLE}" in
ARG_VERBOSE=0 ARG_VERBOSE=0
fi 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 *) # init/boot default, stdout fallback
if (( HAS_DISPLAY_INIT == 1 )) if (( HAS_DISPLAY_INIT == 1 ))
then then