oceanus: warn when build or root storage reaches 85 percent

This commit is contained in:
Brad Stein 2026-12-05 13:13:24 -06:00
parent f5217df6b7
commit ce16ed288c
3 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,11 @@
[Unit]
Description=Check root and Lesavka build storage usage
[Service]
Type=oneshot
ExecStart=/usr/local/libexec/lesavkaci/storage-usage
DynamicUser=yes
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=true
SyslogIdentifier=lesavka-storage

View File

@ -0,0 +1,10 @@
[Unit]
Description=Check root and Lesavka build storage every five minutes
[Timer]
OnCalendar=*:0/5
Persistent=true
Unit=lesavka-storage-usage.service
[Install]
WantedBy=timers.target

View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Systemd interprets the journal priority prefix on stdout.
set -eu
warn_usage() {
local used
used=$(df --output=pcent -- "$1" | tail -1 | tr -d ' %')
if (( used >= 85 )); then
printf '<4>Lesavka storage warning: %s filesystem is %s%% used (threshold 85%%).\n' "$1" "$used"
fi
}
warn_usage /
if mountpoint -q /mnt/veles && [[ -d /mnt/veles/lesavka ]]; then
warn_usage /mnt/veles/lesavka
else
echo '<4>Lesavka storage warning: NVMe mount or Lesavka directory is missing.'
fi