Pingdom alternative in one line of curl through ntfy.sh
I'm personally drawn to small footprint solutions that give me a sense of "cheating" the system by accomplishing tasks with minimal amounts of code (or ideally none), so instead of writing my own uptime monitoring solution, I ended up with a simpler approach which is basically a one-liner.
It involves ntfy.sh, which is a simple HTTP-based pub-sub notification service. All you have to do is install their mobile app and create a unique "topic" which you then can send an instant push notification on that topic with just an HTTP request:
curl -d "Homepage is down" ntfy.sh/mytopic
Now let's say we want to notify ourselves whenever our www.site.com becomes unresponsive. If we execute this command, it will send a post request to our ntfy.sh topic only if our first curl command fails:
curl --silent www.site.com >/dev/null || curl -d "Site is down" ntfy.sh/mytopic
That means we can now put it on a cron to run every minute and we would get notified if our site suddenly goes down.
Open crontab in edit mode crontab -e
and add:
* * * * * curl --silent www.site.com >/dev/null || curl -d "Site is down" ntfy.sh/mytopic