A Clojure/Babashka script for monitoring hackny.social's uptime
update readme with systemd unit files
properly handle bad status codes


browse  log 



You can also use your local clone with git send-email.

#hackNY uptime monitor

Occasionally we have some issues with hackNY.social going down for whatever reason. It sometimes takes me a bit to realize when this happens, so I figured a simple monitoring script would help me ensure better uptime.

I couldn've done this in Python or Ruby or some other mundane language but I've been on a Clojure binge lately and have been looking for an excuse to try babashka. After fiddling around with this script I can say I'm a fan!

Anyways, this script does the following:

  1. Requests the homepage of hackny.social and checks the HTTP status code.
  2. Records the status code to a SQLite3 database.
  3. If the status code is 200, do nothing.
  4. If the status code is not 200, check to see when the last notification was sent and, if it was greater than an hour ago, ping my phone via PushOver to let me know something is awry.

That's it! To run it, just make sure you have Babashka's bb in your $PATH and run bb check. It will create a new log.db file in your current working directory.

If you like what you see here I can imagine this is very easy to port over to your own use case (there's not a lot going on). Feel free to send me an email if you end up using it for something interesting and/or have any questions.

#Systemd unit files

This script isn't all that useful without some kind of cron job that runs it periodically. I use the following systemd unit files to activate the job:


Description=Monitor hackNY.social status

ExecStart=/home/steve/.local/bin/bb check



Description=Periodically checks hackNY.social's uptime



You can use these as user-level units by placing them in ~/.config/systemd/user and activating them with:

$ systemd --user start hackny-monitor.timer
$ systemd --user enable hackny-monitor.timer

Just remember to enable lingering so that the timers will run even if you're not logged in to your server:

$ loginctl enable-linger username


This project is released under the MIT License. See LICENSE.txt for more information.