Monitoring Homelab with Uptime Kuma

So I've been looking for a good option for monitoring my homelab. I've done the googling and a lot of it showed prometheus or zabbix, and while I don't have anything against either solution they are just overly complicated, overly detailed and just generally more than I need. I was looking for something simple that I could setup the things I want monitored, get a nice up/down dashboard to look at. Ideally one that would tell me at a glance that everything is green and good. I don't need to know how much cpu each process is using, I don't want to have to setup snmp.

So what do I care about? well I have some daemons that I want to know they are running, like sshd, samba-ad-dc, etc. I also have some docker containers that I want to know are up and healthy, and a few apps on subdomains that I want to know are returning 200's, and maybe a host or two that I can ping to ensure they are still up and responding.

This may not sound like a good usecase for something that's primary function is pinging hosts to ensure they are up, but I was pleasantly surprised by how well it fit. To start with uptime kuma is very simple to get up and running, create a few storage directories, and set a few environment variables in the docker compose file and docker compose up -d will do the rest for you. Once it was up and running adding checks was also pretty simple. The pinging hosts was just a matter of clicking through and adding the ip/hostname to ping and optionally adding it to a group. Docker monitoring wasn't much more difficult. It did require mounting the docker socket into the container for communication but other than that you give it a nice label and plug in the container name and you're good to go with that too. The remaining one was the most difficult I've setup so far, daemon monitoring. And even that is solved pretty trivially with a bash script and a text file. To be fair you could merge the text file into the bash script if you really want to. The bash script I used can be found below.

#!/bin/bash
cat services.txt | while IFS=, read -r servicename url
do
        if systemctl status $servicename | grep "Active: active (running)"
        then
                curl $url
        fi
done

Very simple, it just checks the service and verifies that the status is active (running), if so it calls the url for a webhook in uptime kuma. This seems to be a moderately documented feature that the developer expects users to be fairly technical to use and the community suggests that unless you know you need it you probably shouldn't use it. That said its also a fairly simple feature. When you add a Push monitor type instance it gives you a url, lets you set some variables and the category and friendly name like most other types. Then you have to setup some way to call that url to check in. In my example I simple use curl inside a bash script that itself is called by a cron job running once a minute. I will admit I may need to do a bit of tuning because I'm pretty sure I got a few false positives overnight, but that's understandable. Sane defaults are just that, reasonable defaults for most use cases. Doesn't mean they will fit for all the cases, just a good baseline to be tweaked and tuned as needed.

Similar scripts could be written for most anything you can check with the command line, for example you could write a script to parse the output of df and hit the url unless a line that starts with /dev has a percent above 90. Which will let you know if any of your partitions start to get too full.

Obviously Uptime Kuma is not a full featured monitoring platform, but for simple checks it works just fine. With the added benefit of being easy to reconfigure as you add and remove services/endpoints.