Add health check email notifications

This commit is contained in:
jude 2023-06-23 09:39:09 +01:00
parent 6de11f09db
commit fc33ec11cb
4 changed files with 16 additions and 1 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reminder-rs" name = "reminder-rs"
version = "1.6.17-1" version = "1.6.18"
authors = ["Jude Southworth <judesouthworth@pm.me>"] authors = ["Jude Southworth <judesouthworth@pm.me>"]
edition = "2021" edition = "2021"
license = "AGPL-3.0 only" license = "AGPL-3.0 only"
@ -44,6 +44,8 @@ assets = [
["conf/Rocket.toml", "etc/reminder-rs/Rocket.toml", "600"], ["conf/Rocket.toml", "etc/reminder-rs/Rocket.toml", "600"],
["web/static/**/*", "lib/reminder-rs/static", "644"], ["web/static/**/*", "lib/reminder-rs/static", "644"],
["web/templates/**/*", "lib/reminder-rs/templates", "644"], ["web/templates/**/*", "lib/reminder-rs/templates", "644"],
["healthcheck", "lib/reminder-rs/healthcheck", "755"],
["cron.d/reminder_health", "etc/cron.d", "644"],
# ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"] # ["nginx/reminder-rs", "etc/nginx/sites-available/reminder-rs", "755"]
] ]
conf-files = [ conf-files = [

View File

@ -14,3 +14,5 @@ REMIND_INTERVAL=
OAUTH2_DISCORD_CALLBACK= OAUTH2_DISCORD_CALLBACK=
OAUTH2_CLIENT_ID= OAUTH2_CLIENT_ID=
OAUTH2_CLIENT_SECRET= OAUTH2_CLIENT_SECRET=
REPORT_EMAIL=

1
cron.d/reminder_health Normal file
View File

@ -0,0 +1 @@
*/10 * * * * reminders /lib/reminder-rs/healthcheck

10
healthcheck Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
export $(grep -v '^#' /etc/reminder-rs/config.env | xargs -d '\n')
VAR=$(mysql -N -D reminders -e "SELECT COUNT(1) FROM reminders WHERE utc_time < NOW() - INTERVAL 10 MINUTE AND enabled = 1")
if [ "$VAR" -gt 0 ]
then
echo "This is to inform that there is a reminder backlog which must be resolved." | mail -s "Backlog: $VAR" "$REPORT_EMAIL"
fi