Watch the server¶
Check the configuration: uFTP --check¶
sudo -u uftp uFTP --check /etc/uftp/uftpd.cfg
It reads the configuration as the server does and looks at the ports, the certificate (and how long it lasts), the log folder, the homes and the owners. It writes nothing and starts nothing. Run it as the user of the server. The exit status is 1 if the server could not start. It does not try PAM, the hooks and the firewall.
uftpctl¶
CONTROL_SOCKET = /run/uftp/control.sock
| Command | What it does |
|---|---|
uftpctl status |
Version, connections, transfers, end of the certificate |
uftpctl who |
The connections: number, user, address, TLS, seconds, inactivity, what each one is doing |
uftpctl kick 12 |
Close the connection 12 (the client gets 421) |
uftpctl kick-user name |
Close the connections of a user |
uftpctl reload |
Read the TLS certificate and the users again, like SIGHUP |
Two more commands do not talk to the server, they change the configuration file: uftpctl adduser adds an FTP user and
uftpctl passwd NAME changes the password of one (see Users). They do not need CONTROL_SOCKET.
It is off by default. The socket has mode 600, and only root and the user of the server are listened to. The path must be absolute, in a folder that the server can write
(with the unit of contrib/systemd it is /run/uftp).
Health and metrics¶
HEALTH_PORT = 8080
HEALTH_LISTEN_ADDRESS = 127.0.0.1
| Page | Answer |
|---|---|
/livez |
200, or 503 if the control loop has been blocked for more than 30 seconds |
/readyz |
200, or 503 while the server is stopping, or when no home or not the log folder is accessible |
/metrics |
Text for Prometheus |
The metrics are the connections (open, allowed, accepted, refused), the sessions, the logins (ok, failed), the transfers (active, ok, failed, bytes), the slow commands, the age of the control loop and the end of the TLS certificate. They never have names of users, files or addresses.
There is no password: keep the local address, or protect the port with a firewall. An address that is not local is a warning in the log. The users of an authentication hook have no home to check.
scrape_configs:
- job_name: uftp
static_configs:
- targets: ["127.0.0.1:8080"]
Alert rules¶
Prometheus can evaluate alert rules and show them as pending or firing alerts. For example, create /etc/prometheus/uftp.rules.yml with these rules:
groups:
- name: uftp
rules:
- alert: UFTPDown
expr: up{job="uftp"} == 0
for: 2m
labels:
severity: warning
annotations:
summary: "uFTP metrics endpoint is unreachable"
description: "Prometheus has not scraped {{ $labels.instance }} successfully for at least two minutes."
- alert: UFTPCertificateExpiresWithin30Days
expr: (uftp_tls_certificate_not_after_seconds - time()) < 2592000
for: 10m
labels:
severity: warning
annotations:
summary: "uFTP TLS certificate expires within 30 days"
description: "The certificate on {{ $labels.instance }} expires in less than 30 days."
Add the rule file under the existing rule_files section in /etc/prometheus/prometheus.yml:
rule_files:
- /etc/prometheus/uftp.rules.yml
If rule_files already exists, add the path to that list. Validate the rule and Prometheus configuration, then reload Prometheus:
sudo promtool check rules /etc/prometheus/uftp.rules.yml
sudo promtool check config /etc/prometheus/prometheus.yml
sudo systemctl reload prometheus
The rules appear in Prometheus as pending or firing alerts. Prometheus does not send notifications itself. To receive email or another notification, configure Alertmanager and a receiver. See the Prometheus examples in the repository.
The Docker image uses /livez for its HEALTHCHECK.