No space left on device

Monit is a AGPL 3.0 licensed process supervision monitoring agent for Unix/Linux. It has the ability to preform user-defined actions based on the state of its host. The default polling ‘cycle’ is 30 seconds which is adjustable.

It has a space usage test, eg:

/etc/monit.d/stor-sdb1.conf

check filesystem storfs with path /mnt/stor
       every 2 cycles   # poll every 1 min
       group storage
       group stor
       start program = "/bin/mount -a /dev/sdb1 /mnt/stor"
       stop program = "/bin/umount /mnt/stor"
       onreboot laststate
       mode active
       if does not exist then start
       if space usage > 90% then alert
       if space usage > 99% then stop

Other actions are restart, exec and unmonitor based on percentage, B, KB, MB and GB. This allows the ability to go as far as unmounting the storage device (as shown) if not simply terminating individual or grouped processes (eg: Kopia-UI, Kopia Respository Server, WebDAV related daemons, etc.).

It is coded in C which I understand Golang draws certain similarities.

Surely Kopia devs can adapt an approach and incorporate it accordingly.

See SPACE USAGE TEST, Version 5.34.4, Monit manual