+#!/bin/bash
+# generatortest notifier for icinga
+# Alert if the file /tmp/generatortest is present, first with warning on Monday and then with critical on Thursday (day of test)
+# Must have this cron job:
+# At 08:00 on the first seven days of every month, check if it's a Monday, and output the date for the following thursday to the file /tmp/generatortest. Note that the % needs to be escaped when it's run through cron
+# 0 8 1-7 * * root [ "$(LC_TIME=en_US date '+\%a')" = "Mon" ] && date --date='+3 days' '+\%Y\%m\%d\%H\%M' > /tmp/generatortest
+TestFile="/tmp/generatortest"
+if [ -e "${TestFile}" ]; then
+ TestDate="$(head -n 1 "${TestFile}")"
+ Today="$(date +%Y%m%d%H%M)"
+ if [ "${Today}" -lt "${TestDate}" ]; then
+ echo "Reminder: generator test on Thursday"
+ exit 1
+ else
+ echo "Please run generator test today, then delete ${TestFile}"
+ exit 2
+ fi
+fi