💾 Archived View for gmi.bacardi55.io › gemlog › 2022 › 02 › 22 › capsule-monitoring captured on 2023-04-26 at 13:13:38. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Posted on 2022-02-22
Yesterday I read Jon's article about capsule monitoring¹. I discovered the article through Antenna and wasn't aware of the service he provides to geminauts to help monitoring their capsule.
Basically you give him a URL to check and you'll will receive a notification if the service is down (after multiple checks).
And it also provide a nice status page for all covered capsules².
Jon is gently offering his service for free for fellow geminauts that wants to, and if you don't have any type of health check in place, I suggest you take a look :).
I already have this kind of service in place for my main https website, but reading the article reminded me I didn't do it for my capsules.
After reading the article I start thinking "should I reach out to Jon to add my capsule?" or "should I selfhost his service as it's open source³?".
Then it hit me… I already have a service in place that almost does this: Houston⁴!
For those that doesn't know, I created a small service that check if a capsule is up or down, like the well known service downforeveryoneorjustme.com or alike in the http(s) world.
You can go to the houston capsule to try some urls (only gemini protocol is accepted):
Check a capsule's status with Houston.
The service itself doesn't really do what I wanted, which in summary is:
- Check a capsule every X minutes
- If a capsule seems down, double check
- If it is really down, notify me
So my simple idea was to create the smallest bash script to actually automate the testing based on Houston.
For that, I installed on a server gemtext⁵, a very nice command line tool to request and download gemini pages (thank you @makeworld⁶!). It is in golang and can easily be installed or you can just download a pre-compiled binary in the release page.
Now that I selected the gemini page "downloader", all I needed was a few lines of bash script:
#!/bin/bash # check-capsule.sh script. Will check all urls in the URLS variable ## Configuration: # URL to check: URLS=("gmi.bacardi55.io" "feeds.gmi.bacardi55.io" "tinylogs.gmi.bacardi55.io") # Houston (tester) URL: HOUSTON_URL="gemini://houston.gmi.bacardi55.io/cgi-bin/houston?" # Script: for url in ${URLS[@]} do RESPONSE=$(/path/to/bin/gemget -q -o - "${HOUSTON_URL}${url}" | grep "Everything seems ok" | wc -l) if [ "$RESPONSE" == "0" ]; then # echo "Capsule ($url) not responding correctly, waiting 60s for a double check" sleep 60 RESPONSE2=$(/path/to/bin/gemget -q -o - "${HOUSTON_URL}${url}" | grep "Everything seems ok" | wc -l) if [ "$RESPONSE2" == "0" ]; then printf "Subject: Capsule $url is down\nCapsule $url seems down…" | msmtp -a default my@email.abc fi fi done
You can easily reuse it by just changing the urls to check and the email address if you have msmtp⁷ configured.
Or a correctly configured MTA will do, but then you'll need to change the command that actually send the email.
Then I just added a crontask to automate the script with (with `crontab -e`)
And voilà :), a poorman's version of a status check solution :). I've set it up during the day and it seems to work correctly since (I did a few tests by stopping one of my capsules).
Clearly it could be optimized a lot, for example:
But that's enough for now, and still an improvement from not having any health check in place at all!
So thank you Jon for your article, as well as offering free health check to geminauts! I may not use it, but I find it still useful for the overall community!
3: status.shit.cx source code (HTTPS)