Simple web server monitoring with bash

There are lots of great enterprise infrastructure monitoring tools out there, like Nagios. And if you want to monitor a web page in minutia (i.e. detecting if a single pixel has changed), there’s stuff like Puppeteer.

But sometimes a web server just did something weird, and you want to keep an eye on it for a little while. I do that with a bash script.

servercheck.sh
1
2
3
4
#!/bin/bash
wget -qO /dev/null 'https://www.yoursite.com/index.html' || {
notify-send -u critical 'Damnit! The server is down!'
}

I’m using libnotify on Linux to pop up an alert on my screen, and because I have KDE Connect, it’ll buzz my phone too. Schedule it to run every 15 minutes or so during the day with a little cron magic, and you can stop compulsively refreshing your browser every 5 minutes.