Projet

Général

Profil

« Précédent | Suivant » 

Révision 0d4b6b89

Ajouté par jim-p il y a presque 10 ans

Display space usage for all mounted filesystems, not just /. Also display FS type and indicate if it's a RAM disk.

Voir les différences:

usr/local/www/includes/functions.inc.php
191 191
	return $temp_out;
192 192
}
193 193

  
194
function disk_usage() {
194
/* Get mounted filesystems and usage. Do not display entries for virtual filesystems (e.g. devfs, nullfs, unionfs) */
195
function get_mounted_filesystems() {
196
	$mout = "";
197
	$filesystems = array();
198
	exec("/bin/df -Tht ufs,zfs,cd9660 | /usr/bin/awk '{print $1, $2, $3, $6, $7;}'", $mout);
199

  
200
	/* Get rid of the header */
201
	array_shift($mout);
202
	foreach ($mout as $fs) {
203
		$f = array();
204
		list($f['device'], $f['type'], $f['total_size'], $f['percent_used'], $f['mountpoint']) = explode(' ', $fs);
205

  
206
		/* We dont' want the trailing % sign. */
207
		$f['percent_used'] = trim($f['percent_used'], '%');
208

  
209
		$filesystems[] = $f;
210
	}
211
	return $filesystems;
212
}
213

  
214
function disk_usage($slice = '/') {
195 215
	$dfout = "";
196
	exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout);
216
	exec("/bin/df -h {$slice} | /usr/bin/tail -n 1 | /usr/bin/awk '{ print $5 }' | /usr/bin/cut -d '%' -f 1", $dfout);
197 217
	$diskusage = trim($dfout[0]);
198 218

  
199 219
	return $diskusage;
usr/local/www/widgets/widgets/system_information.widget.php
85 85

  
86 86
$curcfg = $config['system']['firmware'];
87 87

  
88
$filesystems = get_mounted_filesystems();
89

  
88 90
?>
89 91
<script type="text/javascript">
90 92
//<![CDATA[
......
93 95
		jQuery("#mbufPB").progressbar( { value: <?php echo get_mbuf(true); ?> } );
94 96
		jQuery("#cpuPB").progressbar( { value:false } );
95 97
		jQuery("#memUsagePB").progressbar( { value: <?php echo mem_usage(); ?> } );
96
		jQuery("#diskUsagePB").progressbar( { value: <?php echo disk_usage(); ?> } );
98

  
99
<?PHP $d = 0; ?>
100
<?PHP foreach ($filesystems as $fs): ?>
101
		jQuery("#diskUsagePB<?php echo $d++; ?>").progressbar( { value: <?php echo $fs['percent_used']; ?> } );
102
<?PHP endforeach; ?>
97 103

  
98 104
		<?php if($showswap == true): ?>
99 105
			jQuery("#swapUsagePB").progressbar( { value: <?php echo swap_usage(); ?> } );
......
274 280
		<tr>
275 281
			<td width="25%" class="vncellt"><?=gettext("Disk usage");?></td>
276 282
			<td width="75%" class="listr">
277
				<?php $diskusage = disk_usage(); ?>
278
				<div id="diskUsagePB"></div>
279
				<span id="diskusagemeter"><?= $diskusage.'%'; ?></span> of <?= `/bin/df -h / | /usr/bin/grep -v 'Size' | /usr/bin/awk '{ print $2 }'` ?>
283
<?PHP $d = 0; ?>
284
<?PHP foreach ($filesystems as $fs): ?>
285
				<div id="diskUsagePB<?php echo $d; ?>"></div>
286
				<?PHP if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?>
287
				<?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> of <?PHP echo $fs['total_size'];?>
288
				<br />
289
<?PHP endforeach; ?>
280 290
			</td>
281 291
		</tr>
282 292
	</tbody>

Formats disponibles : Unified diff