I have a collection of Linux servers, each of which has a local hard drive with a /tmp directory. Occasionally, the /tmp directory on a server will fill up and cause errors. I want to automate the process of checking for free space on each local drive so that /tmp can be cleaned before it causes a problem. Is there an elegant, programmatic way to determine the amount of free space on a disk on Linux? I know the "classical" answer is to run
df -h
on each server (perhaps using a distributed shell tool such as dsh) and write a script to parse the output. Many such scripts can be found online. I am looking for a more elegant solution, such as a newer disk utility that returns structured data, or some information buried in the /proc filesystem.