I had a similar issue at one point ... I needed to get the total and used space on LVM logical volumes from a PHP script ...
I wrote an ugly little function that returns a multi-dimensional array with the filesystem data from df
...
Each array contains:
- Filesystem
- Mount Point
- Total Space
- Used Space
Like I said, it's ugly, but it works ...
function disk_space()
{
$cmd = 'df -P | gawk \'{ printf "%s\t%s\t%s\t%s\n", $1, $6, $2, $3 }\'';
$data = trim(shell_exec($cmd));
$return = array();
$lines = explode("\n", $data);
unset($lines[0]);
foreach($lines as $line){
$return[] = explode("\t", $line);
}
return $return;
}