I track filesystem usage on all my home machines using a small script which runs periodically. There are four pieces to this puzzle: fsusage, vixie-cron, syslog-ng and swatch. Of course you could swap out syslog-ng and swatch for your favorite logger and watcher, but the snippets I provide here are particular to those programs.
The fsusage script itself is simple: It queries each local filesystem for usage information via df. If usage is 100% then it issues a RED alert to syslog. If usage is >=90% then it issues YELLOW alert to syslog. If usage is <90% then it issues a GREEN alert to syslog, but only if the previous level was non-GREEN.
Each machine runs fsusage once per minute using the following snippet in /etc/cron.d/fsusage.cron:
*/1 * * * * root /usr/local/bin/fsusage
Each machine sends syslog data back to my primary workstation via the following lines in /etc/syslog-ng/syslog-ng.conf:
destination loghost { udp("10.0.0.6"); }; log { source(src); destination(loghost); };
My primary workstation accepts the syslog packets, and gives me ownership of the logfiles, with this snippet. These lines are in addition to the existing src and log lines that log for the local host.
options { owner("agriffis"); }; source net { udp(); }; log { source(src); destination(messages); };
Finally, swatch runs in a screen session. It catches the notifications from fsusage and sends me mail or takes other appropriate actions. Here are the appropriate files to make that happen. (If you don't want to start in screen, then you can just run swatch in a terminal)