diff --git a/check_puppet_agent b/check_puppet_agent index 1ebcc84..64a45b3 100755 --- a/check_puppet_agent +++ b/check_puppet_agent @@ -84,8 +84,6 @@ # 20170426 benwtr Detect failure to retrieve catalog from server as a warning. # 20180324 deric Discard puppet config error (logging) output -declare -A puppet_config_list - # FUNCTIONS result () { case $1 in @@ -204,7 +202,11 @@ while getopts "c:d:l:s:r:w:v:PEh" opt; do done parse_puppet_config () { - [ ${puppet_config_list[$1]+abc} ] && echo ${puppet_config_list[$1]} || echo "" + echo "$puppet_config_output" | while read key value; do + if [ "$key" = "$1" ]; then + echo "${value#= }" + fi + done } [ -z "$HOME" ] && export HOME=$(getent passwd `whoami` | cut -d: -f6) # Some clean environment situations make puppet -V fail. @@ -234,14 +236,7 @@ case $puppet_major_version in ;; esac -# Construct the associative array puppet config list -while read key value -do - puppet_config_list[$key]=${value#= } -done <<_EOT_ -`$puppet_config_print 2> /dev/null` -_EOT_ - +puppet_config_output="$($puppet_config_print 2> /dev/null)" # construct WARN and CRIT times based on runinterval plus a safety buffer # if they have not already been explicitly set runinterval=$(parse_puppet_config "runinterval")