Created
July 21, 2015 14:28
-
-
Save andrekeller/b484940909c6617fadc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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