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:
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.
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
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.