heyer.systems Open Source

Disk space check

Every 15 minutes: warns before a local file system runs full – free space in percent and absolute (10 % of 80 TB are still 8 TB), free inodes and the rate it fills (full within 48 hours, or within 6 hours at the rate of the last hour). In the journal, by mail with the module mail-relay and in the security report. Now: iac-disk-space

disk-space LXCVM

Add to a guest

In the guest as root – container and VM alike:

update --add-modules disk-space

Runs a normal update and installs the module on the way.

From the Proxmox node, without logging in:

pct exec <ID> -- update --add-modules disk-space   # container
ssh root@<IP> update --add-modules disk-space

Choose when creating a guest

Without a dialog, on the Proxmox node:

IAC_NONINTERACTIVE=1 var_modules=auto-update,disk-space \
  bash -c "$(curl -fsSL https://iac.heyer.systems/<app>/ct.sh)"

var_modules replaces the app's preselection – keep auto-update in the list if you want it. Interactive: choose “advanced” in the dialog, or tick the module in the generator on the app page.

Remove

update --remove-modules disk-space

Removes the module's packages, services, firewall rules and configuration again. Data stays.

Details

Checks the local file systems of the guest every 15 minutes and warns before one runs full – in the journal, by mail and in the security report.

When it warns

A percentage alone does not tell how urgent it is: 10 % of 80 GB are 8 GB, 10 % of 80 TB are still 8 TB. So a file system is low only when it is below both limits – and it is low when it fills fast, whatever is free now:

LevelSpaceInodesRate
warningless than 10 % and less than 50 GiB freeless than 10 % freefull within 48 hours at the rate of the last 24 hours
criticalless than 5 % and less than 10 GiB freeless than 5 % freefull within 6 hours at the rate of the last hour

The rate needs samples first: a quarter of the window, so 15 minutes for the last hour and 6 hours for the last 24 hours. A file system that only gets emptier never warns for its rate.

How it notifies

WhereWhenNeeds
Journal (iac-disk-space)every check, one line per file system – priority crit for critical, warning for low, info for oknothing
Mail to rootwhen a file system becomes low or critical, when its level changes, once a day while one stays low, and once when all are ok againthe module mail-relay – the mail goes to mail_root_to
Security reportevery week and after every update: a line in the summary (disk space: 1 critical, 0 low), every file system in its own part and in security.json – so NetBox shows it toothe module security-report

The subject of the mail names the guest and the file systems, e.g. Disk space web1.example.org: 1 critical, 0 low: /srv; the text lists every file system as iac-disk-space shows it. Without mail-relay there is no mail – the warnings are in the journal and, with the module security-report, in its report. Test the mail with printf 'Subject: test\n\nhello\n' | sendmail root.

Settings

In /etc/iac/settings.env, then run update – all optional:

disk_space_warn_percent=10    # warning below this percentage …
disk_space_warn_gb=50         # … and below this many GiB free
disk_space_warn_hours=48      # warning when full within this many hours (rate of 24 hours)
disk_space_crit_percent=5
disk_space_crit_gb=10
disk_space_crit_hours=6       # critical when full within this many hours (rate of the last hour)
disk_space_ignore=/media      # mount points not to check, comma separated

disk_space_ignore is for file systems that other guests check already – e.g. the shared /media of the module media-share. Network file systems (NFS, SMB) are never checked.

Read it

iac-disk-space                           # check now and show every file system
journalctl -u iac-disk-space -p warning  # past warnings
systemctl list-timers iac-disk-space.timer
Disk space of web1.example.org – 1 critical, 0 low: /srv
CRITICAL  /srv                 41.2G free of 500.0G (8.2 %), losing 9.0G/h – full in ~5 h [growth]
OK        /                    6.1G free of 8.0G (76.3 %), inodes 89.0 % free

What it does not cover

S.M.A.R.T. and the health of the disks: an LXC container sees no disks, a VM only virtual ones. That is the job of the Proxmox host – smartd runs there already; set a target under Datacenter → Notifications and it mails disk errors.

When the module is removed, the check and its samples go again.