From: Einar Jørgen Haraldseid Date: Fri, 4 Nov 2016 11:51:08 +0000 (+0100) Subject: A tiny reminder script for icinga/nagios X-Git-Url: https://git.slaskete.net/einar-bin/commitdiff_plain/8efe12ba5ebe4e282853ab4de03b4d9a716fb750 A tiny reminder script for icinga/nagios --- 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