Skip to content
jalogisch

nobody was watching - updown from the outside, beszel from the inside

· tools linux monitoring

Until three weeks ago, nothing watched my servers. No check from the outside, no alarm. If the blog was down, I would notice after a few days, or weeks. The backups? At least the script has a cron job that calls it, right? Proof, I had none.

Funny position for someone who likes to say “the truth is in the logs”. Logs only help when somebody looks at them.

I wanted two things: an alarm when something is down, also when I am not at the laptop, and graphs that show when an update suddenly needs more CPU or memory. My hoster shows CPU and network, but no RAM. Two tools, one job each.

from the outside: updown.io

A check that runs on my own server cannot tell me that my server is gone. I use updown.io (ad).

Every five minutes it checks the websites, my git server, the webmail, and SMTP and IMAP over TCP, with alarm by mail and SMS. The mail server checks send only SMS: an alarm mail through the broken mail server is no alarm.

What I like most is the price model. No plans, no tiers, no “contact sales for more than ten monitors”. You buy credits, one request is one credit. 200,000 credits cost 5 euro plus VAT. My eight checks every five minutes are about 69,000 requests a month, so about two euro. One SMS costs 7,500 credits, about ten cent. That is fair.

One trap: the API does not tell you how many credits are left, and an empty account means silent monitoring. In the billing settings, updown can buy the same pack again when the credits last only ten more days. I switched that on.

New accounts get 100,000 credits for free. With my referral link (ad) you get 100,000 more on top. Honest: when you buy for the first time, I get 100,000 too. If you do not like that, go to updown.io directly. Same tool. Same price. No benefits.

pulse for the timers

The other question: did my job run? updown calls this pulse. The job calls a secret URL when it is done. No call within the period, alarm. In systemd that is one line:

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup.sh
# runs only when ExecStart was successful
ExecStartPost=/usr/bin/curl -fsS -m 10 --retry 3 -o /dev/null https://pulse.updown.io/<your-pulse-url>

A broken backup does not call home, and the alarm comes. Daily jobs get 26 hours, because my backup timer starts with up to one hour random delay.

checks as code

I did not want to click fourteen checks together and forget later why one exists. So there is one file in git, here simplified:

mail = "me@example.org"

[[check]]
name = "blog"
url  = "https://blog.example.org/"
to   = ["mail", "sms"]

[[check]]
name = "mail smtp"
url  = "tcp://mail.example.org:25"
to   = ["sms"]        # an alarm mail through the broken mail server is no alarm

[[pulse]]
name   = "web01-backup"
period = 93600        # 26 h: daily, plus up to 1 h random delay
to     = ["mail"]

A small Python script, standard library only, reads it. Without a flag it shows a plan, with --apply it does it. It never deletes; what exists only at updown, it reports. The Terraform provider is abandoned since 2022, and its fork is one person who would get my full API key. About 140 lines of my own are easier to trust.

from the inside: beszel

In Warhammer 40k, an auspex is the scanner that shows what is coming before it is in front of you. My auspex is Beszel. MIT license, a hub with the dashboard and an agent on every server. Small means small: on my servers the hub needs about 44 MB RAM, the agent about 20 MB. Prometheus with Grafana can do more. I do not need more.

It fits my rootless Podman setup: all containers run as a normal user, and hub and agent are just two more Quadlet files. The agent connects to the hub by itself over WebSocket. No new open port, no SSH from the hub to the servers. With a universal token, a new server registers itself on the first start.

# ~/.config/containers/systemd/beszel-agent.container
[Container]
Image=docker.io/henrygd/beszel-agent:0.21
# host network, otherwise the agent does not see the network cards
Network=host
Volume=/run/user/1000/podman/podman.sock:/run/user/1000/podman/podman.sock:ro
Environment=HUB_URL=https://metrics.example.org
Environment=DOCKER_HOST=unix:///run/user/1000/podman/podman.sock
Environment=DISABLE_SSH=true
# TOKEN and KEY from your password manager, not from git
EnvironmentFile=%h/.config/beszel/agent.env
NoNewPrivileges=true
DropCapability=all

[Install]
WantedBy=default.target

Two things to know before you copy this.

The socket is the keys to the house. With the Podman socket the agent shows CPU and memory for every container. But :ro does not make a socket read-only. Whoever takes over the agent controls all containers of that user. Not root, but still every website on the server. I took that trade, knowing it.

The superuser shares your password. Beszel creates the database admin with the same password as the first user, and that admin can do everything. My proxy answers /_/ and /api/collections/_superusers with a 403, and I reach the admin panel only through an SSH tunnel.

Beszel can also send alarms and run network checks. I use neither. “Who watches the watchmen?” is written on the walls in “Watchmen”. My answer: not the server itself. When the server is gone, its alarm is gone too. Graphs here, alarms there.

I wrote the same in 2012 (in German): monitoring and metrics can be looked at together, but should be separate. Fourteen years later, I still think so.

boring, on purpose

About two euro a month and less than 100 MB RAM. No monitoring platform, no dashboard wall, no on-call rotation for one person. For two servers and one mail box, that is enough. Maybe it is exactly right.

The backups still run every night. Now I have proof.

Read more: updown.io pulse, Beszel agent installation, Beszel releases.

Ad (Werbung): links marked “(ad)” are my updown.io referral link. If you sign up through it, you get 100,000 extra credits, and I get 100,000 credits when you buy for the first time. Nothing changes in the price for you.