Is there an existing solution for systemd based systems to call a user defined script when usage on some filesystem exceeds or falls short of certain limits, without implementing a polling every some seconds which sounds inefficient ?

For some device mapper based devices, dmeventd can trigger a script based on snapshot usage levels, but this works on the block device level. I'm seeking a solution on the filesystem level.

The first thing I would like to use it for is to adjust tmpfs limits dynamically based on current swap space usage: If some program wants to use more /tmp space, enough swap is still free and the amount of dirty pages is low enough, the script can increase the limit in mount -oremount,size=%LIMIT /tmp and reduce it to a minimum after files are deleted.
But if swap is almost full or too many dirty pages (the program in question writing too fast), the script would instead log the current usage, find the causing process using lsof and keep the tmp limit low to ensure system stability.

I'm unsure about the right tags to use so suggestions are welcome.


You must log in to answer this question.

Browse other questions tagged .