From 4b9b8e7de2e127b179bcae3599f52c503bd20023 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Wed, 25 Jul 2018 15:50:21 +0200 Subject: usr-lib-nagios-plugins/check_puppetmaster.sh: Port to being used against puppet 4.8.x. --- usr-lib-nagios-plugins/check_puppetmaster.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'usr-lib-nagios-plugins/check_puppetmaster.sh') diff --git a/usr-lib-nagios-plugins/check_puppetmaster.sh b/usr-lib-nagios-plugins/check_puppetmaster.sh index 5799a41..67bd249 100755 --- a/usr-lib-nagios-plugins/check_puppetmaster.sh +++ b/usr-lib-nagios-plugins/check_puppetmaster.sh @@ -104,9 +104,9 @@ while true ; do esac done -URL="https://${PUPPETMASTER}:${PORT}/production/node/${HOST}" +URL="https://${PUPPETMASTER}:${PORT}/puppet/v3/node/${HOST}?environment=production" T1=`date +%s.%N` -CURL_NODE="`curl -sS --max-time $TIMEOUT --insecure -H 'Accept: yaml' --cert $SSLDIR/certs/${HOST}.pem --key $SSLDIR/private_keys/${HOST}.pem --cacert $SSLDIR/certs/ca.pem "${URL}" 2>&1`" +CURL_NODE="`curl -sS --max-time $TIMEOUT --insecure -H 'Accept: pson' --cert $SSLDIR/certs/${HOST}.pem --key $SSLDIR/private_keys/${HOST}.pem --cacert $SSLDIR/certs/ca.pem "${URL}" 2>&1`" CURL_RESULT=$? T2=`date +%s.%N` @@ -115,14 +115,13 @@ PERF_TIME=$( perl -e "printf('%1.3f', $T2 - $T1);" ) if [ "$CURL_RESULT" != 0 ]; then EXIT=2 MESSAGE="${URL} $CURL_NODE" -elif FOUND=$( echo "$CURL_NODE" | grep -m 1 environment: ) ; then - # trim spaces... - FOUND=`sed 's/^ *.//' <<<$FOUND` +elif echo $CURL_NODE | grep '"environment":'; then + FOUND=$( echo "$CURL_NODE" | sed -r -e 's/.*"environment":"([^"]+)".*/\1/' ) EXIT=0 - MESSAGE="found '${FOUND}' in https://${PUPPETMASTER}:${PORT}/production/node/${HOST}" + MESSAGE="found '${FOUND}' in https://${PUPPETMASTER}:${PORT}/puppet/v3/node/${HOST}?environment=production" else EXIT=1 - MESSAGE="environment not found in https://${PUPPETMASTER}:${PORT}/production/node/${HOST}" + MESSAGE="environment not found in https://${PUPPETMASTER}:${PORT}/puppet/v3/node/${HOST}?environment=production" fi if ! perl -e "exit( $PERF_TIME >= $TIME_CRIT )" ; then -- cgit v1.2.3