diff options
author | jim-p <jimp@pfsense.org> | 2014-05-22 12:47:23 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2014-05-22 12:47:23 -0400 |
commit | 0d4b6b89c97c33c6150058df3c915e6b71d197ac (patch) | |
tree | 5a7cef5b3c288f3ae3b841bcfb364a93709bb5e6 /usr/local/www/includes/functions.inc.php | |
parent | e1854cad12e91e83cede2595dab9a2c66fefd10c (diff) | |
download | pfsense-0d4b6b89c97c33c6150058df3c915e6b71d197ac.zip pfsense-0d4b6b89c97c33c6150058df3c915e6b71d197ac.tar.gz |
Display space usage for all mounted filesystems, not just /. Also display FS type and indicate if it's a RAM disk.
Diffstat (limited to 'usr/local/www/includes/functions.inc.php')
-rw-r--r-- | usr/local/www/includes/functions.inc.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index 7ad0ed9..78043e8 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -191,9 +191,29 @@ function get_temp() { return $temp_out; } -function disk_usage() { +/* Get mounted filesystems and usage. Do not display entries for virtual filesystems (e.g. devfs, nullfs, unionfs) */ +function get_mounted_filesystems() { + $mout = ""; + $filesystems = array(); + exec("/bin/df -Tht ufs,zfs,cd9660 | /usr/bin/awk '{print $1, $2, $3, $6, $7;}'", $mout); + + /* Get rid of the header */ + array_shift($mout); + foreach ($mout as $fs) { + $f = array(); + list($f['device'], $f['type'], $f['total_size'], $f['percent_used'], $f['mountpoint']) = explode(' ', $fs); + + /* We dont' want the trailing % sign. */ + $f['percent_used'] = trim($f['percent_used'], '%'); + + $filesystems[] = $f; + } + return $filesystems; +} + +function disk_usage($slice = '/') { $dfout = ""; - exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout); + exec("/bin/df -h {$slice} | /usr/bin/tail -n 1 | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout); $diskusage = trim($dfout[0]); return $diskusage; |