Skip to content
Browse files

Updated mailpuppicheck

  • Loading branch information...
1 parent bf5e873 commit 1061cb731bc75a1188b58b889b74ce1505ccb412 @alvagante alvagante committed May 5, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 files/mailpuppicheck
View
17 files/mailpuppicheck
@@ -8,7 +8,6 @@
# postrun_command = "/usr/bin/mailpuppicheck -m roots@example.com"
#
retries=1
-interval=8
workdir="/tmp"
counter=0
while [ $# -gt 0 ]; do
@@ -19,9 +18,6 @@ while [ $# -gt 0 ]; do
-r)
retries=$2
shift 2 ;;
- -i)
- internal=$2
- shift 2 ;;
esac
done
@@ -30,13 +26,13 @@ if [ ! $mail ] ; then
exit 1
fi
-randfile="$(mktemp)"
+# randfile="$(mktemp)"
lastrunfile=$workdir/puppicheck_lastrun
savedfile=$workdir/puppicheck_saved
while [ $counter -lt $retries ] ; do
- puppi check -s fail | grep -A1 FAILED > $lastrunfile
- if [ $(grep FAILED $lastrunfile) ] ; then
+ puppi check | grep FAILED > $lastrunfile
+ if [ "x$?" == "x0" ] ; then
errors="yes"
else
errors="no"
@@ -49,16 +45,17 @@ while [ $counter -lt $retries ] ; do
done
diff $lastrunfile $savedfile
-if [ $? == 0 ] ; then
+if [ "x$?" == "x0" ] ; then
echo "No changes detected"
else
echo "Changes detected"
notify="yes"
fi
cp $lastrunfile $savedfile
-if [ x$notify == "xyes" ] ; then
- cat $lastrunfile | mail -s "[puppet] Errors after Puppet run on $(hostname -f)" $mail
+if [ "x$notify" == "xyes" ] ; then
+ # Yes, it's ugly
+ cat -v $lastrunfile | sed -e 's:\^\[\[60G\[\^\[\[0;31m: :g' | sed -e 's:\^\[\[0;39m\]\^M: :g' | mail -s "[puppet] Errors after Puppet run on $(hostname -f)" $mail
echo "Sent notification"
fi

0 comments on commit 1061cb7

Please sign in to comment.
Something went wrong with that request. Please try again.