Skip to content

Instantly share code, notes, and snippets.

@andrekeller
Created July 21, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrekeller/b484940909c6617fadc9 to your computer and use it in GitHub Desktop.
Save andrekeller/b484940909c6617fadc9 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Checks whether the last puppet run was recently and didn't fail
maxtime=90
summary="/var/lib/puppet/state/last_run_summary.yaml"
report="/var/lib/puppet/state/last_run_report.yaml"
if [ ! -f ${summary} ] || [ ! -f ${report} ] ; then
echo "UNKNOWN: puppet does not seem to be installed"
exit 3
fi
if [ "$( find $summary -mmin +$maxtime | wc -l )" -gt 0 ] ; then
echo "CRITICAL: Last puppet run more than $maxtime minutes ago: $( stat -c '%z' ${summary} )"
exit 2
else
if [ "$( grep 'status:' ${report} | grep fail | wc -l )" -gt 0 ] ; then
echo "CRITICAL: Last puppet run failed."
exit 2
else
if [ "$( grep 'Using cached catalog' ${report} | wc -l )" -gt 0 ] ; then
echo "CRITICAL: puppet is using cached catalog."
exit 2
else
echo "OK: Last puppet run recently: $(stat -c '%z' ${summary})"
exit 0
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment