Nice work! Your going to want to run the curl checks at least every minute via a cron job. Also keep in mind your dig's can be cached so it can get a bit more complex. I do things slightly different in bash and only call an API when action is needed (ie server goes down)
Cloudflare has many...