Merge pull request #24 from ayasystems/Disk-use

Disk usage panel info
This commit is contained in:
Kim - DG9VH 2016-06-28 20:55:53 +02:00 committed by GitHub
commit ac06e016ba
3 changed files with 103 additions and 0 deletions

87
include/disk.php Normal file
View file

@ -0,0 +1,87 @@
<div class="panel panel-default">
<!-- Standard-Panel-Inhalt -->
<div class="panel-heading">Disk use</div>
<!-- Tabelle -->
<div class="table-responsive">
<table id="diskuse" class="table table-condensed table-striped table-hover">
<thead>
<tr>
<th class="w10p filesystem">Filesystem</th>
<th class="w20p">Mount</th>
<th>Use</th>
<th class="w15p">Free</th>
<th class="w15p">Used</th>
<th class="w15p">Total</th>
</tr>
</thead>
<tbody>
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//include "./functions.php";
try{
$datas = array();
if (!(exec('/bin/df -T | awk -v c=`/bin/df -T | grep -bo "Type" | awk -F: \'{print $2}\'` \'{print substr($0,c);}\' | tail -n +2 | awk \'{print $1","$2","$3","$4","$5","$6","$7}\'', $df)))
{
$datas[] = array(
'total' => 'N.A',
'used' => 'N.A',
'free' => 'N.A',
'percent_used' => 0,
'mount' => 'N.A',
'filesystem' => 'N.A',
);
}
else
{
$mounted_points = array();
$key = 0;
foreach ($df as $mounted)
{
list($filesystem, $type, $total, $used, $free, $percent, $mount) = explode(',', $mounted);
if (strpos($type, 'tmpfs') !== false )
continue;
?>
<tr>
<td><?php echo $filesystem ?></td>
<td><?php echo $mount ?></td>
<td><div class="progress"><div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="<?php echo trim($percent, '%') ?>" aria-valuemin="0" aria-valuemax="100" style="width: <?php echo trim($percent, '%') ?>%;"><?php echo trim($percent, '%') ?>%</div></div></td>
<td><?php echo getSize($free * 1024) ?></td>
<td><?php echo getSize($used * 1024) ?></td>
<td><?php echo getSize($total * 1024) ?></td>
</tr>
<?php
$key++;
}
}
} catch (Exception $e) {
return false;
}
?>
</tbody>
</table>
</div>
</div>

View file

@ -469,6 +469,21 @@ function getActiveYSFReflectors($logLines) {
return $reflectorlist;
}
function getSize($filesize, $precision = 2)
{
$units = array('', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y');
foreach ($units as $idUnit => $unit)
{
if ($filesize > 1024)
$filesize /= 1024;
else
break;
}
return round($filesize, $precision).' '.$units[$idUnit].'B';
}
//Some basic inits
$mmdvmconfigs = getMMDVMConfig();
$logLinesMMDVM = getMMDVMLog();

View file

@ -53,6 +53,7 @@ if (defined("ENABLEMANAGEMENT")) {
checkSetup();
// Here you can feel free to disable info-sections by commenting out with // before include
include "include/sysinfo.php";
include "include/disk.php";
include "include/repeaterinfo.php";
include "include/modes.php";
include "include/lh.php";