Skip to content

Instantly share code, notes, and snippets.

@natemccurdy
Last active March 15, 2016 20:23
Show Gist options
  • Save natemccurdy/b68497e1769c16e8fab0 to your computer and use it in GitHub Desktop.
Save natemccurdy/b68497e1769c16e8fab0 to your computer and use it in GitHub Desktop.
Check when the last class refresh happened in the Puppet Node Classifier
#!/bin/bash
# GIST_URL: https://gist.github.com/b68497e1769c16e8fab0
# Get the timestamp of the last class update in the Node Classifier.
# This can be run from any Puppet Master or the Puppet Console.
# https://docs.puppetlabs.com/pe/latest/nc_last_class_update.html
CONFDIR="$(puppet master --configprint confdir)"
CERT="$(puppet master --confdir "${CONFDIR}" --configprint hostcert)"
CACERT="$(puppet master --confdir "${CONFDIR}" --configprint localcacert)"
PRVKEY="$(puppet master --confdir "${CONFDIR}" --configprint hostprivkey)"
OPTIONS="--cert ${CERT} --cacert ${CACERT} --key ${PRVKEY}"
CONSOLE="$(awk '/server: /{print $NF}' "${CONFDIR}/classifier.yaml")"
/opt/puppetlabs/puppet/bin/curl -s -X GET $OPTIONS "https://${CONSOLE}:4433/classifier-api/v1/last-class-update" | python -m json.tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment