So, you probably have multiple servers, and you somehow want to monitor them.
Today, I will show you two types of self-hosted (FOSS) monitoring you can use:
- Uptime monitoring to get alerted when things go down, while also providing a nice status page
- System monitoring, to get alerted when things happen (e.g., out of RAM, CPU load too high, etc.)
Uptime Monitoring
First we’ll look at uptime monitoring. This will allow you to install a piece of software called Uptime Kuma, on some server, which will then ping other servers to check on their uptime, and let you know if they’re down. Make sure to install this on some server that is likely to be up all the time, as monitoring won’t work if the server which does the monitoring goes down!
To install Uptime Kuma you will need either Podman or Docker (run the appropriate command depending on what you use):
podman run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma docker.io/louislam/uptime-kuma:1
docker run -d --restart=always -p 3001:3001 -v uptime-kuma:/app/data --name uptime-kuma louislam/uptime-kuma:1
Once you run this, you can visit Uptime Kuma on your server on port 3001 to create an admin account and then start using it.
Note: It is recommended to keep port 3001 firewalled, and connect through SSH port forwarding or a VPN instead for the setup, and then putting Nginx or Caddy in front of it for HTTPS.
To start using it, simply click on “Add New Monitor”. If you want to monitor a website, choose “HTTPS”, insert the full address, let it check every 60 seconds.
I recommend setting retries to something between 5 and 15. This means that it will not instantly alert you but instead retry a few more times, in effect only alerting you if it’s still down after 5 – 15 minutes. This can be useful if your host is only down once or there was a connection error, but it works in the next minute. You don’t want needless alerts!
You can also use Ping monitors to just check if a host is up, or Port monitor to check if some service on some port is up and running. There are many more, go explore!
Make sure to set up notifications in the settings! I recommend setting up Pushover, but Email (SMTP) works too, or any other you desire. That’s about it!
System Monitoring
Now, while uptime monitoring is important, it might be pretty basic. What if the server is running out of resources? What if there are anomalies? You might want to know!
For this, we’ll be using Netdata.
Now, here’s the thing about Netdata, there are two options:
- You can run it completely self-hosted without cloud (but you’ll have to set up some form of reverse proxy and authentication yourself). You also have to deal with email sending.
- Or, you can create a cloud account with Netdata, to connect all your servers with their dashboard, and authentication, HTTPS and emails will be dealt with for you.
Netdata claims they stream the data straight from your servers to the dashboard and that they don’t keep a log or anything, which is why the cloud setup does not seem so bad.
The basic command to install Netdata is this:
curl https://my-netdata.io/kickstart.sh > /tmp/netdata-kickstart.sh && sh /tmp/netdata-kickstart.sh --stable-channel --disable-telemetry --non-interactive --auto-update --static-only
This will cleanly install Netdata to /opt/netdata so that it can easily be removed again later.
After installation, you can connect to your server at port 19999 to view all data. It is highly recommended that you firewall this port, and set up Nginx with authentication and HTTPS in front of it. Alternatively, use SSH port forwarding or a VPN. If you want to get emails from Netdata in this self-hosted setup, I recommend setting up Postfix (assuming no email server is installed yet).
Alternatively, if you want to connect with Netdata cloud, you’ll have to create an account with them, sign in to the dashboard and choose “add nodes”, this should give you a claim token. Copy that token and run this command:
/opt/netdata/bin/netdata-claim.sh -token=YOUR_TOKEN_HERE
Since this also means you’ll now get emails from Netdata cloud, it’s probably a good idea to disable your node from sending emails by itself:
/opt/netdata/etc/netdata/edit-config health_alarm_notify.conf
This will open a text editor with the config. Look for SEND_EMAIL="YES"
and replace it with SEND_EMAIL="NO"
, save the file and exit. Netdata will apply the change automatically.
I also recommend changing the notification settings in Netdata to “critical only”, as you probably don’t want to get spammed with useless warnings.
Conclusion
As you can see, it’s fairly easy to get started with simple monitoring. Just one command for uptime monitoring, and one command for system monitoring (and two more if you want cloud).
I hope I have given you a good starting point. If you’re not yet monitoring your servers, you should!
Please note that I run this blog in my free time. Consider donating a cup of coffee if I helped you out!
Leave A Comment