From: Einar Jørgen Haraldseid Date: Fri, 4 Nov 2016 11:53:24 +0000 (+0100) Subject: Merge branch 'master' of ssh://git.slaskete.net:/srv/git/einar-bin X-Git-Url: https://git.slaskete.net/einar-bin/commitdiff_plain/5b5a51570353e143f299b4fb520e0a0e673bc4f4?hp=269e8fe473c36b750b0fb69b924388a18439f449 Merge branch 'master' of ssh://git.slaskete.net:/srv/git/einar-bin --- diff --git a/generatortest.sh b/generatortest.sh new file mode 100755 index 0000000..b633dec --- /dev/null +++ b/generatortest.sh @@ -0,0 +1,18 @@ +#!/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