Automatic uptime checks from my phone

• Reading time: 4 minutes

Tired of being blind regarding the availability of my websites and services, I created a really basic setup allowing myself to be alerted in less than an hour if any of my apps fail to respond.

All my apps are running on a single OVH VPS. Knowing this, I couldn't setup a monitoring tool on the same infrastructure just in case of global failure.

Finding another hosting platform #

Having used Next.js a lot at my latest job, I deployed a lot of things on Vercel's platform. I also knew a free tier was available allowing hosting small apps with low traffic for personal use: a status checker app was the perfect use-case.

On top of that, a project specific CRONTAB allows for an easy task scheduling.

The API #

Next.js synergy with Vercel made me choose to spawn a minimalist Next.js app exposing a single /api/check endpoint.

When calling this route protected by a secret, a simple .json configuration file is parsed. From it, a collection of URLs to call is iterated over. On success, everything is fine, continue... On failure, a configurable number of retries is made. Definitive errors are listed inside a simple report sent via email through nodemailer alerting me of any app failure relatively fast. I couldn't think of a simpler solution.

Triggering the checkup #

My first approach was simply to set up a repeating CRON task every hour of the day except the "Hobby" plan wouldn't allow more than a daily task. A status checker checking if things are working properly only one time a day isn't really useful. I'm not running critical services that need permanent observability but triggering a check every hour seemed the right amount to aim for when I imagined the solution.

The missing piece #

As the integrated CRONTAB wasn't an option, I first created a local CRON job on my laptop knowing well enough it was only a band aid as it was going to fail as soon as I close the lid off.

Then, it clicked.

The real need was to be able to send a GET request reliably every hour. And if my laptop isn't open all day long, my phone is.

Thanks to the "Automation" system available out of the box on iPhone, it is possible to do exactly so.

I created 15 identical tasks:

  • When: "Every hour from 07:30AM to 09:30PM"
  • Do: "Get contents of .../api/check?secret=xxx"

That's it.

Afterthought #

Looking at this setup, we can also think of eliminating the intermediate API and only use iOS shortcuts by creating an automation for each app to monitor and analyze the returned content in order to detect failures.

This approach would multiply the number of automations needed by a factor of the number of checks needed each across the day.

The API allows centralizing everything in a single place and handling check-up and retry logic.