Skip to content

Watch your servers

Know before it breaks

The worst problems are the ones nobody sees coming. Kiyesi warns about the full disk, the broken backup and the expiring certificate first.

Kiyesi draws a line through each disk’s used space over the last day and works out when it will be full at that rate.

As it arrives in Telegram:

Disk filling · uploads-prod
uploads-prod: disk /data is full in about 3 days at this rate (43 GB of 52 GB, growing 3.0 GB a day).
When a disk is full, databases stop writing, logs stop, and apps fail in ways that are hard to read.
sudo du -xh /data --max-depth=2 2>/dev/null | sort -rh | head -n 15
[ Acknowledge ] [ Open alert ]
[ Mute 30 min ]
  • An alert goes out when a disk will be full within 7 days, as critical within 2 days, and it is sent again once a day while it stays open.
  • It closes by itself when the disk has room for 10 days again, or stops growing.
  • It needs at least 6 hours of figures, and only real growth counts: a burst of writes that is cleaned up again raises nothing.
  • The server’s page shows each disk that is filling, with how long is left.

The fix lists the folders that grew most, so you can see what to clean up: old logs, uploads, Docker images (docker system prune), or a backup folder that is never cleared.

The backups check already says when a backup is late. Now it also opens the newest backup in each folder, as the tool that restores it would, and reads it through:

Backup What is checked
.gz, .tgz, .tar.gz The whole file decompresses and its checksum is right; a tar holds whole files
.zip Every file inside is whole
.tar Every file inside is whole
PostgreSQL and MySQL text dumps (pg_dump, pg_dumpall, mysqldump, mariadb-dump), plain or gzipped The dump reached its last line, which a dump cut short by a full disk or a lost connection never writes
PostgreSQL’s own format (pg_dump -Fc) Its header only: reading it through needs pg_restore

A backup that would not restore is a critical finding, with why: “The newest backup in /var/backups/db would not restore: the pg_dump dump never finished: its last line is missing.”

A backup that is suddenly less than a fifth of the one before (and the one before was over 1 MB) is a warning: a dump that ran against an empty or unreachable database looks just like this.

Each backup is read once, when it is new, and nothing is unpacked or copied. A backup over 1 GB is checked by its start only, so a scan never spends minutes on one file.

Tell Kiyesi where backups are written, in /etc/kiyesi/config.yaml:

backups:
paths: [/var/backups/db]
max_age_hours: 24

Each minute the agent reads SSH’s own record of who signed in. For a user and address it has not seen on that server before, it sends a short note: the user, the address, how they signed in and when. Nothing else from the sign-in records leaves the server.

Kiyesi places the address in a country, then sends a New sign-in alert when:

  • someone signs in from a country never seen on that server, or
  • someone signs in as root from an address never seen.
New sign-in · checkout-db-prod
root signed in to checkout-db-prod from 203.0.113.9 (Example Broadband, Netherlands) with a key: a root sign-in from a network not seen before.
If this was not someone on your team, the server may be in someone else's hands. Check who it was now.
sudo journalctl -u ssh -u sshd --since -24h | grep Accepted, then sudo kiyesi keys to see the keys that open it
If this was you or your team, there is nothing to fix: press This was us, so the team knows it was checked.
[ This was us ] [ Open alert ]
[ Mute 30 min ]

The first day after a server connects is learned quietly, so connecting a server does not send one alert for each teammate. Addresses on a private network (such as 10.x or 192.168.x) have no country and never alert. The alert is sent once and closes itself: there is nothing to fix if it was you. This was us notes, on the alert and in the activity log, who said the sign-in was the team’s, so everyone sees it was checked. Anyone who can act on the server may press it.

The server’s page lists the last 50 users and addresses that signed in, with country, method, and first and last time. As this names people and addresses, it is shown to those with Manage on servers and findings (the Owner and Admin roles, or a role you made with it). A user and address not seen for a year are forgotten.

To turn the sign-in watch off on a server, add to /etc/kiyesi/config.yaml:

logins: off