Skip to content

Commit

Permalink
Merge pull request #57 from aswen/revert_52
Browse files Browse the repository at this point in the history
Revert "Improving the way to get Puppet config value"
  • Loading branch information
aswen authored Jul 29, 2019
2 parents 4797af7 + 96db3d5 commit ccf16ae
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions check_puppet_agent
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit ccf16ae

Please sign in to comment.