Philipp's Blog

OpenBSD server: maintenance

In the previous parts of this series we did a base install of the server, installed a web server with certificates, set up the server to host git repositories and configured a mail server from scratch.

This part is about maintaining an OpenBSD server day-to-day.

Update the base system

syspatch installs patches for the base system components.

doas syspatch

Package management

Show all packages installed on the system:

pkg_info -q

Show information for a specific package:

pkg_info dovecot

Update all installed packages:

doas pkg_add -Uu

Services

Show all services enabled at boot:

doas rcctl ls on

Show all running services:

doas rcctl ls started

Show all stopped services:

doas rcctl ls stopped

Check a specific service:

doas rcctl check dovecot

Logs

General system logs:

doas tail -50 /var/log/messages

Authentication logs (SSH, failed su or doas):

doas tail -50 /var/log/authlog

Show the last logins to the server:

last

Check daemon/service logs:

doas tail -50 /var/log/daemon

Web logs:

doas tail -50 /var/www/logs/access.log
doas tail -50 /var/www/logs/error.log

General system metrics

Check filesystem usage:

df -h

Check the size of a directory:

doas du -xh -d 0 /var

System load:

uptime

The 3 numbers at the end show the load average for the last 1, 5 and 15 minutes.

Memory usage:

vmstat

To see the most important metrics at a glance use:

top

Show the SMTP log:

doas tail -50 /var/log/maillog

Spam-Filter logs:

doas tail -50 /var/log/rspamd/rspamd.log

To troubleshoot IMAP-client issues:

doas doveadm log errors

Show the mails currently in the queue:

doas smtpctl show queue

You might get an output like:

ae22a4e44b59c55e|inet4|mta|auth|bob@domain.net|alice@domain.net|alice@domain.net|1779712757|1779712757|0|16|pending|217|Network error on destination MXs

Get more detail on a message:

doas grep ae22a4e44b59c55e /var/log/maillog

View the contents of a message:

doas smtpctl show message ae22a4e44b59c55e

Retry all items in the queue:

doas smtpctl schedule all

Delete one queued message:

doas smtpctl remove ae22a4e44b59c55e