diff options
-rw-r--r-- | usr/local/www/includes/functions.inc.php | 24 | ||||
-rw-r--r-- | usr/local/www/widgets/widgets/system_information.widget.php | 18 |
2 files changed, 36 insertions, 6 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; diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 2cb00f2..3705937 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -85,6 +85,8 @@ if($_REQUEST['getupdatestatus']) { $curcfg = $config['system']['firmware']; +$filesystems = get_mounted_filesystems(); + ?> <script type="text/javascript"> //<![CDATA[ @@ -93,7 +95,11 @@ $curcfg = $config['system']['firmware']; jQuery("#mbufPB").progressbar( { value: <?php echo get_mbuf(true); ?> } ); jQuery("#cpuPB").progressbar( { value:false } ); jQuery("#memUsagePB").progressbar( { value: <?php echo mem_usage(); ?> } ); - jQuery("#diskUsagePB").progressbar( { value: <?php echo disk_usage(); ?> } ); + +<?PHP $d = 0; ?> +<?PHP foreach ($filesystems as $fs): ?> + jQuery("#diskUsagePB<?php echo $d++; ?>").progressbar( { value: <?php echo $fs['percent_used']; ?> } ); +<?PHP endforeach; ?> <?php if($showswap == true): ?> jQuery("#swapUsagePB").progressbar( { value: <?php echo swap_usage(); ?> } ); @@ -274,9 +280,13 @@ $curcfg = $config['system']['firmware']; <tr> <td width="25%" class="vncellt"><?=gettext("Disk usage");?></td> <td width="75%" class="listr"> - <?php $diskusage = disk_usage(); ?> - <div id="diskUsagePB"></div> - <span id="diskusagemeter"><?= $diskusage.'%'; ?></span> of <?= `/bin/df -h / | /usr/bin/grep -v 'Size' | /usr/bin/awk '{ print $2 }'` ?> +<?PHP $d = 0; ?> +<?PHP foreach ($filesystems as $fs): ?> + <div id="diskUsagePB<?php echo $d; ?>"></div> + <?PHP if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?> + <?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> of <?PHP echo $fs['total_size'];?> + <br /> +<?PHP endforeach; ?> </td> </tr> </tbody> |